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;
89 import jalview.util.Platform;
92 * Base class for the Preferences panel.
97 public class GPreferences extends JPanel
99 private static final Font LABEL_FONT = JvSwingUtils.getLabelFont();
101 private static final Font LABEL_FONT_ITALIC = JvSwingUtils
102 .getLabelFont(false, true);
104 private static final Font LABEL_FONT_BOLD = JvSwingUtils
105 .getLabelFont(true, false);
108 * Visual tab components
110 protected JCheckBox fullScreen = new JCheckBox();
112 protected JCheckBox openoverv = new JCheckBox();
114 protected JCheckBox seqLimit = new JCheckBox();
116 protected JCheckBox rightAlign = new JCheckBox();
118 protected JComboBox<String> fontSizeCB = new JComboBox<>();
120 protected JComboBox<String> fontStyleCB = new JComboBox<>();
122 protected JComboBox<String> fontNameCB = new JComboBox<>();
124 protected JCheckBox showOccupancy = new JCheckBox();
126 protected JCheckBox showUnconserved = new JCheckBox();
128 protected JCheckBox idItalics = new JCheckBox();
130 protected JCheckBox smoothFont = new JCheckBox();
132 protected JCheckBox scaleProteinToCdna = new JCheckBox();
134 protected JComboBox<String> gapSymbolCB = new JComboBox<>();
136 protected JCheckBox wrap = new JCheckBox();
138 protected JComboBox<String> sortby = new JComboBox<>();
140 protected JComboBox<String> sortAnnBy = new JComboBox<>();
142 protected JComboBox<String> sortAutocalc = new JComboBox<>();
144 protected JCheckBox startupCheckbox = new JCheckBox();
146 protected JTextField startupFileTextfield = new JTextField();
148 // below are in the 'second column'
149 protected JCheckBox annotations = new JCheckBox();
151 protected JCheckBox quality = new JCheckBox();
153 protected JCheckBox conservation = new JCheckBox();
155 protected JCheckBox identity = new JCheckBox();
157 protected JCheckBox showGroupConsensus = new JCheckBox();
159 protected JCheckBox showGroupConservation = new JCheckBox();
161 protected JCheckBox showConsensHistogram = new JCheckBox();
163 protected JCheckBox showConsensLogo = new JCheckBox();
165 protected JCheckBox showDbRefTooltip = new JCheckBox();
167 protected JCheckBox showNpTooltip = new JCheckBox();
170 * Structure tab and components
172 protected JPanel structureTab;
174 protected JCheckBox structFromPdb = new JCheckBox();
176 protected JCheckBox useRnaView = new JCheckBox();
178 protected JCheckBox addSecondaryStructure = new JCheckBox();
180 protected JCheckBox addTempFactor = new JCheckBox();
182 protected JComboBox<String> structViewer = new JComboBox<>();
184 protected JLabel structureViewerPathLabel;
186 protected JTextField structureViewerPath = new JTextField();
188 protected ButtonGroup mappingMethod = new ButtonGroup();
190 protected JRadioButton siftsMapping = new JRadioButton();
192 protected JRadioButton nwMapping = new JRadioButton();
195 * Colours tab components
197 protected JPanel minColour = new JPanel();
199 protected JPanel maxColour = new JPanel();
201 protected JComboBox<String> protColour = new JComboBox<>();
203 protected JComboBox<String> nucColour = new JComboBox<>();
206 * Overview tab components
208 protected JPanel gapColour = new JPanel();
210 protected JPanel hiddenColour = new JPanel();
212 protected JCheckBox useLegacyGap;
214 protected JCheckBox showHiddenAtStart;
216 protected JLabel gapLabel;
219 * Connections tab components
221 protected JTable linkUrlTable = new JTable();
223 protected JButton editLink = new JButton();
225 protected JButton deleteLink = new JButton();
227 protected JTextField filterTB = new JTextField();
229 protected JButton doReset = new JButton();
231 protected JButton userOnly = new JButton();
233 protected JLabel httpLabel = new JLabel();
235 protected JLabel httpsLabel = new JLabel();
237 protected JLabel portLabel = new JLabel();
239 protected JLabel serverLabel = new JLabel();
241 protected JLabel portLabel2 = new JLabel();
243 protected JLabel serverLabel2 = new JLabel();
245 protected JLabel proxyAuthUsernameLabel = new JLabel();
247 protected JLabel proxyAuthPasswordLabel = new JLabel();
249 protected JTextField proxyServerHttpTB = new JTextField();
251 protected JTextField proxyPortHttpTB = new JTextField();
253 protected JTextField proxyServerHttpsTB = new JTextField();
255 protected JTextField proxyPortHttpsTB = new JTextField();
257 protected JCheckBox proxyAuth = new JCheckBox();
259 protected JTextField proxyAuthUsernameTB = new JTextField();
261 protected JTextField proxyAuthPasswordTB = new JPasswordField();
263 protected JTextField defaultBrowser = new JTextField();
265 protected ButtonGroup proxyType = new ButtonGroup();
267 protected JRadioButton noProxy = new JRadioButton();
269 protected JRadioButton systemProxy = new JRadioButton();
271 protected JRadioButton customProxy = new JRadioButton();
273 protected JCheckBox usagestats = new JCheckBox();
275 protected JCheckBox questionnaire = new JCheckBox();
277 protected JCheckBox versioncheck = new JCheckBox();
280 * Output tab components
282 protected JComboBox<Object> epsRendering = new JComboBox<>();
284 protected JComboBox<Object> htmlRendering = new JComboBox<>();
286 protected JComboBox<Object> svgRendering = new JComboBox<>();
288 protected JLabel userIdWidthlabel = new JLabel();
290 protected JCheckBox autoIdWidth = new JCheckBox();
292 protected JTextField userIdWidth = new JTextField();
294 protected JCheckBox blcjv = new JCheckBox();
296 protected JCheckBox pileupjv = new JCheckBox();
298 protected JCheckBox clustaljv = new JCheckBox();
300 protected JCheckBox msfjv = new JCheckBox();
302 protected JCheckBox fastajv = new JCheckBox();
304 protected JCheckBox pfamjv = new JCheckBox();
306 protected JCheckBox pirjv = new JCheckBox();
308 protected JCheckBox modellerOutput = new JCheckBox();
310 protected JCheckBox embbedBioJSON = new JCheckBox();
313 * Editing tab components
315 protected JCheckBox autoCalculateConsCheck = new JCheckBox();
317 protected JCheckBox padGaps = new JCheckBox();
319 protected JCheckBox sortByTree = new JCheckBox();
324 protected JPanel wsTab = new JPanel();
327 * Backups tab components
328 * a lot of these are member variables instead of local variables only so that they
329 * can be enabled/disabled easily in one go
332 protected JCheckBox enableBackupFiles = new JCheckBox();
334 protected JPanel presetsPanel = new JPanel();
336 protected JLabel presetsComboLabel = new JLabel();
338 protected JCheckBox customiseCheckbox = new JCheckBox();
340 protected JButton revertButton = new JButton();
342 protected JComboBox<Object> backupfilesPresetsCombo = new JComboBox<>();
344 private int backupfilesPresetsComboLastSelected = 0;
346 protected JPanel suffixPanel = new JPanel();
348 protected JPanel keepfilesPanel = new JPanel();
350 protected JPanel exampleFilesPanel = new JPanel();
352 protected JTextField suffixTemplate = new JTextField(null, 8);
354 protected JLabel suffixTemplateLabel = new JLabel();
356 protected JLabel suffixDigitsLabel = new JLabel();
358 protected JSpinner suffixDigitsSpinner = new JSpinner();
360 protected JalviewBooleanRadioButtons suffixReverse = new JalviewBooleanRadioButtons();
362 protected JalviewBooleanRadioButtons backupfilesKeepAll = new JalviewBooleanRadioButtons();
364 public JSpinner backupfilesRollMaxSpinner = new JSpinner();
366 protected JLabel oldBackupFilesLabel = new JLabel();
368 protected JalviewBooleanRadioButtons backupfilesConfirmDelete = new JalviewBooleanRadioButtons();
370 protected JTextArea backupfilesExampleLabel = new JTextArea();
373 * Creates a new GPreferences object.
375 public GPreferences()
380 } catch (Exception ex)
382 ex.printStackTrace();
387 * Construct the panel and its tabbed sub-panels.
391 private void jbInit() throws Exception
393 final JTabbedPane tabbedPane = new JTabbedPane();
394 this.setLayout(new BorderLayout());
395 JPanel okCancelPanel = initOkCancelPanel();
396 this.add(tabbedPane, BorderLayout.CENTER);
397 this.add(okCancelPanel, BorderLayout.SOUTH);
399 tabbedPane.add(initVisualTab(),
400 MessageManager.getString("label.visual"));
402 tabbedPane.add(initColoursTab(),
403 MessageManager.getString("label.colours"));
405 tabbedPane.add(initOverviewTab(),
406 MessageManager.getString("label.overview"));
408 tabbedPane.add(initStructureTab(),
409 MessageManager.getString("label.structure"));
411 tabbedPane.add(initConnectionsTab(),
412 MessageManager.getString("label.connections"));
414 if (!Platform.isJS())
416 tabbedPane.add(initBackupsTab(),
417 MessageManager.getString("label.backups"));
420 tabbedPane.add(initLinksTab(),
421 MessageManager.getString("label.urllinks"));
423 tabbedPane.add(initOutputTab(),
424 MessageManager.getString("label.output"));
426 tabbedPane.add(initEditingTab(),
427 MessageManager.getString("label.editing"));
430 * See WsPreferences for the real work of configuring this tab.
432 if (!Platform.isJS())
434 wsTab.setLayout(new BorderLayout());
435 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
439 * Handler to validate a tab before leaving it - currently only for
442 tabbedPane.addChangeListener(new ChangeListener()
444 private Component lastTab;
447 public void stateChanged(ChangeEvent e)
449 if (lastTab == structureTab
450 && tabbedPane.getSelectedComponent() != structureTab)
452 if (!validateStructure())
454 tabbedPane.setSelectedComponent(structureTab);
458 lastTab = tabbedPane.getSelectedComponent();
465 * Initialises the Editing tabbed panel.
469 private JPanel initEditingTab()
471 JPanel editingTab = new JPanel();
472 editingTab.setLayout(null);
473 autoCalculateConsCheck.setFont(LABEL_FONT);
474 autoCalculateConsCheck.setText(
475 MessageManager.getString("label.autocalculate_consensus"));
476 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
477 padGaps.setFont(LABEL_FONT);
479 MessageManager.getString("label.pad_gaps_when_editing"));
480 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
481 sortByTree.setFont(LABEL_FONT);
483 .setText(MessageManager.getString("label.sort_with_new_tree"));
484 sortByTree.setToolTipText(MessageManager.getString(
485 "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
486 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
487 editingTab.add(autoCalculateConsCheck);
488 editingTab.add(padGaps);
489 editingTab.add(sortByTree);
494 * Initialises the Output tab
498 private JPanel initOutputTab()
500 JPanel outputTab = new JPanel();
501 outputTab.setLayout(null);
503 JLabel epsLabel = new JLabel(
504 MessageManager.formatMessage("label.rendering_style", "EPS"));
505 epsLabel.setFont(LABEL_FONT);
506 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
507 epsLabel.setBounds(new Rectangle(9, 31, 160, 24));
508 epsRendering.setFont(LABEL_FONT);
509 epsRendering.setBounds(new Rectangle(174, 34, 187, 21));
510 JLabel htmlLabel = new JLabel(
511 MessageManager.formatMessage("label.rendering_style", "HTML"));
512 htmlLabel.setFont(LABEL_FONT);
513 htmlLabel.setHorizontalAlignment(SwingConstants.RIGHT);
514 htmlLabel.setBounds(new Rectangle(9, 55, 160, 24));
515 htmlRendering.setFont(LABEL_FONT);
516 htmlRendering.setBounds(new Rectangle(174, 58, 187, 21));
517 JLabel svgLabel = new JLabel(
518 MessageManager.formatMessage("label.rendering_style", "SVG"));
519 svgLabel.setFont(LABEL_FONT);
520 svgLabel.setHorizontalAlignment(SwingConstants.RIGHT);
521 svgLabel.setBounds(new Rectangle(9, 79, 160, 24));
522 svgRendering.setFont(LABEL_FONT);
523 svgRendering.setBounds(new Rectangle(174, 82, 187, 21));
525 JLabel jLabel1 = new JLabel();
526 jLabel1.setFont(LABEL_FONT);
527 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
528 jLabel1.setText(MessageManager.getString("label.append_start_end"));
529 jLabel1.setFont(LABEL_FONT);
531 fastajv.setFont(LABEL_FONT);
532 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
533 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
534 blcjv.setText(MessageManager.getString("label.blc") + " ");
535 fastajv.setText(MessageManager.getString("label.fasta") + " ");
536 msfjv.setText(MessageManager.getString("label.msf") + " ");
537 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
538 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
539 msfjv.setFont(LABEL_FONT);
540 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
541 pirjv.setText(MessageManager.getString("label.pir") + " ");
542 JPanel jPanel11 = new JPanel();
543 jPanel11.setFont(LABEL_FONT);
544 TitledBorder titledBorder2 = new TitledBorder(
545 MessageManager.getString("label.file_output"));
546 jPanel11.setBorder(titledBorder2);
547 jPanel11.setBounds(new Rectangle(30, 120, 196, 182));
548 GridLayout gridLayout3 = new GridLayout();
549 jPanel11.setLayout(gridLayout3);
550 gridLayout3.setRows(8);
551 blcjv.setFont(LABEL_FONT);
552 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
553 clustaljv.setFont(LABEL_FONT);
554 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
555 pfamjv.setFont(LABEL_FONT);
556 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
557 pileupjv.setFont(LABEL_FONT);
558 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
559 pirjv.setFont(LABEL_FONT);
560 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
561 autoIdWidth.setFont(LABEL_FONT);
563 MessageManager.getString("label.automatically_set_id_width"));
564 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
565 .getString("label.adjusts_width_generated_eps_png")));
566 autoIdWidth.setBounds(new Rectangle(228, 144, 320, 23));
567 autoIdWidth.addActionListener(new ActionListener()
571 public void actionPerformed(ActionEvent e)
573 autoIdWidth_actionPerformed();
576 userIdWidthlabel.setFont(LABEL_FONT);
577 userIdWidthlabel.setText(
578 MessageManager.getString("label.figure_id_column_width"));
579 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
580 .getString("label.manually_specify_width_left_column")));
581 userIdWidthlabel.setToolTipText(
582 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
583 "label.manually_specify_width_left_column")));
584 userIdWidthlabel.setBounds(new Rectangle(236, 168, 320, 23));
585 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
586 userIdWidth.setText("");
587 userIdWidth.setBounds(new Rectangle(232, 192, 84, 23));
588 userIdWidth.addActionListener(new ActionListener()
592 public void actionPerformed(ActionEvent e)
594 userIdWidth_actionPerformed();
597 modellerOutput.setFont(LABEL_FONT);
599 .setText(MessageManager.getString("label.use_modeller_output"));
600 modellerOutput.setBounds(new Rectangle(228, 274, 320, 23));
601 embbedBioJSON.setFont(LABEL_FONT);
602 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
603 embbedBioJSON.setBounds(new Rectangle(228, 248, 250, 23));
605 jPanel11.add(jLabel1);
607 jPanel11.add(clustaljv);
608 jPanel11.add(fastajv);
610 jPanel11.add(pfamjv);
611 jPanel11.add(pileupjv);
613 outputTab.add(autoIdWidth);
614 outputTab.add(userIdWidth);
615 outputTab.add(userIdWidthlabel);
616 outputTab.add(modellerOutput);
617 if (!Platform.isJS())
620 * JalviewJS doesn't support Lineart option or SVG output
622 outputTab.add(embbedBioJSON);
623 outputTab.add(epsLabel);
624 outputTab.add(epsRendering);
625 outputTab.add(htmlLabel);
626 outputTab.add(htmlRendering);
627 outputTab.add(svgLabel);
628 outputTab.add(svgRendering);
630 outputTab.add(jPanel11);
635 * Initialises the Connections tabbed panel.
639 private JPanel initConnectionsTab()
641 JPanel connectTab = new JPanel();
642 connectTab.setLayout(new GridBagLayout());
644 // Label for browser text box
645 JLabel browserLabel = new JLabel();
646 browserLabel.setFont(LABEL_FONT);
647 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
648 browserLabel.setText(
649 MessageManager.getString("label.default_browser_unix"));
650 defaultBrowser.setFont(LABEL_FONT);
651 defaultBrowser.setText("");
652 final String tooltip = JvSwingUtils.wrapTooltip(true,
653 MessageManager.getString("label.double_click_to_browse"));
654 defaultBrowser.setToolTipText(tooltip);
655 defaultBrowser.addMouseListener(new MouseAdapter()
658 public void mouseClicked(MouseEvent e)
660 if (e.getClickCount() > 1)
662 defaultBrowser_mouseClicked(e);
667 JPanel proxyPanel = initConnTabProxyPanel();
668 initConnTabCheckboxes();
670 // Add default Browser text box
671 connectTab.add(browserLabel,
672 new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
673 GridBagConstraints.WEST, GridBagConstraints.NONE,
674 new Insets(10, 0, 5, 5), 5, 1));
675 defaultBrowser.setFont(LABEL_FONT);
676 defaultBrowser.setText("");
678 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
679 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
680 new Insets(10, 0, 5, 10), 30, 1));
682 // Add proxy server panel
683 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
684 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
685 new Insets(10, 0, 5, 12), 4, 10));
687 // Add usage stats, version check and questionnaire checkboxes
688 connectTab.add(usagestats,
689 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
690 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
691 new Insets(0, 2, 5, 5), 70, 1));
692 connectTab.add(questionnaire,
693 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
694 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
695 new Insets(0, 2, 5, 10), 70, 1));
696 connectTab.add(versioncheck,
697 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
698 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
699 new Insets(0, 2, 5, 5), 70, 1));
701 versioncheck.setVisible(false);
703 // Add padding so the panel doesn't look ridiculous
704 JPanel spacePanel = new JPanel();
705 connectTab.add(spacePanel,
706 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
707 GridBagConstraints.WEST, GridBagConstraints.BOTH,
708 new Insets(0, 0, 0, 5), 70, 1));
714 * Initialises the Links tabbed panel.
718 private JPanel initLinksTab()
720 JPanel linkTab = new JPanel();
721 linkTab.setLayout(new GridBagLayout());
723 // Set up table for Url links
724 linkUrlTable.getTableHeader().setReorderingAllowed(false);
725 linkUrlTable.setFillsViewportHeight(true);
726 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
727 linkUrlTable.setAutoCreateRowSorter(true);
728 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
730 // adjust row height so radio buttons actually fit
731 // don't do this in the renderer, it causes the awt thread to activate
733 JRadioButton temp = new JRadioButton();
734 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
736 // Table in scrollpane so that the table is given a scrollbar
737 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
738 linkScrollPane.setBorder(null);
740 // Panel for links functionality
741 JPanel linkPanel = new JPanel(new GridBagLayout());
742 linkPanel.setBorder(new TitledBorder(
743 MessageManager.getString("label.url_linkfrom_sequence_id")));
745 // Put the Url links panel together
747 // Buttons go at top right, resizing only resizes the blank space vertically
748 JPanel buttonPanel = initLinkTabUrlButtons();
749 GridBagConstraints linkConstraints1 = new GridBagConstraints();
750 linkConstraints1.insets = new Insets(0, 0, 5, 0);
751 linkConstraints1.gridx = 0;
752 linkConstraints1.gridy = 0;
753 linkConstraints1.weightx = 1.0;
754 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
755 linkTab.add(buttonPanel, linkConstraints1);
757 // Links table goes at top left, resizing resizes the table
758 GridBagConstraints linkConstraints2 = new GridBagConstraints();
759 linkConstraints2.insets = new Insets(0, 0, 5, 5);
760 linkConstraints2.gridx = 0;
761 linkConstraints2.gridy = 1;
762 linkConstraints2.weightx = 1.0;
763 linkConstraints2.weighty = 1.0;
764 linkConstraints2.fill = GridBagConstraints.BOTH;
765 linkTab.add(linkScrollPane, linkConstraints2);
767 // Filter box and buttons goes at bottom left, resizing resizes the text box
768 JPanel filterPanel = initLinkTabFilterPanel();
769 GridBagConstraints linkConstraints3 = new GridBagConstraints();
770 linkConstraints3.insets = new Insets(0, 0, 0, 5);
771 linkConstraints3.gridx = 0;
772 linkConstraints3.gridy = 2;
773 linkConstraints3.weightx = 1.0;
774 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
775 linkTab.add(filterPanel, linkConstraints3);
780 private JPanel initLinkTabFilterPanel()
782 // Filter textbox and reset button
783 JLabel filterLabel = new JLabel(
784 MessageManager.getString("label.filter"));
785 filterLabel.setFont(LABEL_FONT);
786 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
787 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
789 filterTB.setFont(LABEL_FONT);
790 filterTB.setText("");
792 doReset.setText(MessageManager.getString("action.showall"));
793 userOnly.setText(MessageManager.getString("action.customfilter"));
795 // Panel for filter functionality
796 JPanel filterPanel = new JPanel(new GridBagLayout());
797 filterPanel.setBorder(new TitledBorder("Filter"));
798 GridBagConstraints gbc = new GridBagConstraints();
801 gbc.fill = GridBagConstraints.NONE;
802 gbc.anchor = GridBagConstraints.WEST;
804 filterPanel.add(filterLabel, gbc);
806 GridBagConstraints gbc1 = new GridBagConstraints();
809 gbc1.fill = GridBagConstraints.HORIZONTAL;
810 gbc1.anchor = GridBagConstraints.WEST;
812 filterPanel.add(filterTB, gbc1);
814 GridBagConstraints gbc2 = new GridBagConstraints();
816 gbc2.fill = GridBagConstraints.NONE;
817 gbc2.anchor = GridBagConstraints.WEST;
818 filterPanel.add(doReset, gbc2);
820 GridBagConstraints gbc3 = new GridBagConstraints();
822 gbc3.fill = GridBagConstraints.NONE;
823 gbc3.anchor = GridBagConstraints.WEST;
824 filterPanel.add(userOnly, gbc3);
829 private JPanel initLinkTabUrlButtons()
831 // Buttons for new / edit / delete Url links
832 JButton newLink = new JButton();
833 newLink.setText(MessageManager.getString("action.new"));
835 editLink.setText(MessageManager.getString("action.edit"));
837 deleteLink.setText(MessageManager.getString("action.delete"));
839 // no current selection, so initially disable delete/edit buttons
840 editLink.setEnabled(false);
841 deleteLink.setEnabled(false);
843 newLink.addActionListener(new java.awt.event.ActionListener()
846 public void actionPerformed(ActionEvent e)
848 newLink_actionPerformed(e);
852 editLink.setText(MessageManager.getString("action.edit"));
853 editLink.addActionListener(new java.awt.event.ActionListener()
856 public void actionPerformed(ActionEvent e)
858 editLink_actionPerformed(e);
862 deleteLink.setText(MessageManager.getString("action.delete"));
863 deleteLink.addActionListener(new java.awt.event.ActionListener()
866 public void actionPerformed(ActionEvent e)
868 deleteLink_actionPerformed(e);
872 JPanel buttonPanel = new JPanel(new GridBagLayout());
873 buttonPanel.setBorder(new TitledBorder("Edit links"));
874 GridBagConstraints gbc = new GridBagConstraints();
877 gbc.fill = GridBagConstraints.NONE;
878 buttonPanel.add(newLink, gbc);
880 GridBagConstraints gbc1 = new GridBagConstraints();
883 gbc1.fill = GridBagConstraints.NONE;
884 buttonPanel.add(editLink, gbc1);
886 GridBagConstraints gbc2 = new GridBagConstraints();
889 gbc2.fill = GridBagConstraints.NONE;
890 buttonPanel.add(deleteLink, gbc2);
892 GridBagConstraints gbc3 = new GridBagConstraints();
895 gbc3.fill = GridBagConstraints.HORIZONTAL;
897 JPanel spacePanel = new JPanel();
898 spacePanel.setBorder(null);
899 buttonPanel.add(spacePanel, gbc3);
905 * Initialises the proxy server panel in the Connections tab
907 * @return the proxy server panel
909 private JPanel initConnTabProxyPanel()
911 // Label for server text box
912 serverLabel.setText(MessageManager.getString("label.host") + ": ");
913 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
914 serverLabel.setFont(LABEL_FONT);
915 serverLabel2.setText(MessageManager.getString("label.host") + ": ");
916 serverLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
917 serverLabel2.setFont(LABEL_FONT);
919 // Proxy server and port text boxes
920 proxyServerHttpTB.setFont(LABEL_FONT);
921 proxyServerHttpTB.setColumns(40);
922 proxyPortHttpTB.setFont(LABEL_FONT);
923 proxyPortHttpTB.setColumns(4);
924 proxyServerHttpsTB.setFont(LABEL_FONT);
925 proxyServerHttpsTB.setColumns(40);
926 proxyPortHttpsTB.setFont(LABEL_FONT);
927 proxyPortHttpsTB.setColumns(4);
928 proxyAuthUsernameTB.setFont(LABEL_FONT);
929 proxyAuthUsernameTB.setColumns(30);
930 proxyAuthPasswordTB.setFont(LABEL_FONT);
931 proxyAuthPasswordTB.setColumns(30);
933 // Label for Port text box
934 portLabel.setFont(LABEL_FONT);
935 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
936 portLabel.setText(MessageManager.getString("label.port") + ": ");
937 portLabel2.setFont(LABEL_FONT);
938 portLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
939 portLabel2.setText(MessageManager.getString("label.port") + ": ");
941 httpLabel.setText("HTTP");
942 httpLabel.setFont(LABEL_FONT_BOLD);
943 httpLabel.setHorizontalAlignment(SwingConstants.LEFT);
944 httpsLabel.setText("HTTPS");
945 httpsLabel.setFont(LABEL_FONT_BOLD);
946 httpsLabel.setHorizontalAlignment(SwingConstants.LEFT);
948 proxyAuthUsernameLabel
949 .setText(MessageManager.getString("label.username") + ": ");
950 proxyAuthUsernameLabel.setFont(LABEL_FONT);
951 proxyAuthUsernameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
952 proxyAuthPasswordLabel
953 .setText(MessageManager.getString("label.password") + ": ");
954 proxyAuthPasswordLabel.setFont(LABEL_FONT);
955 proxyAuthPasswordLabel.setHorizontalAlignment(SwingConstants.RIGHT);
957 // Proxy type radio buttons
958 noProxy.setFont(LABEL_FONT);
959 noProxy.setHorizontalAlignment(SwingConstants.LEFT);
960 noProxy.setText(MessageManager.getString("label.no_proxy"));
961 systemProxy.setFont(LABEL_FONT);
962 systemProxy.setHorizontalAlignment(SwingConstants.LEFT);
963 systemProxy.setText(MessageManager.formatMessage("label.system_proxy",
964 displayHostPort(Cache.startupProxyProperties[0],
965 Cache.startupProxyProperties[1]),
966 displayHostPort(Cache.startupProxyProperties[2],
967 Cache.startupProxyProperties[3])));
968 customProxy.setFont(LABEL_FONT);
969 customProxy.setHorizontalAlignment(SwingConstants.LEFT);
971 MessageManager.getString("label.use_proxy_server") + ":");
972 ActionListener al = new ActionListener()
975 public void actionPerformed(ActionEvent e)
977 proxyType_actionPerformed();
980 noProxy.addActionListener(al);
981 systemProxy.addActionListener(al);
982 customProxy.addActionListener(al);
983 proxyType.add(noProxy);
984 proxyType.add(systemProxy);
985 proxyType.add(customProxy);
987 proxyAuth.setFont(LABEL_FONT);
988 proxyAuth.setHorizontalAlignment(SwingConstants.LEFT);
989 proxyAuth.setText(MessageManager.getString("label.auth_required"));
990 proxyAuth.addActionListener(new ActionListener()
993 public void actionPerformed(ActionEvent e)
995 proxyAuth_actionPerformed();
999 setCustomProxyEnabled();
1000 setProxyAuthEnabled();
1002 // Make proxy server panel
1003 JPanel proxyPanel = new JPanel();
1004 TitledBorder titledBorder1 = new TitledBorder(
1005 MessageManager.getString("label.proxy_servers"));
1006 proxyPanel.setBorder(titledBorder1);
1007 GridBagConstraints gbc = new GridBagConstraints();
1008 proxyPanel.setLayout(new GridBagLayout());
1014 gbc.anchor = GridBagConstraints.WEST;
1015 gbc.fill = GridBagConstraints.BOTH;
1018 proxyPanel.add(noProxy, gbc);
1021 proxyPanel.add(systemProxy, gbc);
1024 proxyPanel.add(customProxy, gbc);
1030 proxyPanel.add(httpLabel, gbc);
1033 gbc.anchor = GridBagConstraints.EAST;
1035 proxyPanel.add(serverLabel, gbc);
1038 gbc.anchor = GridBagConstraints.WEST;
1040 proxyPanel.add(proxyServerHttpTB, gbc);
1043 gbc.anchor = GridBagConstraints.EAST;
1045 proxyPanel.add(portLabel, gbc);
1048 gbc.anchor = GridBagConstraints.WEST;
1050 proxyPanel.add(proxyPortHttpTB, gbc);
1054 gbc.anchor = GridBagConstraints.WEST;
1056 proxyPanel.add(httpsLabel, gbc);
1059 gbc.anchor = GridBagConstraints.EAST;
1061 proxyPanel.add(serverLabel2, gbc);
1064 gbc.anchor = GridBagConstraints.WEST;
1066 proxyPanel.add(proxyServerHttpsTB, gbc);
1069 gbc.anchor = GridBagConstraints.EAST;
1071 proxyPanel.add(portLabel2, gbc);
1074 gbc.anchor = GridBagConstraints.WEST;
1076 proxyPanel.add(proxyPortHttpsTB, gbc);
1081 gbc.anchor = GridBagConstraints.WEST;
1083 proxyPanel.add(proxyAuth, gbc);
1088 gbc.anchor = GridBagConstraints.EAST;
1089 proxyPanel.add(proxyAuthUsernameLabel, gbc);
1093 gbc.anchor = GridBagConstraints.WEST;
1094 proxyPanel.add(proxyAuthUsernameTB, gbc);
1099 gbc.anchor = GridBagConstraints.EAST;
1100 proxyPanel.add(proxyAuthPasswordLabel, gbc);
1104 gbc.anchor = GridBagConstraints.WEST;
1105 proxyPanel.add(proxyAuthPasswordTB, gbc);
1110 private String displayHostPort(String host, String port)
1112 boolean hostBlank = (host == null || host.isEmpty());
1113 boolean portBlank = (port == null || port.isEmpty());
1114 if (hostBlank && portBlank)
1116 return MessageManager.getString("label.none");
1119 StringBuilder sb = new StringBuilder();
1120 sb.append(hostBlank ? "" : host);
1126 return sb.toString();
1130 * Initialises the checkboxes in the Connections tab
1132 private void initConnTabCheckboxes()
1134 // Usage stats checkbox label
1136 MessageManager.getString("label.send_usage_statistics"));
1137 usagestats.setFont(LABEL_FONT);
1138 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
1139 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
1141 // Questionnaire checkbox label
1142 questionnaire.setText(
1143 MessageManager.getString("label.check_for_questionnaires"));
1144 questionnaire.setFont(LABEL_FONT);
1145 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
1146 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
1148 // Check for latest version checkbox label
1149 versioncheck.setText(
1150 MessageManager.getString("label.check_for_latest_version"));
1151 versioncheck.setFont(LABEL_FONT);
1152 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
1153 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
1157 * Initialises the parent panel which contains the tabbed sections.
1161 private JPanel initOkCancelPanel()
1163 JButton ok = new JButton();
1164 ok.setText(MessageManager.getString("action.ok"));
1165 ok.addActionListener(new ActionListener()
1168 public void actionPerformed(ActionEvent e)
1170 ok_actionPerformed(e);
1173 JButton cancel = new JButton();
1174 cancel.setText(MessageManager.getString("action.cancel"));
1175 cancel.addActionListener(new ActionListener()
1178 public void actionPerformed(ActionEvent e)
1180 cancel_actionPerformed(e);
1183 JPanel okCancelPanel = new JPanel();
1184 okCancelPanel.add(ok);
1185 okCancelPanel.add(cancel);
1186 return okCancelPanel;
1190 * Initialises the Colours tabbed panel.
1194 private JPanel initColoursTab()
1196 JPanel coloursTab = new JPanel();
1197 coloursTab.setBorder(new TitledBorder(
1198 MessageManager.getString("action.open_new_alignment")));
1199 coloursTab.setLayout(new FlowLayout());
1200 JLabel mincolourLabel = new JLabel();
1201 mincolourLabel.setFont(LABEL_FONT);
1202 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1203 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
1204 minColour.setFont(LABEL_FONT);
1205 minColour.setBorder(BorderFactory.createEtchedBorder());
1206 minColour.setPreferredSize(new Dimension(40, 20));
1207 minColour.addMouseListener(new MouseAdapter()
1210 public void mousePressed(MouseEvent e)
1212 minColour_actionPerformed(minColour);
1215 JLabel maxcolourLabel = new JLabel();
1216 maxcolourLabel.setFont(LABEL_FONT);
1217 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1218 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
1219 maxColour.setFont(LABEL_FONT);
1220 maxColour.setBorder(BorderFactory.createEtchedBorder());
1221 maxColour.setPreferredSize(new Dimension(40, 20));
1222 maxColour.addMouseListener(new MouseAdapter()
1225 public void mousePressed(MouseEvent e)
1227 maxColour_actionPerformed(maxColour);
1231 protColour.setFont(LABEL_FONT);
1232 protColour.setBounds(new Rectangle(172, 225, 155, 21));
1233 JLabel protColourLabel = new JLabel();
1234 protColourLabel.setFont(LABEL_FONT);
1235 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1236 protColourLabel.setText(
1237 MessageManager.getString("label.prot_alignment_colour") + " ");
1238 JvSwingUtils.addtoLayout(coloursTab,
1240 .getString("label.default_colour_scheme_for_alignment"),
1241 protColourLabel, protColour);
1243 nucColour.setFont(LABEL_FONT);
1244 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1245 JLabel nucColourLabel = new JLabel();
1246 nucColourLabel.setFont(LABEL_FONT);
1247 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1248 nucColourLabel.setText(
1249 MessageManager.getString("label.nuc_alignment_colour") + " ");
1250 JvSwingUtils.addtoLayout(coloursTab,
1252 .getString("label.default_colour_scheme_for_alignment"),
1253 nucColourLabel, nucColour);
1255 JPanel annotationShding = new JPanel();
1256 annotationShding.setBorder(new TitledBorder(
1257 MessageManager.getString("label.annotation_shading_default")));
1258 annotationShding.setLayout(new GridLayout(1, 2));
1259 JvSwingUtils.addtoLayout(annotationShding,
1260 MessageManager.getString(
1261 "label.default_minimum_colour_annotation_shading"),
1262 mincolourLabel, minColour);
1263 JvSwingUtils.addtoLayout(annotationShding,
1264 MessageManager.getString(
1265 "label.default_maximum_colour_annotation_shading"),
1266 maxcolourLabel, maxColour);
1267 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1272 * Initialises the Overview tabbed panel.
1276 private JPanel initOverviewTab()
1278 JPanel overviewPanel = new JPanel();
1279 overviewPanel.setBorder(new TitledBorder(
1280 MessageManager.getString("label.overview_settings")));
1282 gapColour.setFont(LABEL_FONT);
1283 // fixing the border colours stops apparent colour bleed from the panel
1284 gapColour.setBorder(
1285 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1286 gapColour.setPreferredSize(new Dimension(40, 20));
1287 gapColour.addMouseListener(new MouseAdapter()
1290 public void mousePressed(MouseEvent e)
1292 gapColour_actionPerformed(gapColour);
1296 hiddenColour.setFont(LABEL_FONT);
1297 // fixing the border colours stops apparent colour bleed from the panel
1298 hiddenColour.setBorder(
1299 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1300 hiddenColour.setPreferredSize(new Dimension(40, 20));
1301 hiddenColour.addMouseListener(new MouseAdapter()
1304 public void mousePressed(MouseEvent e)
1306 hiddenColour_actionPerformed(hiddenColour);
1310 useLegacyGap = new JCheckBox(
1311 MessageManager.getString("label.ov_legacy_gap"));
1312 useLegacyGap.setFont(LABEL_FONT);
1313 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1314 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1315 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1316 gapLabel.setFont(LABEL_FONT);
1317 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1318 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1319 showHiddenAtStart = new JCheckBox(
1320 MessageManager.getString("label.ov_show_hide_default"));
1321 showHiddenAtStart.setFont(LABEL_FONT);
1322 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1323 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1324 JLabel hiddenLabel = new JLabel(
1325 MessageManager.getString("label.hidden_colour"));
1326 hiddenLabel.setFont(LABEL_FONT);
1327 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1328 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1330 useLegacyGap.addActionListener(new ActionListener()
1333 public void actionPerformed(ActionEvent e)
1335 useLegacyGaps_actionPerformed(e);
1339 overviewPanel.setLayout(new GridBagLayout());
1340 GridBagConstraints c1 = new GridBagConstraints();
1342 c1.fill = GridBagConstraints.HORIZONTAL;
1347 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1348 overviewPanel.add(useLegacyGap, c1);
1350 GridBagConstraints c2 = new GridBagConstraints();
1351 c2.fill = GridBagConstraints.HORIZONTAL;
1354 c2.insets = new Insets(0, 15, 0, 10);
1355 overviewPanel.add(gapLabel, c2);
1357 GridBagConstraints c3 = new GridBagConstraints();
1358 c3.fill = GridBagConstraints.HORIZONTAL;
1361 c3.insets = new Insets(0, 0, 0, 15);
1362 overviewPanel.add(gapColour, c3);
1364 GridBagConstraints c4 = new GridBagConstraints();
1365 c4.fill = GridBagConstraints.HORIZONTAL;
1369 overviewPanel.add(showHiddenAtStart, c4);
1371 GridBagConstraints c5 = new GridBagConstraints();
1372 c5.fill = GridBagConstraints.HORIZONTAL;
1375 c5.insets = new Insets(0, 15, 0, 10);
1376 overviewPanel.add(hiddenLabel, c5);
1378 GridBagConstraints c6 = new GridBagConstraints();
1379 c6.fill = GridBagConstraints.HORIZONTAL;
1382 c6.insets = new Insets(0, 0, 0, 15);
1383 overviewPanel.add(hiddenColour, c6);
1385 JButton resetButton = new JButton(
1386 MessageManager.getString("label.reset_to_defaults"));
1388 resetButton.addActionListener(new ActionListener()
1391 public void actionPerformed(ActionEvent e)
1393 resetOvDefaults_actionPerformed(e);
1397 GridBagConstraints c7 = new GridBagConstraints();
1398 c7.fill = GridBagConstraints.NONE;
1401 c7.insets = new Insets(10, 0, 0, 0);
1402 c7.anchor = GridBagConstraints.WEST;
1403 overviewPanel.add(resetButton, c7);
1405 // Add padding so the panel doesn't look ridiculous
1406 JPanel spacePanel = new JPanel();
1407 overviewPanel.add(spacePanel,
1408 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1409 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1410 new Insets(0, 0, 0, 5), 0, 0));
1412 return overviewPanel;
1416 * Initialises the Structure tabbed panel.
1420 private JPanel initStructureTab()
1422 structureTab = new JPanel();
1424 structureTab.setBorder(new TitledBorder(
1425 MessageManager.getString("label.structure_options")));
1426 structureTab.setLayout(null);
1427 final int width = 420;
1428 final int height = 22;
1429 final int lineSpacing = 25;
1432 structFromPdb.setFont(LABEL_FONT);
1434 .setText(MessageManager.getString("label.struct_from_pdb"));
1435 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1436 structFromPdb.addActionListener(new ActionListener()
1439 public void actionPerformed(ActionEvent e)
1441 boolean selected = structFromPdb.isSelected();
1442 // enable other options only when the first is checked
1443 useRnaView.setEnabled(selected);
1444 addSecondaryStructure.setEnabled(selected);
1445 addTempFactor.setEnabled(selected);
1448 structureTab.add(structFromPdb);
1450 // indent checkboxes that are conditional on the first one
1451 ypos += lineSpacing;
1452 useRnaView.setFont(LABEL_FONT);
1453 useRnaView.setText(MessageManager.getString("label.use_rnaview"));
1454 useRnaView.setBounds(new Rectangle(25, ypos, width, height));
1455 structureTab.add(useRnaView);
1457 ypos += lineSpacing;
1458 addSecondaryStructure.setFont(LABEL_FONT);
1459 addSecondaryStructure
1460 .setText(MessageManager.getString("label.autoadd_secstr"));
1461 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1462 structureTab.add(addSecondaryStructure);
1464 ypos += lineSpacing;
1465 addTempFactor.setFont(LABEL_FONT);
1466 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1467 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1468 structureTab.add(addTempFactor);
1470 ypos += lineSpacing;
1471 JLabel viewerLabel = new JLabel();
1472 viewerLabel.setFont(LABEL_FONT);
1473 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1474 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1475 viewerLabel.setBounds(new Rectangle(10, ypos, 220, height));
1476 structureTab.add(viewerLabel);
1479 * add all external viewers as options here - check
1480 * when selected whether the program is installed
1482 structViewer.setFont(LABEL_FONT);
1483 structViewer.setBounds(new Rectangle(190, ypos, 120, height));
1484 structViewer.addItem(ViewerType.JMOL.name());
1485 structViewer.addItem(ViewerType.CHIMERA.name());
1486 structViewer.addItem(ViewerType.CHIMERAX.name());
1487 structViewer.addItem(ViewerType.PYMOL.name());
1488 structViewer.addActionListener(new ActionListener()
1491 public void actionPerformed(ActionEvent e)
1493 structureViewer_actionPerformed(
1494 (String) structViewer.getSelectedItem());
1497 structureTab.add(structViewer);
1499 ypos += lineSpacing;
1500 structureViewerPathLabel = new JLabel();
1501 structureViewerPathLabel.setFont(LABEL_FONT);// new Font("SansSerif", 0, 11));
1502 structureViewerPathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1503 structureViewerPathLabel.setText(MessageManager
1504 .formatMessage("label.viewer_path", "Chimera(X)"));
1505 structureViewerPathLabel.setBounds(new Rectangle(10, ypos, 170, height));
1506 structureViewerPathLabel.setEnabled(false);
1507 structureTab.add(structureViewerPathLabel);
1509 structureViewerPath.setFont(LABEL_FONT);
1510 structureViewerPath.setText("");
1511 structureViewerPath.setEnabled(false);
1512 final String tooltip = JvSwingUtils.wrapTooltip(true,
1513 MessageManager.getString("label.viewer_path_tip"));
1514 structureViewerPath.setToolTipText(tooltip);
1515 structureViewerPath.setBounds(new Rectangle(190, ypos, 290, height));
1516 structureViewerPath.addMouseListener(new MouseAdapter()
1519 public void mouseClicked(MouseEvent e)
1521 if (structureViewerPath.isEnabled() && e.getClickCount() == 2)
1523 String chosen = openFileChooser();
1526 structureViewerPath.setText(chosen);
1531 structureTab.add(structureViewerPath);
1533 ypos += lineSpacing;
1534 nwMapping.setFont(LABEL_FONT);
1535 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1536 siftsMapping.setFont(LABEL_FONT);
1537 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1538 mappingMethod.add(nwMapping);
1539 mappingMethod.add(siftsMapping);
1540 JPanel mappingPanel = new JPanel();
1541 mappingPanel.setFont(LABEL_FONT);
1542 TitledBorder mmTitledBorder = new TitledBorder(
1543 MessageManager.getString("label.mapping_method"));
1544 mmTitledBorder.setTitleFont(LABEL_FONT);
1545 mappingPanel.setBorder(mmTitledBorder);
1546 mappingPanel.setBounds(new Rectangle(10, ypos, 472, 45));
1547 // GridLayout mappingLayout = new GridLayout();
1548 mappingPanel.setLayout(new GridLayout());
1549 mappingPanel.add(nwMapping);
1550 mappingPanel.add(siftsMapping);
1551 structureTab.add(mappingPanel);
1553 ypos += lineSpacing;
1554 ypos += lineSpacing;
1555 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1556 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1557 docFieldPref.setBounds(new Rectangle(10, ypos, 470, 120));
1558 structureTab.add(docFieldPref);
1561 * hide Chimera options in JalviewJS
1563 if (Platform.isJS())
1565 structureViewerPathLabel.setVisible(false);
1566 structureViewerPath.setVisible(false);
1567 viewerLabel.setVisible(false);
1568 structViewer.setVisible(false);
1571 return structureTab;
1575 * Action on choosing a structure viewer from combobox options.
1577 * @param selectedItem
1579 protected void structureViewer_actionPerformed(String selectedItem)
1584 * Show a dialog for the user to choose a file. Returns the chosen path, or
1589 protected String openFileChooser()
1591 String choice = null;
1592 JFileChooser chooser = new JFileChooser();
1594 // chooser.setFileView(new JalviewFileView());
1595 chooser.setDialogTitle(
1596 MessageManager.getString("label.open_local_file"));
1597 chooser.setToolTipText(MessageManager.getString("action.open"));
1599 int value = chooser.showOpenDialog(this);
1601 if (value == JFileChooser.APPROVE_OPTION)
1603 choice = chooser.getSelectedFile().getPath();
1609 * Validate the structure tab preferences; if invalid, set focus on this tab.
1613 protected boolean validateStructure(FocusEvent e)
1615 if (!validateStructure())
1617 e.getComponent().requestFocusInWindow();
1623 protected boolean validateStructure()
1629 * Initialises the Visual tabbed panel.
1633 private JPanel initVisualTab()
1635 JPanel visualTab = new JPanel();
1636 visualTab.setBorder(new TitledBorder(
1637 MessageManager.getString("action.open_new_alignment")));
1638 visualTab.setLayout(null);
1639 fullScreen.setFont(LABEL_FONT);
1640 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1641 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1642 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1643 quality.setEnabled(false);
1644 quality.setFont(LABEL_FONT);
1645 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1646 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1647 quality.setSelected(true);
1648 quality.setText(MessageManager.getString("label.quality"));
1649 conservation.setEnabled(false);
1650 conservation.setFont(LABEL_FONT);
1651 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1652 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1653 conservation.setSelected(true);
1654 conservation.setText(MessageManager.getString("label.conservation"));
1655 identity.setEnabled(false);
1656 identity.setFont(LABEL_FONT);
1657 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1658 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1659 identity.setSelected(true);
1660 identity.setText(MessageManager.getString("label.consensus"));
1661 showOccupancy.setFont(LABEL_FONT);
1662 showOccupancy.setEnabled(false);
1663 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1664 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1665 showOccupancy.setSelected(true);
1666 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1668 JLabel showGroupbits = new JLabel();
1669 showGroupbits.setFont(LABEL_FONT);
1670 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1671 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1673 .setText(MessageManager.getString("action.show_group") + ":");
1674 JLabel showConsensbits = new JLabel();
1675 showConsensbits.setFont(LABEL_FONT);
1676 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1677 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1679 .setText(MessageManager.getString("label.consensus") + ":");
1680 showConsensHistogram.setEnabled(false);
1681 showConsensHistogram.setFont(LABEL_FONT);
1682 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1683 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1684 showConsensHistogram.setSelected(true);
1685 showConsensHistogram
1686 .setText(MessageManager.getString("label.histogram"));
1687 showConsensLogo.setEnabled(false);
1688 showConsensLogo.setFont(LABEL_FONT);
1689 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1690 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1691 showConsensLogo.setSelected(true);
1692 showConsensLogo.setText(MessageManager.getString("label.logo"));
1693 showGroupConsensus.setEnabled(false);
1694 showGroupConsensus.setFont(LABEL_FONT);
1695 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1696 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1697 showGroupConsensus.setSelected(true);
1698 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1699 showGroupConservation.setEnabled(false);
1700 showGroupConservation.setFont(LABEL_FONT);
1701 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1702 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1703 showGroupConservation.setSelected(true);
1704 showGroupConservation
1705 .setText(MessageManager.getString("label.conservation"));
1706 showNpTooltip.setEnabled(true);
1707 showNpTooltip.setFont(LABEL_FONT);
1708 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1709 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1710 showNpTooltip.setSelected(true);
1711 showNpTooltip.setText(
1712 MessageManager.getString("label.non_positional_features"));
1713 showDbRefTooltip.setEnabled(true);
1714 showDbRefTooltip.setFont(LABEL_FONT);
1715 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1716 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1717 showDbRefTooltip.setSelected(true);
1719 .setText(MessageManager.getString("label.database_references"));
1720 annotations.setFont(LABEL_FONT);
1721 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1722 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1723 annotations.setSelected(true);
1724 annotations.setText(MessageManager.getString("label.show_annotations"));
1725 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1726 annotations.addActionListener(new ActionListener()
1729 public void actionPerformed(ActionEvent e)
1731 annotations_actionPerformed(e);
1734 identity.addActionListener(new ActionListener()
1737 public void actionPerformed(ActionEvent e)
1739 annotations_actionPerformed(e);
1742 showGroupConsensus.addActionListener(new ActionListener()
1745 public void actionPerformed(ActionEvent e)
1747 annotations_actionPerformed(e);
1750 showUnconserved.setFont(LABEL_FONT);
1751 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1752 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1753 showUnconserved.setSelected(true);
1755 .setText(MessageManager.getString("action.show_unconserved"));
1756 showUnconserved.addActionListener(new ActionListener()
1759 public void actionPerformed(ActionEvent e)
1761 showunconserved_actionPerformed(e);
1765 // TODO these are not yet added to / action from Preferences
1766 // JCheckBox shareSelections = new JCheckBox();
1767 // shareSelections.setFont(verdana11);
1768 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1769 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1770 // shareSelections.setSelected(true);
1771 // shareSelections.setText(MessageManager
1772 // .getString("label.share_selection_across_views"));
1773 // JCheckBox followHighlight = new JCheckBox();
1774 // followHighlight.setFont(verdana11);
1775 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1776 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1777 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1778 // followHighlight.setSelected(true);
1779 // followHighlight.setText(MessageManager
1780 // .getString("label.scroll_highlighted_regions"));
1782 seqLimit.setFont(LABEL_FONT);
1783 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1784 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1785 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1786 smoothFont.setFont(LABEL_FONT);
1787 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1788 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1789 smoothFont.setText(MessageManager.getString("label.smooth_font"));
1790 scaleProteinToCdna.setFont(LABEL_FONT);
1791 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1792 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1793 scaleProteinToCdna.setText(
1794 MessageManager.getString("label.scale_protein_to_cdna"));
1795 scaleProteinToCdna.setToolTipText(
1796 MessageManager.getString("label.scale_protein_to_cdna_tip"));
1797 JLabel gapLabel = new JLabel();
1798 gapLabel.setFont(LABEL_FONT);
1799 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1800 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1801 JLabel fontLabel = new JLabel();
1802 fontLabel.setFont(LABEL_FONT);
1803 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1804 fontLabel.setText(MessageManager.getString("label.font"));
1805 fontSizeCB.setFont(LABEL_FONT);
1806 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
1807 fontStyleCB.setFont(LABEL_FONT);
1808 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
1809 fontNameCB.setFont(LABEL_FONT);
1810 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
1811 gapSymbolCB.setFont(LABEL_FONT);
1812 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
1813 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1814 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1815 gapSymbolCB.setRenderer(dlcr);
1817 startupCheckbox.setText(MessageManager.getString("action.open_file"));
1818 startupCheckbox.setFont(LABEL_FONT);
1819 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1820 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1821 startupCheckbox.setSelected(true);
1822 startupFileTextfield.setFont(LABEL_FONT);
1823 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
1824 final String tooltip = JvSwingUtils.wrapTooltip(true,
1825 MessageManager.getString("label.double_click_to_browse"));
1826 startupFileTextfield.setToolTipText(tooltip);
1827 startupFileTextfield.addMouseListener(new MouseAdapter()
1830 public void mouseClicked(MouseEvent e)
1832 if (e.getClickCount() > 1)
1834 startupFileTextfield_mouseClicked();
1839 sortby.setFont(LABEL_FONT);
1840 sortby.setBounds(new Rectangle(172, 260, 155, 21));
1841 JLabel sortLabel = new JLabel();
1842 sortLabel.setFont(LABEL_FONT);
1843 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1844 sortLabel.setText(MessageManager.getString("label.sort_by"));
1845 sortAnnBy.setFont(LABEL_FONT);
1846 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
1847 JLabel sortAnnLabel = new JLabel();
1848 sortAnnLabel.setFont(LABEL_FONT);
1849 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1850 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
1851 sortAutocalc.setFont(LABEL_FONT);
1852 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
1854 JPanel annsettingsPanel = new JPanel();
1855 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
1856 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1857 annsettingsPanel.setBorder(new EtchedBorder());
1858 visualTab.add(annsettingsPanel);
1859 Border jb = new EmptyBorder(1, 1, 4, 5);
1860 annotations.setBorder(jb);
1861 showOccupancy.setBorder(jb);
1862 quality.setBorder(jb);
1863 conservation.setBorder(jb);
1864 identity.setBorder(jb);
1865 showConsensbits.setBorder(jb);
1866 showGroupbits.setBorder(jb);
1867 showGroupConsensus.setBorder(jb);
1868 showGroupConservation.setBorder(jb);
1869 showConsensHistogram.setBorder(jb);
1870 showConsensLogo.setBorder(jb);
1872 JPanel autoAnnotSettings = new JPanel();
1873 annsettingsPanel.add(autoAnnotSettings);
1874 autoAnnotSettings.setLayout(new GridLayout(0, 2));
1875 autoAnnotSettings.add(annotations);
1876 autoAnnotSettings.add(quality);
1877 // second row of autoannotation box
1878 autoAnnotSettings = new JPanel();
1879 annsettingsPanel.add(autoAnnotSettings);
1881 autoAnnotSettings.setLayout(new GridLayout(0, 3));
1882 autoAnnotSettings.add(conservation);
1883 autoAnnotSettings.add(identity);
1884 autoAnnotSettings.add(showOccupancy);
1885 autoAnnotSettings.add(showGroupbits);
1886 autoAnnotSettings.add(showGroupConservation);
1887 autoAnnotSettings.add(showGroupConsensus);
1888 autoAnnotSettings.add(showConsensbits);
1889 autoAnnotSettings.add(showConsensHistogram);
1890 autoAnnotSettings.add(showConsensLogo);
1892 JPanel tooltipSettings = new JPanel();
1893 tooltipSettings.setBorder(new TitledBorder(
1894 MessageManager.getString("label.sequence_id_tooltip")));
1895 tooltipSettings.setBounds(173, 140, 220, 62);
1896 tooltipSettings.setLayout(new GridLayout(2, 1));
1897 tooltipSettings.add(showDbRefTooltip);
1898 tooltipSettings.add(showNpTooltip);
1899 visualTab.add(tooltipSettings);
1901 wrap.setFont(LABEL_FONT);
1902 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
1903 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
1904 wrap.setText(MessageManager.getString("label.wrap_alignment"));
1905 rightAlign.setFont(LABEL_FONT);
1906 rightAlign.setForeground(Color.black);
1907 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
1908 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
1909 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
1910 idItalics.setFont(LABEL_FONT_ITALIC);
1911 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
1912 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
1914 MessageManager.getString("label.sequence_name_italics"));
1915 openoverv.setFont(LABEL_FONT);
1916 openoverv.setActionCommand(
1917 MessageManager.getString("label.open_overview"));
1918 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
1919 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
1920 openoverv.setText(MessageManager.getString("label.open_overview"));
1921 JPanel jPanel2 = new JPanel();
1922 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
1923 jPanel2.setLayout(new GridLayout(14, 1));
1924 jPanel2.add(fullScreen);
1925 jPanel2.add(openoverv);
1926 jPanel2.add(seqLimit);
1927 jPanel2.add(rightAlign);
1928 jPanel2.add(fontLabel);
1929 jPanel2.add(showUnconserved);
1930 jPanel2.add(idItalics);
1931 jPanel2.add(smoothFont);
1932 jPanel2.add(scaleProteinToCdna);
1933 jPanel2.add(gapLabel);
1935 jPanel2.add(sortLabel);
1936 jPanel2.add(sortAnnLabel);
1937 jPanel2.add(startupCheckbox);
1938 visualTab.add(jPanel2);
1939 visualTab.add(startupFileTextfield);
1940 visualTab.add(sortby);
1941 visualTab.add(sortAnnBy);
1942 visualTab.add(sortAutocalc);
1943 visualTab.add(gapSymbolCB);
1944 visualTab.add(fontNameCB);
1945 visualTab.add(fontSizeCB);
1946 visualTab.add(fontStyleCB);
1948 if (Platform.isJS())
1950 startupCheckbox.setVisible(false);
1951 startupFileTextfield.setVisible(false);
1958 * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
1961 protected void loadLastSavedBackupsOptions()
1963 BackupFilesPresetEntry savedPreset = BackupFilesPresetEntry
1964 .getSavedBackupEntry();
1966 .setSelected(Cache.getDefault(BackupFiles.ENABLED, !Platform.isJS()));
1968 BackupFilesPresetEntry backupfilesCustomEntry = BackupFilesPresetEntry
1969 .createBackupFilesPresetEntry(Cache
1970 .getDefault(BackupFilesPresetEntry.CUSTOMCONFIG, null));
1971 if (backupfilesCustomEntry == null)
1973 backupfilesCustomEntry = BackupFilesPresetEntry.backupfilesPresetEntriesValues
1974 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT);
1976 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
1977 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM,
1978 backupfilesCustomEntry);
1980 setComboIntStringKey(backupfilesPresetsCombo,
1981 Cache.getDefault(BackupFiles.NS + "_PRESET",
1982 BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT));
1984 backupsSetOptions(savedPreset);
1986 backupsOptionsSetEnabled();
1987 updateBackupFilesExampleLabel();
1990 private boolean warnAboutSuffixReverseChange()
1992 BackupFilesPresetEntry bfpe = BackupFilesPresetEntry
1993 .getSavedBackupEntry();
1994 boolean savedSuffixReverse = bfpe.reverse;
1995 int savedSuffixDigits = bfpe.digits;
1996 String savedSuffixTemplate = bfpe.suffix;
1998 boolean nowSuffixReverse = suffixReverse.isSelected();
1999 int nowSuffixDigits = getSpinnerInt(suffixDigitsSpinner, 3);
2000 String nowSuffixTemplate = suffixTemplate.getText();
2001 return nowSuffixReverse != savedSuffixReverse
2002 && nowSuffixDigits == savedSuffixDigits
2003 && nowSuffixTemplate != null
2004 && nowSuffixTemplate.equals(savedSuffixTemplate);
2008 * Initialises the Backups tabbed panel.
2012 private JPanel initBackupsTab()
2014 JPanel backupsTab = new JPanel();
2015 backupsTab.setBorder(new TitledBorder(
2016 MessageManager.getString("label.backup_files")));
2017 backupsTab.setLayout(new GridBagLayout());
2019 GridBagConstraints gbc = new GridBagConstraints();
2022 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2023 gbc.fill = GridBagConstraints.NONE;
2025 initBackupsTabPresetsPanel();
2026 initBackupsTabSuffixPanel();
2027 initBackupsTabKeepFilesPanel();
2028 initBackupsTabFilenameExamplesPanel();
2030 enableBackupFiles.setFont(LABEL_FONT_BOLD);
2032 .setText(MessageManager.getString("label.enable_backupfiles"));
2033 enableBackupFiles.addActionListener(new ActionListener()
2036 public void actionPerformed(ActionEvent e)
2038 // enable other options only when the first is checked
2039 backupsOptionsSetEnabled();
2044 // enable checkbox 1 col
2048 gbc.gridy = 0; // row 0
2049 backupsTab.add(enableBackupFiles, gbc);
2051 // summary of scheme box (over two rows)
2055 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
2056 gbc.fill = GridBagConstraints.BOTH;
2057 backupsTab.add(exampleFilesPanel, gbc);
2059 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2060 gbc.fill = GridBagConstraints.NONE;
2062 // fill empty space on right
2065 backupsTab.add(new JPanel(), gbc);
2070 gbc.gridy++; // row 1
2071 backupsTab.add(presetsPanel, gbc);
2073 // now using whole row
2078 gbc.gridy++; // row 2
2079 backupsTab.add(keepfilesPanel, gbc);
2081 // filename strategy box
2082 gbc.gridy++; // row 3
2083 backupsTab.add(suffixPanel, gbc);
2086 gbc.gridy++; // row 4
2088 backupsTab.add(new JPanel(), gbc);
2090 backupsOptionsSetEnabled();
2094 private JPanel initBackupsTabPresetsPanel()
2097 String title = MessageManager.getString("label.schemes");
2099 presetsPanel.setLayout(new GridBagLayout());
2101 GridBagConstraints gbc = new GridBagConstraints();
2104 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
2105 gbc.fill = GridBagConstraints.NONE;
2113 presetsComboLabel = new JLabel(title + ":");
2114 presetsPanel.add(presetsComboLabel, gbc);
2116 List<Object> entries = Arrays
2117 .asList((Object[]) BackupFilesPresetEntry.backupfilesPresetEntries);
2118 List<String> tooltips = Arrays.asList(
2119 BackupFilesPresetEntry.backupfilesPresetEntryDescriptions);
2120 backupfilesPresetsCombo = JvSwingUtils.buildComboWithTooltips(entries,
2123 for (int i = 0; i < BackupFilesPresetEntry.backupfilesPresetEntries.length; i++)
2125 backupfilesPresetsCombo
2126 .addItem(BackupFilesPresetEntry.backupfilesPresetEntries[i]);
2130 backupfilesPresetsCombo.addActionListener(new ActionListener()
2133 public void actionPerformed(ActionEvent e)
2135 int key = getComboIntStringKey(backupfilesPresetsCombo);
2136 if (!customiseCheckbox.isSelected())
2138 backupfilesPresetsComboLastSelected = key;
2140 if (key == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
2142 if (customiseCheckbox.isSelected())
2144 // got here by clicking on customiseCheckbox so don't change the values
2145 backupfilesCustomOptionsSetEnabled();
2149 backupsTabUpdatePresets();
2150 backupfilesCustomOptionsSetEnabled();
2155 customiseCheckbox.setSelected(false);
2156 backupsTabUpdatePresets();
2157 backupfilesCustomOptionsSetEnabled();
2162 // dropdown list of preset schemes
2164 presetsPanel.add(backupfilesPresetsCombo, gbc);
2166 revertButton.setText(MessageManager.getString("label.cancel_changes"));
2167 revertButton.setToolTipText(
2168 MessageManager.getString("label.cancel_changes_description"));
2169 revertButton.addActionListener(new ActionListener()
2172 public void actionPerformed(ActionEvent e)
2175 BackupFilesPresetEntry.backupfilesPresetEntriesValues.get(
2176 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM));
2177 backupfilesCustomOptionsSetEnabled();
2181 revertButton.setFont(LABEL_FONT);
2183 customiseCheckbox.setFont(LABEL_FONT);
2184 customiseCheckbox.setText(MessageManager.getString("label.customise"));
2185 customiseCheckbox.addActionListener(new ActionListener()
2188 public void actionPerformed(ActionEvent e)
2190 int currently = getComboIntStringKey(backupfilesPresetsCombo);
2191 if (customiseCheckbox.isSelected())
2193 backupfilesPresetsComboLastSelected = currently;
2194 setComboIntStringKey(backupfilesPresetsCombo,
2195 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2199 setComboIntStringKey(backupfilesPresetsCombo,
2200 backupfilesPresetsComboLastSelected);
2203 backupfilesCustomOptionsSetEnabled();
2206 customiseCheckbox.setToolTipText(
2207 MessageManager.getString("label.customise_description"));
2209 // customise checkbox
2212 presetsPanel.add(customiseCheckbox, gbc);
2214 // "Cancel changes" button (aligned with combo box above)
2216 presetsPanel.add(revertButton, gbc);
2218 return presetsPanel;
2221 private JPanel initBackupsTabFilenameExamplesPanel()
2223 String title = MessageManager
2224 .getString("label.scheme_examples");
2225 TitledBorder tb = new TitledBorder(title);
2226 exampleFilesPanel.setBorder(tb);
2227 exampleFilesPanel.setLayout(new GridBagLayout());
2230 backupfilesExampleLabel.setEditable(false);
2231 backupfilesExampleLabel
2232 .setBackground(exampleFilesPanel.getBackground());
2234 updateBackupFilesExampleLabel();
2236 GridBagConstraints gbc = new GridBagConstraints();
2239 gbc.fill = GridBagConstraints.NONE;
2240 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2242 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
2243 return exampleFilesPanel;
2246 private void backupsTabUpdatePresets()
2248 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
2251 String value = entry.v;
2253 if (BackupFilesPresetEntry.backupfilesPresetEntriesValues
2257 BackupFilesPresetEntry.backupfilesPresetEntriesValues
2263 "Preset '" + value + "' [key:" + key + "] not implemented");
2266 // Custom options will now be enabled when the customiseCheckbox is checked
2267 // (performed above)
2268 // backupfilesCustomOptionsSetEnabled();
2269 updateBackupFilesExampleLabel();
2272 protected int getComboIntStringKey(
2273 JComboBox<Object> backupfilesPresetsCombo2)
2275 IntKeyStringValueEntry e;
2278 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2
2280 } catch (Exception ex)
2283 "Problem casting Combo entry to IntKeyStringValueEntry.");
2286 return e != null ? e.k : 0;
2289 protected void setComboIntStringKey(
2290 JComboBox<Object> backupfilesPresetsCombo2,
2293 for (int i = 0; i < backupfilesPresetsCombo2.getItemCount(); i++)
2295 IntKeyStringValueEntry e;
2298 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2.getItemAt(i);
2299 } catch (Exception ex)
2302 "Problem casting Combo entry to IntKeyStringValueEntry. Skipping item. ");
2307 backupfilesPresetsCombo2.setSelectedIndex(i);
2311 // backupsTabUpdatePresets();
2314 private JPanel initBackupsTabSuffixPanel()
2316 suffixPanel.setBorder(new TitledBorder(
2317 MessageManager.getString("label.backup_filename_strategy")));
2318 suffixPanel.setLayout(new GridBagLayout());
2321 .setText(MessageManager.getString("label.append_to_filename"));
2322 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
2323 suffixTemplateLabel.setFont(LABEL_FONT);
2325 final String tooltip = JvSwingUtils.wrapTooltip(true,
2326 MessageManager.getString("label.append_to_filename_tooltip"));
2327 suffixTemplate.setToolTipText(tooltip);
2328 suffixTemplate.addActionListener(new ActionListener()
2331 public void actionPerformed(ActionEvent e)
2333 updateBackupFilesExampleLabel();
2334 backupfilesCustomOptionsSetEnabled();
2335 backupfilesRevertButtonSetEnabled(true);
2339 suffixTemplate.addKeyListener(new KeyListener()
2342 public void keyReleased(KeyEvent e)
2344 updateBackupFilesExampleLabel();
2345 backupfilesCustomOptionsSetEnabled();
2346 backupfilesRevertButtonSetEnabled(true);
2350 public void keyPressed(KeyEvent e)
2354 // disable use of ':' or '/' or '\'
2356 public void keyTyped(KeyEvent e)
2358 char c = e.getKeyChar();
2359 if (c == ':' || c == '/' || c == '\\')
2361 // don't process ':' or '/' or '\'
2370 .setText(MessageManager.getString("label.index_digits"));
2371 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
2372 suffixDigitsLabel.setFont(LABEL_FONT);
2373 ChangeListener c = new ChangeListener()
2376 public void stateChanged(ChangeEvent e)
2378 backupfilesRevertButtonSetEnabled(true);
2379 updateBackupFilesExampleLabel();
2383 setIntegerSpinner(suffixDigitsSpinner, BackupFilesPresetEntry.DIGITSMIN,
2384 BackupFilesPresetEntry.DIGITSMAX, 3, c);
2386 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
2387 MessageManager.getString("label.increment_index"));
2388 suffixReverse.addActionListener(new ActionListener()
2391 public void actionPerformed(ActionEvent e)
2393 boolean okay = true;
2394 if (warnAboutSuffixReverseChange())
2397 okay = confirmSuffixReverseChange();
2401 backupfilesRevertButtonSetEnabled(true);
2402 updateBackupFilesExampleLabel();
2406 boolean savedSuffixReverse = BackupFilesPresetEntry
2407 .getSavedBackupEntry().reverse;
2408 suffixReverse.setSelected(savedSuffixReverse);
2413 GridBagConstraints sgbc = new GridBagConstraints();
2415 // first row (template text box)
2416 sgbc.anchor = GridBagConstraints.WEST;
2420 sgbc.gridheight = 1;
2423 sgbc.fill = GridBagConstraints.NONE;
2424 suffixPanel.add(suffixTemplateLabel, sgbc);
2427 sgbc.fill = GridBagConstraints.HORIZONTAL;
2428 suffixPanel.add(suffixTemplate, sgbc);
2430 // second row (number of digits spinner)
2434 sgbc.fill = GridBagConstraints.NONE;
2435 suffixPanel.add(suffixDigitsLabel, sgbc);
2438 sgbc.fill = GridBagConstraints.HORIZONTAL;
2439 suffixPanel.add(suffixDigitsSpinner, sgbc);
2441 // third row (forward order radio selection)
2444 sgbc.gridwidth = GridBagConstraints.REMAINDER;
2445 sgbc.fill = GridBagConstraints.HORIZONTAL;
2446 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
2448 // fourth row (reverse order radio selection)
2450 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
2454 private boolean confirmSuffixReverseChange()
2456 boolean ret = false;
2457 String warningMessage = MessageManager
2458 .getString("label.warning_confirm_change_reverse");
2459 int confirm = JvOptionPane.showConfirmDialog(Desktop.desktop,
2461 MessageManager.getString("label.change_increment_decrement"),
2462 JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE);
2464 ret = (confirm == JvOptionPane.YES_OPTION);
2468 private JPanel initBackupsTabKeepFilesPanel()
2470 keepfilesPanel.setBorder(
2471 new TitledBorder(MessageManager.getString("label.keep_files")));
2472 keepfilesPanel.setLayout(new GridBagLayout());
2474 backupfilesKeepAll.setLabels(
2475 MessageManager.getString("label.keep_all_backup_files"),
2476 MessageManager.getString(
2477 "label.keep_only_this_number_of_backup_files"));
2478 backupfilesKeepAll.addTrueActionListener(new ActionListener()
2481 public void actionPerformed(ActionEvent e)
2483 backupfilesRevertButtonSetEnabled(true);
2484 updateBackupFilesExampleLabel();
2487 backupfilesKeepAll.addActionListener(new ActionListener()
2490 public void actionPerformed(ActionEvent e)
2492 backupfilesRevertButtonSetEnabled(true);
2493 keepRollMaxOptionsEnabled();
2494 updateBackupFilesExampleLabel();
2498 ChangeListener c = new ChangeListener()
2501 public void stateChanged(ChangeEvent e)
2503 backupfilesRevertButtonSetEnabled(true);
2504 updateBackupFilesExampleLabel();
2508 setIntegerSpinner(backupfilesRollMaxSpinner,
2509 BackupFilesPresetEntry.ROLLMAXMIN,
2510 BackupFilesPresetEntry.ROLLMAXMAX, 4, true, c);
2512 backupfilesConfirmDelete.setLabels(
2513 MessageManager.getString("label.always_ask"),
2514 MessageManager.getString("label.auto_delete"));
2515 backupfilesConfirmDelete.addActionListener(new ActionListener()
2518 public void actionPerformed(ActionEvent e)
2520 backupfilesRevertButtonSetEnabled(true);
2523 // update the enabled section
2524 keepRollMaxOptionsEnabled();
2526 GridBagConstraints kgbc = new GridBagConstraints();
2528 // first row (template text box)
2529 kgbc.anchor = GridBagConstraints.WEST;
2532 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2533 kgbc.gridheight = 1;
2536 kgbc.fill = GridBagConstraints.HORIZONTAL;
2537 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
2543 kgbc.gridwidth = GridBagConstraints.RELATIVE;
2544 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
2547 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2548 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
2550 // third row (indented)
2552 kgbc.insets = new Insets(0, 20, 0, 0);
2555 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2556 kgbc.fill = GridBagConstraints.HORIZONTAL;
2559 JPanel jp = new JPanel();
2560 jp.setLayout(new FlowLayout());
2562 .setText(MessageManager
2563 .getString("label.autodelete_old_backup_files"));
2564 oldBackupFilesLabel.setFont(LABEL_FONT);
2565 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
2566 jp.add(oldBackupFilesLabel);
2567 jp.add(backupfilesConfirmDelete.getTrueButton());
2568 jp.add(backupfilesConfirmDelete.getFalseButton());
2569 keepfilesPanel.add(jp, kgbc);
2571 return keepfilesPanel;
2574 protected void updateBackupFilesExampleLabel()
2576 int exampleindex = 12;
2577 String base = MessageManager.getString("label.filename") + ".fa";
2578 if (base == null || base.length() == 0)
2580 base = "file_name.fa";
2583 boolean reverse = suffixReverse.isSelected();
2584 boolean keepAll = backupfilesKeepAll.isSelected();
2586 String suffix = suffixTemplate.getText();
2589 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
2590 if (suffix == null || suffix.length() == 0)
2592 backupfilesExampleLabel
2593 .setText(MessageManager.getString("label.no_backup_files"));
2594 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
2598 rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 4);
2599 rollMax = rollMax < 1 ? 1 : rollMax;
2601 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
2606 digits = getSpinnerInt(suffixDigitsSpinner, 3);
2607 digits = digits < 1 ? 1 : digits;
2609 int lowersurround = 2;
2610 int uppersurround = 0;
2611 StringBuilder exampleSB = new StringBuilder();
2612 boolean firstLine = true;
2618 int max = keepAll ? exampleindex : rollMax;
2619 for (int index = min; index <= max; index++)
2621 if (index == min + lowersurround && index < max - uppersurround - 1)
2623 exampleSB.append("\n...");
2626 else if (index > min + lowersurround && index < max - uppersurround)
2638 exampleSB.append("\n");
2641 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2642 base, suffix, digits));
2645 // no extra text needed
2647 else if (index == min)
2649 String newest = MessageManager.getString("label.braced_newest");
2650 if (newest != null && newest.length() > 0)
2652 exampleSB.append(" " + newest);
2655 else if (index == max)
2657 String oldest = MessageManager.getString("label.braced_oldest");
2658 if (oldest != null && oldest.length() > 0)
2660 exampleSB.append(" " + oldest);
2669 int min = (keepAll || exampleindex - rollMax < 0) ? 1
2670 : exampleindex - rollMax + 1;
2671 int max = exampleindex;
2673 for (int index = min; index <= max; index++)
2676 if (index == min + lowersurround && index < max - uppersurround - 1)
2678 exampleSB.append("\n...");
2681 else if (index > min + lowersurround && index < max - uppersurround)
2693 exampleSB.append("\n");
2696 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2697 base, suffix, digits));
2700 // no extra text needed
2702 else if (index == min)
2704 String oldest = MessageManager.getString("label.braced_oldest");
2705 if (oldest != null && oldest.length() > 0)
2707 exampleSB.append(" " + oldest);
2710 else if (index == max)
2712 String newest = MessageManager.getString("label.braced_newest");
2713 if (newest != null && newest.length() > 0)
2715 exampleSB.append(" " + newest);
2723 // add some extra empty lines to pad out the example files box. ugh, please tell
2724 // me how to do this better
2725 int remainingLines = lowersurround + uppersurround + 1 - lineNumber;
2726 if (remainingLines > 0)
2728 for (int i = 0; i < remainingLines; i++)
2730 exampleSB.append("\n ");
2735 backupfilesExampleLabel.setText(exampleSB.toString());
2738 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2739 boolean useExistingVal, ChangeListener c)
2746 i = ((Integer) s.getValue()).intValue();
2747 } catch (Exception e)
2750 "Exception casting the initial value of s.getValue()");
2754 setIntegerSpinner(s, min, max, i, c);
2757 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2760 // integer spinner for number of digits
2769 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
2772 s.addChangeListener(c);
2776 protected static int getSpinnerInt(JSpinner s, int def)
2782 i = (Integer) s.getValue();
2783 } catch (Exception e)
2785 Cache.log.error("Failed casting (Integer) JSpinner s.getValue()");
2790 private void keepRollMaxOptionsEnabled()
2792 boolean enabled = backupfilesKeepAll.isEnabled()
2793 && !backupfilesKeepAll.isSelected();
2794 oldBackupFilesLabel.setEnabled(enabled);
2795 backupfilesRollMaxSpinner.setEnabled(enabled);
2796 backupfilesConfirmDelete.setEnabled(enabled);
2799 private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
2801 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2802 && customiseCheckbox.isSelected()
2803 && suffixTemplate.getText()
2804 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2805 keepfilesPanel.setEnabled(enabled);
2806 backupfilesKeepAll.setEnabled(enabled);
2807 oldBackupFilesLabel.setEnabled(enabled);
2808 keepRollMaxOptionsEnabled();
2811 private void backupfilesSuffixTemplateDigitsSetEnabled()
2813 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
2814 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2815 suffixDigitsLabel.setEnabled(enabled);
2816 suffixDigitsSpinner.setEnabled(enabled);
2817 suffixReverse.setEnabled(enabled);
2820 private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
2822 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2823 && customiseCheckbox.isSelected();
2824 suffixPanel.setEnabled(enabled);
2825 suffixTemplateLabel.setEnabled(enabled);
2826 suffixTemplate.setEnabled(enabled);
2827 backupfilesSuffixTemplateDigitsSetEnabled();
2830 private void backupfilesRevertButtonSetEnabled(boolean tryEnabled)
2832 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2833 && customiseCheckbox.isSelected() && backupfilesCustomChanged();
2834 revertButton.setEnabled(enabled);
2837 private boolean backupfilesCustomChanged()
2839 BackupFilesPresetEntry custom = BackupFilesPresetEntry.backupfilesPresetEntriesValues
2840 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2841 BackupFilesPresetEntry current = getBackupfilesCurrentEntry();
2842 return !custom.equals(current);
2845 protected BackupFilesPresetEntry getBackupfilesCurrentEntry()
2847 String suffix = suffixTemplate.getText();
2848 int digits = getSpinnerInt(suffixDigitsSpinner, 3);
2849 boolean reverse = suffixReverse.isSelected();
2850 boolean keepAll = backupfilesKeepAll.isSelected();
2851 int rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 3);
2852 boolean confirmDelete = backupfilesConfirmDelete.isSelected();
2854 BackupFilesPresetEntry bfpe = new BackupFilesPresetEntry(suffix, digits,
2855 reverse, keepAll, rollMax, confirmDelete);
2860 protected void backupfilesCustomOptionsSetEnabled()
2862 boolean enabled = customiseCheckbox.isSelected();
2864 backupfilesRevertButtonSetEnabled(enabled);
2865 backupfilesSuffixTemplateSetEnabled(enabled);
2866 backupfilesKeepAllSetEnabled(enabled);
2869 private void backupfilesSummarySetEnabled()
2871 boolean enabled = enableBackupFiles.isSelected();
2872 backupfilesExampleLabel.setEnabled(enabled);
2873 exampleFilesPanel.setEnabled(enabled);
2876 private void backupfilesPresetsSetEnabled()
2878 boolean enabled = enableBackupFiles.isSelected();
2879 presetsPanel.setEnabled(enabled);
2880 presetsComboLabel.setEnabled(enabled);
2881 backupfilesPresetsCombo.setEnabled(enabled);
2882 customiseCheckbox.setEnabled(enabled);
2883 revertButton.setEnabled(enabled);
2886 protected void backupsOptionsSetEnabled()
2888 backupfilesPresetsSetEnabled();
2889 backupfilesSummarySetEnabled();
2890 backupfilesCustomOptionsSetEnabled();
2893 protected void backupsSetOptions(String suffix, int digits,
2894 boolean reverse, boolean keepAll, int rollMax,
2895 boolean confirmDelete)
2897 suffixTemplate.setText(suffix);
2898 suffixDigitsSpinner.setValue(digits);
2899 suffixReverse.setSelected(reverse);
2900 backupfilesKeepAll.setSelected(keepAll);
2901 backupfilesRollMaxSpinner.setValue(rollMax);
2902 backupfilesConfirmDelete.setSelected(confirmDelete);
2905 protected void backupsSetOptions(BackupFilesPresetEntry p)
2907 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
2911 protected void autoIdWidth_actionPerformed()
2913 // TODO Auto-generated method stub
2917 protected void userIdWidth_actionPerformed()
2919 // TODO Auto-generated method stub
2923 protected void maxColour_actionPerformed(JPanel panel)
2927 protected void minColour_actionPerformed(JPanel panel)
2931 protected void gapColour_actionPerformed(JPanel panel)
2935 protected void hiddenColour_actionPerformed(JPanel panel)
2939 protected void showunconserved_actionPerformed(ActionEvent e)
2941 // TODO Auto-generated method stub
2945 protected void useLegacyGaps_actionPerformed(ActionEvent e)
2949 protected void resetOvDefaults_actionPerformed(ActionEvent e)
2959 public void ok_actionPerformed(ActionEvent e)
2969 public void cancel_actionPerformed(ActionEvent e)
2979 public void annotations_actionPerformed(ActionEvent e)
2986 public void startupFileTextfield_mouseClicked()
2990 public void newLink_actionPerformed(ActionEvent e)
2995 public void editLink_actionPerformed(ActionEvent e)
3000 public void deleteLink_actionPerformed(ActionEvent e)
3005 public void defaultBrowser_mouseClicked(MouseEvent e)
3010 public void linkURLList_keyTyped(KeyEvent e)
3015 public void setProxyAuthEnabled()
3017 boolean enabled = proxyAuth.isSelected() && proxyAuth.isEnabled();
3018 proxyAuthUsernameLabel.setEnabled(enabled);
3019 proxyAuthPasswordLabel.setEnabled(enabled);
3020 proxyAuthUsernameTB.setEnabled(enabled);
3021 proxyAuthPasswordTB.setEnabled(enabled);
3024 public void setCustomProxyEnabled()
3026 boolean enabled = customProxy.isSelected();
3027 portLabel.setEnabled(enabled);
3028 serverLabel.setEnabled(enabled);
3029 portLabel2.setEnabled(enabled);
3030 serverLabel2.setEnabled(enabled);
3031 httpLabel.setEnabled(enabled);
3032 httpsLabel.setEnabled(enabled);
3033 proxyServerHttpTB.setEnabled(enabled);
3034 proxyPortHttpTB.setEnabled(enabled);
3035 proxyServerHttpsTB.setEnabled(enabled);
3036 proxyPortHttpsTB.setEnabled(enabled);
3037 proxyAuth.setEnabled(enabled);
3038 setProxyAuthEnabled();
3041 public void proxyType_actionPerformed()
3043 setCustomProxyEnabled();
3046 public void proxyAuth_actionPerformed()
3048 setProxyAuthEnabled();
3052 * Customer renderer for JTable: supports column of radio buttons
3054 public class RadioButtonRenderer extends JRadioButton
3055 implements TableCellRenderer
3057 public RadioButtonRenderer()
3059 setHorizontalAlignment(CENTER);
3060 setToolTipText(MessageManager.getString("label.urltooltip"));
3064 public Component getTableCellRendererComponent(JTable table,
3065 Object value, boolean isSelected, boolean hasFocus, int row,
3068 setSelected((boolean) value);
3070 // set colours to match rest of table
3073 setBackground(table.getSelectionBackground());
3074 setForeground(table.getSelectionForeground());
3078 setBackground(table.getBackground());
3079 setForeground(table.getForeground());
3086 * Customer cell editor for JTable: supports column of radio buttons in
3087 * conjunction with renderer
3089 public class RadioButtonEditor extends AbstractCellEditor
3090 implements TableCellEditor
3092 private JRadioButton button = new JRadioButton();
3094 public RadioButtonEditor()
3096 button.setHorizontalAlignment(SwingConstants.CENTER);
3097 this.button.addActionListener(new ActionListener()
3100 public void actionPerformed(ActionEvent e)
3102 fireEditingStopped();
3108 public Component getTableCellEditorComponent(JTable table, Object value,
3109 boolean isSelected, int row, int column)
3111 button.setSelected((boolean) value);
3116 public Object getCellEditorValue()
3118 return button.isSelected();