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 JPanel connectTab;
223 protected JTable linkUrlTable = new JTable();
225 protected JButton editLink = new JButton();
227 protected JButton deleteLink = new JButton();
229 protected JTextField filterTB = new JTextField();
231 protected JButton doReset = new JButton();
233 protected JButton userOnly = new JButton();
235 protected JLabel httpLabel = new JLabel();
237 protected JLabel httpsLabel = new JLabel();
239 protected JLabel portLabel = new JLabel();
241 protected JLabel serverLabel = new JLabel();
243 protected JLabel portLabel2 = new JLabel();
245 protected JLabel serverLabel2 = new JLabel();
247 protected JLabel proxyAuthUsernameLabel = new JLabel();
249 protected JLabel proxyAuthPasswordLabel = new JLabel();
251 protected JLabel passwordNotStoredLabel = new JLabel();
253 protected JTextField proxyServerHttpTB = new JTextField();
255 protected JTextField proxyPortHttpTB = new JTextField();
257 protected JTextField proxyServerHttpsTB = new JTextField();
259 protected JTextField proxyPortHttpsTB = new JTextField();
261 protected JCheckBox proxyAuth = new JCheckBox();
263 protected JTextField proxyAuthUsernameTB = new JTextField();
265 protected JPasswordField proxyAuthPasswordTB = new JPasswordField();
267 protected JTextField defaultBrowser = new JTextField();
269 protected ButtonGroup proxyType = new ButtonGroup();
271 protected JRadioButton noProxy = new JRadioButton();
273 protected JRadioButton systemProxy = new JRadioButton();
275 protected JRadioButton customProxy = new JRadioButton();
277 protected JCheckBox usagestats = new JCheckBox();
279 protected JCheckBox questionnaire = new JCheckBox();
281 protected JCheckBox versioncheck = new JCheckBox();
284 * Output tab components
286 protected JComboBox<Object> epsRendering = new JComboBox<>();
288 protected JComboBox<Object> htmlRendering = new JComboBox<>();
290 protected JComboBox<Object> svgRendering = new JComboBox<>();
292 protected JLabel userIdWidthlabel = new JLabel();
294 protected JCheckBox autoIdWidth = new JCheckBox();
296 protected JTextField userIdWidth = new JTextField();
298 protected JCheckBox blcjv = new JCheckBox();
300 protected JCheckBox pileupjv = new JCheckBox();
302 protected JCheckBox clustaljv = new JCheckBox();
304 protected JCheckBox msfjv = new JCheckBox();
306 protected JCheckBox fastajv = new JCheckBox();
308 protected JCheckBox pfamjv = new JCheckBox();
310 protected JCheckBox pirjv = new JCheckBox();
312 protected JCheckBox modellerOutput = new JCheckBox();
314 protected JCheckBox embbedBioJSON = new JCheckBox();
317 * Editing tab components
319 protected JCheckBox autoCalculateConsCheck = new JCheckBox();
321 protected JCheckBox padGaps = new JCheckBox();
323 protected JCheckBox sortByTree = new JCheckBox();
328 protected JPanel wsTab = new JPanel();
331 * Backups tab components
332 * a lot of these are member variables instead of local variables only so that they
333 * can be enabled/disabled easily in one go
336 protected JCheckBox enableBackupFiles = new JCheckBox();
338 protected JPanel presetsPanel = new JPanel();
340 protected JLabel presetsComboLabel = new JLabel();
342 protected JCheckBox customiseCheckbox = new JCheckBox();
344 protected JButton revertButton = new JButton();
346 protected JComboBox<Object> backupfilesPresetsCombo = new JComboBox<>();
348 private int backupfilesPresetsComboLastSelected = 0;
350 protected JPanel suffixPanel = new JPanel();
352 protected JPanel keepfilesPanel = new JPanel();
354 protected JPanel exampleFilesPanel = new JPanel();
356 protected JTextField suffixTemplate = new JTextField(null, 8);
358 protected JLabel suffixTemplateLabel = new JLabel();
360 protected JLabel suffixDigitsLabel = new JLabel();
362 protected JSpinner suffixDigitsSpinner = new JSpinner();
364 protected JalviewBooleanRadioButtons suffixReverse = new JalviewBooleanRadioButtons();
366 protected JalviewBooleanRadioButtons backupfilesKeepAll = new JalviewBooleanRadioButtons();
368 public JSpinner backupfilesRollMaxSpinner = new JSpinner();
370 protected JLabel oldBackupFilesLabel = new JLabel();
372 protected JalviewBooleanRadioButtons backupfilesConfirmDelete = new JalviewBooleanRadioButtons();
374 protected JTextArea backupfilesExampleLabel = new JTextArea();
377 * Creates a new GPreferences object.
379 public GPreferences()
384 public GPreferences(int selectTab)
389 } catch (Exception ex)
391 ex.printStackTrace();
396 * Construct the panel and its tabbed sub-panels.
400 private void jbInit() throws Exception
405 public final static int CONNECTIONS_TAB = 5;
407 private void jbInit(int selectTab) throws Exception
409 final JTabbedPane tabbedPane = new JTabbedPane();
410 this.setLayout(new BorderLayout());
411 JPanel okCancelPanel = initOkCancelPanel();
412 this.add(tabbedPane, BorderLayout.CENTER);
413 this.add(okCancelPanel, BorderLayout.SOUTH);
415 tabbedPane.add(initVisualTab(),
416 MessageManager.getString("label.visual"));
418 tabbedPane.add(initColoursTab(),
419 MessageManager.getString("label.colours"));
421 tabbedPane.add(initOverviewTab(),
422 MessageManager.getString("label.overview"));
424 tabbedPane.add(initStructureTab(),
425 MessageManager.getString("label.structure"));
427 tabbedPane.add(initConnectionsTab(),
428 MessageManager.getString("label.connections"));
430 if (!Platform.isJS())
432 tabbedPane.add(initBackupsTab(),
433 MessageManager.getString("label.backups"));
436 tabbedPane.add(initLinksTab(),
437 MessageManager.getString("label.urllinks"));
439 tabbedPane.add(initOutputTab(),
440 MessageManager.getString("label.output"));
442 tabbedPane.add(initEditingTab(),
443 MessageManager.getString("label.editing"));
446 * See WsPreferences for the real work of configuring this tab.
448 if (!Platform.isJS())
450 wsTab.setLayout(new BorderLayout());
451 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
455 * Handler to validate a tab before leaving it - currently only for
458 tabbedPane.addChangeListener(new ChangeListener()
460 private Component lastTab;
463 public void stateChanged(ChangeEvent e)
465 if (lastTab == structureTab
466 && tabbedPane.getSelectedComponent() != structureTab)
468 if (!validateStructure())
470 tabbedPane.setSelectedComponent(structureTab);
474 lastTab = tabbedPane.getSelectedComponent();
479 // select a given tab - currently only for Connections
482 case CONNECTIONS_TAB:
483 tabbedPane.setSelectedComponent(connectTab);
491 * Initialises the Editing tabbed panel.
495 private JPanel initEditingTab()
497 JPanel editingTab = new JPanel();
498 editingTab.setLayout(null);
499 autoCalculateConsCheck.setFont(LABEL_FONT);
500 autoCalculateConsCheck.setText(
501 MessageManager.getString("label.autocalculate_consensus"));
502 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
503 padGaps.setFont(LABEL_FONT);
505 MessageManager.getString("label.pad_gaps_when_editing"));
506 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
507 sortByTree.setFont(LABEL_FONT);
509 .setText(MessageManager.getString("label.sort_with_new_tree"));
510 sortByTree.setToolTipText(MessageManager.getString(
511 "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
512 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
513 editingTab.add(autoCalculateConsCheck);
514 editingTab.add(padGaps);
515 editingTab.add(sortByTree);
520 * Initialises the Output tab
524 private JPanel initOutputTab()
526 JPanel outputTab = new JPanel();
527 outputTab.setLayout(null);
529 JLabel epsLabel = new JLabel(
530 MessageManager.formatMessage("label.rendering_style", "EPS"));
531 epsLabel.setFont(LABEL_FONT);
532 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
533 epsLabel.setBounds(new Rectangle(9, 31, 160, 24));
534 epsRendering.setFont(LABEL_FONT);
535 epsRendering.setBounds(new Rectangle(174, 34, 187, 21));
536 JLabel htmlLabel = new JLabel(
537 MessageManager.formatMessage("label.rendering_style", "HTML"));
538 htmlLabel.setFont(LABEL_FONT);
539 htmlLabel.setHorizontalAlignment(SwingConstants.RIGHT);
540 htmlLabel.setBounds(new Rectangle(9, 55, 160, 24));
541 htmlRendering.setFont(LABEL_FONT);
542 htmlRendering.setBounds(new Rectangle(174, 58, 187, 21));
543 JLabel svgLabel = new JLabel(
544 MessageManager.formatMessage("label.rendering_style", "SVG"));
545 svgLabel.setFont(LABEL_FONT);
546 svgLabel.setHorizontalAlignment(SwingConstants.RIGHT);
547 svgLabel.setBounds(new Rectangle(9, 79, 160, 24));
548 svgRendering.setFont(LABEL_FONT);
549 svgRendering.setBounds(new Rectangle(174, 82, 187, 21));
551 JLabel jLabel1 = new JLabel();
552 jLabel1.setFont(LABEL_FONT);
553 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
554 jLabel1.setText(MessageManager.getString("label.append_start_end"));
555 jLabel1.setFont(LABEL_FONT);
557 fastajv.setFont(LABEL_FONT);
558 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
559 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
560 blcjv.setText(MessageManager.getString("label.blc") + " ");
561 fastajv.setText(MessageManager.getString("label.fasta") + " ");
562 msfjv.setText(MessageManager.getString("label.msf") + " ");
563 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
564 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
565 msfjv.setFont(LABEL_FONT);
566 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
567 pirjv.setText(MessageManager.getString("label.pir") + " ");
568 JPanel jPanel11 = new JPanel();
569 jPanel11.setFont(LABEL_FONT);
570 TitledBorder titledBorder2 = new TitledBorder(
571 MessageManager.getString("label.file_output"));
572 jPanel11.setBorder(titledBorder2);
573 jPanel11.setBounds(new Rectangle(30, 120, 196, 182));
574 GridLayout gridLayout3 = new GridLayout();
575 jPanel11.setLayout(gridLayout3);
576 gridLayout3.setRows(8);
577 blcjv.setFont(LABEL_FONT);
578 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
579 clustaljv.setFont(LABEL_FONT);
580 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
581 pfamjv.setFont(LABEL_FONT);
582 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
583 pileupjv.setFont(LABEL_FONT);
584 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
585 pirjv.setFont(LABEL_FONT);
586 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
587 autoIdWidth.setFont(LABEL_FONT);
589 MessageManager.getString("label.automatically_set_id_width"));
590 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
591 .getString("label.adjusts_width_generated_eps_png")));
592 autoIdWidth.setBounds(new Rectangle(228, 144, 320, 23));
593 autoIdWidth.addActionListener(new ActionListener()
597 public void actionPerformed(ActionEvent e)
599 autoIdWidth_actionPerformed();
602 userIdWidthlabel.setFont(LABEL_FONT);
603 userIdWidthlabel.setText(
604 MessageManager.getString("label.figure_id_column_width"));
605 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
606 .getString("label.manually_specify_width_left_column")));
607 userIdWidthlabel.setToolTipText(
608 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
609 "label.manually_specify_width_left_column")));
610 userIdWidthlabel.setBounds(new Rectangle(236, 168, 320, 23));
611 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
612 userIdWidth.setText("");
613 userIdWidth.setBounds(new Rectangle(232, 192, 84, 23));
614 userIdWidth.addActionListener(new ActionListener()
618 public void actionPerformed(ActionEvent e)
620 userIdWidth_actionPerformed();
623 modellerOutput.setFont(LABEL_FONT);
625 .setText(MessageManager.getString("label.use_modeller_output"));
626 modellerOutput.setBounds(new Rectangle(228, 274, 320, 23));
627 embbedBioJSON.setFont(LABEL_FONT);
628 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
629 embbedBioJSON.setBounds(new Rectangle(228, 248, 250, 23));
631 jPanel11.add(jLabel1);
633 jPanel11.add(clustaljv);
634 jPanel11.add(fastajv);
636 jPanel11.add(pfamjv);
637 jPanel11.add(pileupjv);
639 outputTab.add(autoIdWidth);
640 outputTab.add(userIdWidth);
641 outputTab.add(userIdWidthlabel);
642 outputTab.add(modellerOutput);
643 if (!Platform.isJS())
646 * JalviewJS doesn't support Lineart option or SVG output
648 outputTab.add(embbedBioJSON);
649 outputTab.add(epsLabel);
650 outputTab.add(epsRendering);
651 outputTab.add(htmlLabel);
652 outputTab.add(htmlRendering);
653 outputTab.add(svgLabel);
654 outputTab.add(svgRendering);
656 outputTab.add(jPanel11);
661 * Initialises the Connections tabbed panel.
665 private JPanel initConnectionsTab()
667 connectTab = new JPanel();
668 connectTab.setLayout(new GridBagLayout());
670 // Label for browser text box
671 JLabel browserLabel = new JLabel();
672 browserLabel.setFont(LABEL_FONT);
673 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
674 browserLabel.setText(
675 MessageManager.getString("label.default_browser_unix"));
676 defaultBrowser.setFont(LABEL_FONT);
677 defaultBrowser.setText("");
678 final String tooltip = JvSwingUtils.wrapTooltip(true,
679 MessageManager.getString("label.double_click_to_browse"));
680 defaultBrowser.setToolTipText(tooltip);
681 defaultBrowser.addMouseListener(new MouseAdapter()
684 public void mouseClicked(MouseEvent e)
686 if (e.getClickCount() > 1)
688 defaultBrowser_mouseClicked(e);
693 JPanel proxyPanel = initConnTabProxyPanel();
694 initConnTabCheckboxes();
696 // Add default Browser text box
697 connectTab.add(browserLabel,
698 new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
699 GridBagConstraints.WEST, GridBagConstraints.NONE,
700 new Insets(10, 0, 5, 5), 5, 1));
701 defaultBrowser.setFont(LABEL_FONT);
702 defaultBrowser.setText("");
704 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
705 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
706 new Insets(10, 0, 5, 10), 30, 1));
708 // Add proxy server panel
709 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
710 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
711 new Insets(10, 0, 5, 12), 4, 10));
713 // Add usage stats, version check and questionnaire checkboxes
714 connectTab.add(usagestats,
715 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
716 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
717 new Insets(0, 2, 5, 5), 70, 1));
718 connectTab.add(questionnaire,
719 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
720 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
721 new Insets(0, 2, 5, 10), 70, 1));
722 connectTab.add(versioncheck,
723 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
724 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
725 new Insets(0, 2, 5, 5), 70, 1));
727 versioncheck.setVisible(false);
729 // Add padding so the panel doesn't look ridiculous
730 JPanel spacePanel = new JPanel();
731 connectTab.add(spacePanel,
732 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
733 GridBagConstraints.WEST, GridBagConstraints.BOTH,
734 new Insets(0, 0, 0, 5), 70, 1));
740 * Initialises the Links tabbed panel.
744 private JPanel initLinksTab()
746 JPanel linkTab = new JPanel();
747 linkTab.setLayout(new GridBagLayout());
749 // Set up table for Url links
750 linkUrlTable.getTableHeader().setReorderingAllowed(false);
751 linkUrlTable.setFillsViewportHeight(true);
752 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
753 linkUrlTable.setAutoCreateRowSorter(true);
754 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
756 // adjust row height so radio buttons actually fit
757 // don't do this in the renderer, it causes the awt thread to activate
759 JRadioButton temp = new JRadioButton();
760 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
762 // Table in scrollpane so that the table is given a scrollbar
763 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
764 linkScrollPane.setBorder(null);
766 // Panel for links functionality
767 JPanel linkPanel = new JPanel(new GridBagLayout());
768 linkPanel.setBorder(new TitledBorder(
769 MessageManager.getString("label.url_linkfrom_sequence_id")));
771 // Put the Url links panel together
773 // Buttons go at top right, resizing only resizes the blank space vertically
774 JPanel buttonPanel = initLinkTabUrlButtons();
775 GridBagConstraints linkConstraints1 = new GridBagConstraints();
776 linkConstraints1.insets = new Insets(0, 0, 5, 0);
777 linkConstraints1.gridx = 0;
778 linkConstraints1.gridy = 0;
779 linkConstraints1.weightx = 1.0;
780 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
781 linkTab.add(buttonPanel, linkConstraints1);
783 // Links table goes at top left, resizing resizes the table
784 GridBagConstraints linkConstraints2 = new GridBagConstraints();
785 linkConstraints2.insets = new Insets(0, 0, 5, 5);
786 linkConstraints2.gridx = 0;
787 linkConstraints2.gridy = 1;
788 linkConstraints2.weightx = 1.0;
789 linkConstraints2.weighty = 1.0;
790 linkConstraints2.fill = GridBagConstraints.BOTH;
791 linkTab.add(linkScrollPane, linkConstraints2);
793 // Filter box and buttons goes at bottom left, resizing resizes the text box
794 JPanel filterPanel = initLinkTabFilterPanel();
795 GridBagConstraints linkConstraints3 = new GridBagConstraints();
796 linkConstraints3.insets = new Insets(0, 0, 0, 5);
797 linkConstraints3.gridx = 0;
798 linkConstraints3.gridy = 2;
799 linkConstraints3.weightx = 1.0;
800 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
801 linkTab.add(filterPanel, linkConstraints3);
806 private JPanel initLinkTabFilterPanel()
808 // Filter textbox and reset button
809 JLabel filterLabel = new JLabel(
810 MessageManager.getString("label.filter"));
811 filterLabel.setFont(LABEL_FONT);
812 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
813 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
815 filterTB.setFont(LABEL_FONT);
816 filterTB.setText("");
818 doReset.setText(MessageManager.getString("action.showall"));
819 userOnly.setText(MessageManager.getString("action.customfilter"));
821 // Panel for filter functionality
822 JPanel filterPanel = new JPanel(new GridBagLayout());
823 filterPanel.setBorder(new TitledBorder("Filter"));
824 GridBagConstraints gbc = new GridBagConstraints();
827 gbc.fill = GridBagConstraints.NONE;
828 gbc.anchor = GridBagConstraints.WEST;
830 filterPanel.add(filterLabel, gbc);
832 GridBagConstraints gbc1 = new GridBagConstraints();
835 gbc1.fill = GridBagConstraints.HORIZONTAL;
836 gbc1.anchor = GridBagConstraints.WEST;
838 filterPanel.add(filterTB, gbc1);
840 GridBagConstraints gbc2 = new GridBagConstraints();
842 gbc2.fill = GridBagConstraints.NONE;
843 gbc2.anchor = GridBagConstraints.WEST;
844 filterPanel.add(doReset, gbc2);
846 GridBagConstraints gbc3 = new GridBagConstraints();
848 gbc3.fill = GridBagConstraints.NONE;
849 gbc3.anchor = GridBagConstraints.WEST;
850 filterPanel.add(userOnly, gbc3);
855 private JPanel initLinkTabUrlButtons()
857 // Buttons for new / edit / delete Url links
858 JButton newLink = new JButton();
859 newLink.setText(MessageManager.getString("action.new"));
861 editLink.setText(MessageManager.getString("action.edit"));
863 deleteLink.setText(MessageManager.getString("action.delete"));
865 // no current selection, so initially disable delete/edit buttons
866 editLink.setEnabled(false);
867 deleteLink.setEnabled(false);
869 newLink.addActionListener(new java.awt.event.ActionListener()
872 public void actionPerformed(ActionEvent e)
874 newLink_actionPerformed(e);
878 editLink.setText(MessageManager.getString("action.edit"));
879 editLink.addActionListener(new java.awt.event.ActionListener()
882 public void actionPerformed(ActionEvent e)
884 editLink_actionPerformed(e);
888 deleteLink.setText(MessageManager.getString("action.delete"));
889 deleteLink.addActionListener(new java.awt.event.ActionListener()
892 public void actionPerformed(ActionEvent e)
894 deleteLink_actionPerformed(e);
898 JPanel buttonPanel = new JPanel(new GridBagLayout());
899 buttonPanel.setBorder(new TitledBorder("Edit links"));
900 GridBagConstraints gbc = new GridBagConstraints();
903 gbc.fill = GridBagConstraints.NONE;
904 buttonPanel.add(newLink, gbc);
906 GridBagConstraints gbc1 = new GridBagConstraints();
909 gbc1.fill = GridBagConstraints.NONE;
910 buttonPanel.add(editLink, gbc1);
912 GridBagConstraints gbc2 = new GridBagConstraints();
915 gbc2.fill = GridBagConstraints.NONE;
916 buttonPanel.add(deleteLink, gbc2);
918 GridBagConstraints gbc3 = new GridBagConstraints();
921 gbc3.fill = GridBagConstraints.HORIZONTAL;
923 JPanel spacePanel = new JPanel();
924 spacePanel.setBorder(null);
925 buttonPanel.add(spacePanel, gbc3);
931 * Initialises the proxy server panel in the Connections tab
933 * @return the proxy server panel
935 private JPanel initConnTabProxyPanel()
937 // Label for server text box
938 serverLabel.setText(MessageManager.getString("label.host") + ": ");
939 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
940 serverLabel.setFont(LABEL_FONT);
941 serverLabel2.setText(MessageManager.getString("label.host") + ": ");
942 serverLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
943 serverLabel2.setFont(LABEL_FONT);
945 // Proxy server and port text boxes
946 proxyServerHttpTB.setFont(LABEL_FONT);
947 proxyServerHttpTB.setColumns(40);
948 proxyPortHttpTB.setFont(LABEL_FONT);
949 proxyPortHttpTB.setColumns(4);
950 proxyServerHttpsTB.setFont(LABEL_FONT);
951 proxyServerHttpsTB.setColumns(40);
952 proxyPortHttpsTB.setFont(LABEL_FONT);
953 proxyPortHttpsTB.setColumns(4);
954 proxyAuthUsernameTB.setFont(LABEL_FONT);
955 proxyAuthUsernameTB.setColumns(30);
956 proxyAuthPasswordTB.setFont(LABEL_FONT);
957 proxyAuthPasswordTB.setColumns(30);
959 // Label for Port text box
960 portLabel.setFont(LABEL_FONT);
961 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
962 portLabel.setText(MessageManager.getString("label.port") + ": ");
963 portLabel2.setFont(LABEL_FONT);
964 portLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
965 portLabel2.setText(MessageManager.getString("label.port") + ": ");
967 httpLabel.setText("HTTP");
968 httpLabel.setFont(LABEL_FONT_BOLD);
969 httpLabel.setHorizontalAlignment(SwingConstants.LEFT);
970 httpsLabel.setText("HTTPS");
971 httpsLabel.setFont(LABEL_FONT_BOLD);
972 httpsLabel.setHorizontalAlignment(SwingConstants.LEFT);
974 proxyAuthUsernameLabel
975 .setText(MessageManager.getString("label.username") + ": ");
976 proxyAuthUsernameLabel.setFont(LABEL_FONT);
977 proxyAuthUsernameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
978 proxyAuthPasswordLabel
979 .setText(MessageManager.getString("label.password") + ": ");
980 proxyAuthPasswordLabel.setFont(LABEL_FONT);
981 proxyAuthPasswordLabel.setHorizontalAlignment(SwingConstants.RIGHT);
982 passwordNotStoredLabel.setText(
983 "(" + MessageManager.getString("label.not_stored") + ")");
984 passwordNotStoredLabel.setFont(LABEL_FONT_ITALIC);
985 passwordNotStoredLabel.setHorizontalAlignment(SwingConstants.LEFT);
987 // Proxy type radio buttons
988 noProxy.setFont(LABEL_FONT);
989 noProxy.setHorizontalAlignment(SwingConstants.LEFT);
990 noProxy.setText(MessageManager.getString("label.no_proxy"));
991 systemProxy.setFont(LABEL_FONT);
992 systemProxy.setHorizontalAlignment(SwingConstants.LEFT);
993 systemProxy.setText(MessageManager.formatMessage("label.system_proxy",
994 displayUserHostPort(Cache.startupProxyProperties[4],
995 Cache.startupProxyProperties[0],
996 Cache.startupProxyProperties[1]),
997 displayUserHostPort(Cache.startupProxyProperties[6],
998 Cache.startupProxyProperties[2],
999 Cache.startupProxyProperties[3])));
1000 customProxy.setFont(LABEL_FONT);
1001 customProxy.setHorizontalAlignment(SwingConstants.LEFT);
1002 customProxy.setText(
1003 MessageManager.getString("label.use_proxy_server") + ":");
1004 ActionListener al = new ActionListener()
1007 public void actionPerformed(ActionEvent e)
1009 proxyType_actionPerformed();
1012 noProxy.addActionListener(al);
1013 systemProxy.addActionListener(al);
1014 customProxy.addActionListener(al);
1015 proxyType.add(noProxy);
1016 proxyType.add(systemProxy);
1017 proxyType.add(customProxy);
1019 proxyAuth.setFont(LABEL_FONT);
1020 proxyAuth.setHorizontalAlignment(SwingConstants.LEFT);
1021 proxyAuth.setText(MessageManager.getString("label.auth_required"));
1022 proxyAuth.addActionListener(new ActionListener()
1025 public void actionPerformed(ActionEvent e)
1027 proxyAuth_actionPerformed();
1031 setCustomProxyEnabled();
1033 // Make proxy server panel
1034 JPanel proxyPanel = new JPanel();
1035 TitledBorder titledBorder1 = new TitledBorder(
1036 MessageManager.getString("label.proxy_servers"));
1037 proxyPanel.setBorder(titledBorder1);
1038 proxyPanel.setLayout(new GridBagLayout());
1039 GridBagConstraints gbc = new GridBagConstraints();
1040 gbc.fill = GridBagConstraints.HORIZONTAL;
1043 GridBagConstraints c = new GridBagConstraints();
1044 // Proxy type radio buttons (3)
1045 JPanel ptPanel = new JPanel();
1046 ptPanel.setLayout(new GridBagLayout());
1051 c.fill = GridBagConstraints.HORIZONTAL;
1052 ptPanel.add(noProxy, c);
1054 ptPanel.add(systemProxy, c);
1056 ptPanel.add(customProxy, c);
1059 proxyPanel.add(ptPanel, gbc);
1061 // host and port text boxes
1062 JPanel hpPanel = new JPanel();
1063 hpPanel.setLayout(new GridBagLayout());
1064 // HTTP host port row
1069 c.anchor = GridBagConstraints.LINE_START;
1070 hpPanel.add(httpLabel, c);
1074 c.anchor = GridBagConstraints.LINE_END;
1075 hpPanel.add(serverLabel, c);
1079 c.anchor = GridBagConstraints.LINE_START;
1080 hpPanel.add(proxyServerHttpTB, c);
1084 c.anchor = GridBagConstraints.LINE_END;
1085 hpPanel.add(portLabel, c);
1089 c.anchor = GridBagConstraints.LINE_START;
1090 hpPanel.add(proxyPortHttpTB, c);
1092 // HTTPS host port row
1097 c.anchor = GridBagConstraints.LINE_START;
1098 hpPanel.add(httpsLabel, c);
1101 c.anchor = GridBagConstraints.LINE_END;
1102 hpPanel.add(serverLabel2, c);
1105 c.anchor = GridBagConstraints.LINE_START;
1106 hpPanel.add(proxyServerHttpsTB, c);
1109 c.anchor = GridBagConstraints.LINE_END;
1110 hpPanel.add(portLabel2, c);
1113 c.anchor = GridBagConstraints.LINE_START;
1114 hpPanel.add(proxyPortHttpsTB, c);
1117 proxyPanel.add(hpPanel, gbc);
1119 // Require authentication checkbox
1121 proxyPanel.add(proxyAuth, gbc);
1123 // username and password
1124 JPanel upPanel = new JPanel();
1125 upPanel.setLayout(new GridBagLayout());
1131 c.anchor = GridBagConstraints.LINE_END;
1132 upPanel.add(proxyAuthUsernameLabel, c);
1136 c.anchor = GridBagConstraints.LINE_START;
1137 upPanel.add(proxyAuthUsernameTB, c);
1143 c.anchor = GridBagConstraints.LINE_END;
1144 upPanel.add(proxyAuthPasswordLabel, c);
1148 c.anchor = GridBagConstraints.LINE_START;
1149 upPanel.add(proxyAuthPasswordTB, c);
1153 c.anchor = GridBagConstraints.LINE_START;
1154 upPanel.add(passwordNotStoredLabel, c);
1157 proxyPanel.add(upPanel, gbc);
1162 private String displayUserHostPort(String user, String host, String port)
1164 boolean hostBlank = (host == null || host.isEmpty());
1165 boolean portBlank = (port == null || port.isEmpty());
1166 if (hostBlank && portBlank)
1168 return MessageManager.getString("label.none");
1171 StringBuilder sb = new StringBuilder();
1174 sb.append(user.isEmpty() || user.indexOf(" ") > -1 ? '"' + user + '"'
1178 sb.append(hostBlank ? "" : host);
1184 return sb.toString();
1188 * Initialises the checkboxes in the Connections tab
1190 private void initConnTabCheckboxes()
1192 // Usage stats checkbox label
1194 MessageManager.getString("label.send_usage_statistics"));
1195 usagestats.setFont(LABEL_FONT);
1196 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
1197 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
1199 // Questionnaire checkbox label
1200 questionnaire.setText(
1201 MessageManager.getString("label.check_for_questionnaires"));
1202 questionnaire.setFont(LABEL_FONT);
1203 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
1204 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
1206 // Check for latest version checkbox label
1207 versioncheck.setText(
1208 MessageManager.getString("label.check_for_latest_version"));
1209 versioncheck.setFont(LABEL_FONT);
1210 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
1211 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
1215 * Initialises the parent panel which contains the tabbed sections.
1219 private JPanel initOkCancelPanel()
1221 JButton ok = new JButton();
1222 ok.setText(MessageManager.getString("action.ok"));
1223 ok.addActionListener(new ActionListener()
1226 public void actionPerformed(ActionEvent e)
1228 ok_actionPerformed(e);
1231 JButton cancel = new JButton();
1232 cancel.setText(MessageManager.getString("action.cancel"));
1233 cancel.addActionListener(new ActionListener()
1236 public void actionPerformed(ActionEvent e)
1238 cancel_actionPerformed(e);
1241 JPanel okCancelPanel = new JPanel();
1242 okCancelPanel.add(ok);
1243 okCancelPanel.add(cancel);
1244 return okCancelPanel;
1248 * Initialises the Colours tabbed panel.
1252 private JPanel initColoursTab()
1254 JPanel coloursTab = new JPanel();
1255 coloursTab.setBorder(new TitledBorder(
1256 MessageManager.getString("action.open_new_alignment")));
1257 coloursTab.setLayout(new FlowLayout());
1258 JLabel mincolourLabel = new JLabel();
1259 mincolourLabel.setFont(LABEL_FONT);
1260 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1261 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
1262 minColour.setFont(LABEL_FONT);
1263 minColour.setBorder(BorderFactory.createEtchedBorder());
1264 minColour.setPreferredSize(new Dimension(40, 20));
1265 minColour.addMouseListener(new MouseAdapter()
1268 public void mousePressed(MouseEvent e)
1270 minColour_actionPerformed(minColour);
1273 JLabel maxcolourLabel = new JLabel();
1274 maxcolourLabel.setFont(LABEL_FONT);
1275 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1276 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
1277 maxColour.setFont(LABEL_FONT);
1278 maxColour.setBorder(BorderFactory.createEtchedBorder());
1279 maxColour.setPreferredSize(new Dimension(40, 20));
1280 maxColour.addMouseListener(new MouseAdapter()
1283 public void mousePressed(MouseEvent e)
1285 maxColour_actionPerformed(maxColour);
1289 protColour.setFont(LABEL_FONT);
1290 protColour.setBounds(new Rectangle(172, 225, 155, 21));
1291 JLabel protColourLabel = new JLabel();
1292 protColourLabel.setFont(LABEL_FONT);
1293 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1294 protColourLabel.setText(
1295 MessageManager.getString("label.prot_alignment_colour") + " ");
1296 JvSwingUtils.addtoLayout(coloursTab,
1298 .getString("label.default_colour_scheme_for_alignment"),
1299 protColourLabel, protColour);
1301 nucColour.setFont(LABEL_FONT);
1302 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1303 JLabel nucColourLabel = new JLabel();
1304 nucColourLabel.setFont(LABEL_FONT);
1305 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1306 nucColourLabel.setText(
1307 MessageManager.getString("label.nuc_alignment_colour") + " ");
1308 JvSwingUtils.addtoLayout(coloursTab,
1310 .getString("label.default_colour_scheme_for_alignment"),
1311 nucColourLabel, nucColour);
1313 JPanel annotationShding = new JPanel();
1314 annotationShding.setBorder(new TitledBorder(
1315 MessageManager.getString("label.annotation_shading_default")));
1316 annotationShding.setLayout(new GridLayout(1, 2));
1317 JvSwingUtils.addtoLayout(annotationShding,
1318 MessageManager.getString(
1319 "label.default_minimum_colour_annotation_shading"),
1320 mincolourLabel, minColour);
1321 JvSwingUtils.addtoLayout(annotationShding,
1322 MessageManager.getString(
1323 "label.default_maximum_colour_annotation_shading"),
1324 maxcolourLabel, maxColour);
1325 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1330 * Initialises the Overview tabbed panel.
1334 private JPanel initOverviewTab()
1336 JPanel overviewPanel = new JPanel();
1337 overviewPanel.setBorder(new TitledBorder(
1338 MessageManager.getString("label.overview_settings")));
1340 gapColour.setFont(LABEL_FONT);
1341 // fixing the border colours stops apparent colour bleed from the panel
1342 gapColour.setBorder(
1343 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1344 gapColour.setPreferredSize(new Dimension(40, 20));
1345 gapColour.addMouseListener(new MouseAdapter()
1348 public void mousePressed(MouseEvent e)
1350 gapColour_actionPerformed(gapColour);
1354 hiddenColour.setFont(LABEL_FONT);
1355 // fixing the border colours stops apparent colour bleed from the panel
1356 hiddenColour.setBorder(
1357 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1358 hiddenColour.setPreferredSize(new Dimension(40, 20));
1359 hiddenColour.addMouseListener(new MouseAdapter()
1362 public void mousePressed(MouseEvent e)
1364 hiddenColour_actionPerformed(hiddenColour);
1368 useLegacyGap = new JCheckBox(
1369 MessageManager.getString("label.ov_legacy_gap"));
1370 useLegacyGap.setFont(LABEL_FONT);
1371 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1372 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1373 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1374 gapLabel.setFont(LABEL_FONT);
1375 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1376 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1377 showHiddenAtStart = new JCheckBox(
1378 MessageManager.getString("label.ov_show_hide_default"));
1379 showHiddenAtStart.setFont(LABEL_FONT);
1380 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1381 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1382 JLabel hiddenLabel = new JLabel(
1383 MessageManager.getString("label.hidden_colour"));
1384 hiddenLabel.setFont(LABEL_FONT);
1385 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1386 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1388 useLegacyGap.addActionListener(new ActionListener()
1391 public void actionPerformed(ActionEvent e)
1393 useLegacyGaps_actionPerformed(e);
1397 overviewPanel.setLayout(new GridBagLayout());
1398 GridBagConstraints c1 = new GridBagConstraints();
1400 c1.fill = GridBagConstraints.HORIZONTAL;
1405 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1406 overviewPanel.add(useLegacyGap, c1);
1408 GridBagConstraints c2 = new GridBagConstraints();
1409 c2.fill = GridBagConstraints.HORIZONTAL;
1412 c2.insets = new Insets(0, 15, 0, 10);
1413 overviewPanel.add(gapLabel, c2);
1415 GridBagConstraints c3 = new GridBagConstraints();
1416 c3.fill = GridBagConstraints.HORIZONTAL;
1419 c3.insets = new Insets(0, 0, 0, 15);
1420 overviewPanel.add(gapColour, c3);
1422 GridBagConstraints c4 = new GridBagConstraints();
1423 c4.fill = GridBagConstraints.HORIZONTAL;
1427 overviewPanel.add(showHiddenAtStart, c4);
1429 GridBagConstraints c5 = new GridBagConstraints();
1430 c5.fill = GridBagConstraints.HORIZONTAL;
1433 c5.insets = new Insets(0, 15, 0, 10);
1434 overviewPanel.add(hiddenLabel, c5);
1436 GridBagConstraints c6 = new GridBagConstraints();
1437 c6.fill = GridBagConstraints.HORIZONTAL;
1440 c6.insets = new Insets(0, 0, 0, 15);
1441 overviewPanel.add(hiddenColour, c6);
1443 JButton resetButton = new JButton(
1444 MessageManager.getString("label.reset_to_defaults"));
1446 resetButton.addActionListener(new ActionListener()
1449 public void actionPerformed(ActionEvent e)
1451 resetOvDefaults_actionPerformed(e);
1455 GridBagConstraints c7 = new GridBagConstraints();
1456 c7.fill = GridBagConstraints.NONE;
1459 c7.insets = new Insets(10, 0, 0, 0);
1460 c7.anchor = GridBagConstraints.WEST;
1461 overviewPanel.add(resetButton, c7);
1463 // Add padding so the panel doesn't look ridiculous
1464 JPanel spacePanel = new JPanel();
1465 overviewPanel.add(spacePanel,
1466 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1467 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1468 new Insets(0, 0, 0, 5), 0, 0));
1470 return overviewPanel;
1474 * Initialises the Structure tabbed panel.
1478 private JPanel initStructureTab()
1480 structureTab = new JPanel();
1482 structureTab.setBorder(new TitledBorder(
1483 MessageManager.getString("label.structure_options")));
1484 structureTab.setLayout(null);
1485 final int width = 420;
1486 final int height = 22;
1487 final int lineSpacing = 25;
1490 structFromPdb.setFont(LABEL_FONT);
1492 .setText(MessageManager.getString("label.struct_from_pdb"));
1493 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1494 structFromPdb.addActionListener(new ActionListener()
1497 public void actionPerformed(ActionEvent e)
1499 boolean selected = structFromPdb.isSelected();
1500 // enable other options only when the first is checked
1501 useRnaView.setEnabled(selected);
1502 addSecondaryStructure.setEnabled(selected);
1503 addTempFactor.setEnabled(selected);
1506 structureTab.add(structFromPdb);
1508 // indent checkboxes that are conditional on the first one
1509 ypos += lineSpacing;
1510 useRnaView.setFont(LABEL_FONT);
1511 useRnaView.setText(MessageManager.getString("label.use_rnaview"));
1512 useRnaView.setBounds(new Rectangle(25, ypos, width, height));
1513 structureTab.add(useRnaView);
1515 ypos += lineSpacing;
1516 addSecondaryStructure.setFont(LABEL_FONT);
1517 addSecondaryStructure
1518 .setText(MessageManager.getString("label.autoadd_secstr"));
1519 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1520 structureTab.add(addSecondaryStructure);
1522 ypos += lineSpacing;
1523 addTempFactor.setFont(LABEL_FONT);
1524 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1525 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1526 structureTab.add(addTempFactor);
1528 ypos += lineSpacing;
1529 JLabel viewerLabel = new JLabel();
1530 viewerLabel.setFont(LABEL_FONT);
1531 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1532 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1533 viewerLabel.setBounds(new Rectangle(10, ypos, 220, height));
1534 structureTab.add(viewerLabel);
1537 * add all external viewers as options here - check
1538 * when selected whether the program is installed
1540 structViewer.setFont(LABEL_FONT);
1541 structViewer.setBounds(new Rectangle(190, ypos, 120, height));
1542 structViewer.addItem(ViewerType.JMOL.name());
1543 structViewer.addItem(ViewerType.CHIMERA.name());
1544 structViewer.addItem(ViewerType.CHIMERAX.name());
1545 structViewer.addItem(ViewerType.PYMOL.name());
1546 structViewer.addActionListener(new ActionListener()
1549 public void actionPerformed(ActionEvent e)
1551 structureViewer_actionPerformed(
1552 (String) structViewer.getSelectedItem());
1555 structureTab.add(structViewer);
1557 ypos += lineSpacing;
1558 structureViewerPathLabel = new JLabel();
1559 structureViewerPathLabel.setFont(LABEL_FONT);// new Font("SansSerif", 0, 11));
1560 structureViewerPathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1561 structureViewerPathLabel.setText(MessageManager
1562 .formatMessage("label.viewer_path", "Chimera(X)"));
1563 structureViewerPathLabel.setBounds(new Rectangle(10, ypos, 170, height));
1564 structureViewerPathLabel.setEnabled(false);
1565 structureTab.add(structureViewerPathLabel);
1567 structureViewerPath.setFont(LABEL_FONT);
1568 structureViewerPath.setText("");
1569 structureViewerPath.setEnabled(false);
1570 final String tooltip = JvSwingUtils.wrapTooltip(true,
1571 MessageManager.getString("label.viewer_path_tip"));
1572 structureViewerPath.setToolTipText(tooltip);
1573 structureViewerPath.setBounds(new Rectangle(190, ypos, 290, height));
1574 structureViewerPath.addMouseListener(new MouseAdapter()
1577 public void mouseClicked(MouseEvent e)
1579 if (structureViewerPath.isEnabled() && e.getClickCount() == 2)
1581 String chosen = openFileChooser();
1584 structureViewerPath.setText(chosen);
1589 structureTab.add(structureViewerPath);
1591 ypos += lineSpacing;
1592 nwMapping.setFont(LABEL_FONT);
1593 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1594 siftsMapping.setFont(LABEL_FONT);
1595 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1596 mappingMethod.add(nwMapping);
1597 mappingMethod.add(siftsMapping);
1598 JPanel mappingPanel = new JPanel();
1599 mappingPanel.setFont(LABEL_FONT);
1600 TitledBorder mmTitledBorder = new TitledBorder(
1601 MessageManager.getString("label.mapping_method"));
1602 mmTitledBorder.setTitleFont(LABEL_FONT);
1603 mappingPanel.setBorder(mmTitledBorder);
1604 mappingPanel.setBounds(new Rectangle(10, ypos, 472, 45));
1605 // GridLayout mappingLayout = new GridLayout();
1606 mappingPanel.setLayout(new GridLayout());
1607 mappingPanel.add(nwMapping);
1608 mappingPanel.add(siftsMapping);
1609 structureTab.add(mappingPanel);
1611 ypos += lineSpacing;
1612 ypos += lineSpacing;
1613 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1614 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1615 docFieldPref.setBounds(new Rectangle(10, ypos, 470, 120));
1616 structureTab.add(docFieldPref);
1619 * hide Chimera options in JalviewJS
1621 if (Platform.isJS())
1623 structureViewerPathLabel.setVisible(false);
1624 structureViewerPath.setVisible(false);
1625 viewerLabel.setVisible(false);
1626 structViewer.setVisible(false);
1629 return structureTab;
1633 * Action on choosing a structure viewer from combobox options.
1635 * @param selectedItem
1637 protected void structureViewer_actionPerformed(String selectedItem)
1642 * Show a dialog for the user to choose a file. Returns the chosen path, or
1647 protected String openFileChooser()
1649 String choice = null;
1650 JFileChooser chooser = new JFileChooser();
1652 // chooser.setFileView(new JalviewFileView());
1653 chooser.setDialogTitle(
1654 MessageManager.getString("label.open_local_file"));
1655 chooser.setToolTipText(MessageManager.getString("action.open"));
1657 int value = chooser.showOpenDialog(this);
1659 if (value == JFileChooser.APPROVE_OPTION)
1661 choice = chooser.getSelectedFile().getPath();
1667 * Validate the structure tab preferences; if invalid, set focus on this tab.
1671 protected boolean validateStructure(FocusEvent e)
1673 if (!validateStructure())
1675 e.getComponent().requestFocusInWindow();
1681 protected boolean validateStructure()
1687 * Initialises the Visual tabbed panel.
1691 private JPanel initVisualTab()
1693 JPanel visualTab = new JPanel();
1694 visualTab.setBorder(new TitledBorder(
1695 MessageManager.getString("action.open_new_alignment")));
1696 visualTab.setLayout(null);
1697 fullScreen.setFont(LABEL_FONT);
1698 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1699 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1700 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1701 quality.setEnabled(false);
1702 quality.setFont(LABEL_FONT);
1703 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1704 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1705 quality.setSelected(true);
1706 quality.setText(MessageManager.getString("label.quality"));
1707 conservation.setEnabled(false);
1708 conservation.setFont(LABEL_FONT);
1709 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1710 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1711 conservation.setSelected(true);
1712 conservation.setText(MessageManager.getString("label.conservation"));
1713 identity.setEnabled(false);
1714 identity.setFont(LABEL_FONT);
1715 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1716 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1717 identity.setSelected(true);
1718 identity.setText(MessageManager.getString("label.consensus"));
1719 showOccupancy.setFont(LABEL_FONT);
1720 showOccupancy.setEnabled(false);
1721 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1722 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1723 showOccupancy.setSelected(true);
1724 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1726 JLabel showGroupbits = new JLabel();
1727 showGroupbits.setFont(LABEL_FONT);
1728 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1729 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1731 .setText(MessageManager.getString("action.show_group") + ":");
1732 JLabel showConsensbits = new JLabel();
1733 showConsensbits.setFont(LABEL_FONT);
1734 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1735 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1737 .setText(MessageManager.getString("label.consensus") + ":");
1738 showConsensHistogram.setEnabled(false);
1739 showConsensHistogram.setFont(LABEL_FONT);
1740 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1741 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1742 showConsensHistogram.setSelected(true);
1743 showConsensHistogram
1744 .setText(MessageManager.getString("label.histogram"));
1745 showConsensLogo.setEnabled(false);
1746 showConsensLogo.setFont(LABEL_FONT);
1747 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1748 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1749 showConsensLogo.setSelected(true);
1750 showConsensLogo.setText(MessageManager.getString("label.logo"));
1751 showGroupConsensus.setEnabled(false);
1752 showGroupConsensus.setFont(LABEL_FONT);
1753 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1754 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1755 showGroupConsensus.setSelected(true);
1756 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1757 showGroupConservation.setEnabled(false);
1758 showGroupConservation.setFont(LABEL_FONT);
1759 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1760 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1761 showGroupConservation.setSelected(true);
1762 showGroupConservation
1763 .setText(MessageManager.getString("label.conservation"));
1764 showNpTooltip.setEnabled(true);
1765 showNpTooltip.setFont(LABEL_FONT);
1766 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1767 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1768 showNpTooltip.setSelected(true);
1769 showNpTooltip.setText(
1770 MessageManager.getString("label.non_positional_features"));
1771 showDbRefTooltip.setEnabled(true);
1772 showDbRefTooltip.setFont(LABEL_FONT);
1773 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1774 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1775 showDbRefTooltip.setSelected(true);
1777 .setText(MessageManager.getString("label.database_references"));
1778 annotations.setFont(LABEL_FONT);
1779 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1780 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1781 annotations.setSelected(true);
1782 annotations.setText(MessageManager.getString("label.show_annotations"));
1783 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1784 annotations.addActionListener(new ActionListener()
1787 public void actionPerformed(ActionEvent e)
1789 annotations_actionPerformed(e);
1792 identity.addActionListener(new ActionListener()
1795 public void actionPerformed(ActionEvent e)
1797 annotations_actionPerformed(e);
1800 showGroupConsensus.addActionListener(new ActionListener()
1803 public void actionPerformed(ActionEvent e)
1805 annotations_actionPerformed(e);
1808 showUnconserved.setFont(LABEL_FONT);
1809 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1810 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1811 showUnconserved.setSelected(true);
1813 .setText(MessageManager.getString("action.show_unconserved"));
1814 showUnconserved.addActionListener(new ActionListener()
1817 public void actionPerformed(ActionEvent e)
1819 showunconserved_actionPerformed(e);
1823 // TODO these are not yet added to / action from Preferences
1824 // JCheckBox shareSelections = new JCheckBox();
1825 // shareSelections.setFont(verdana11);
1826 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1827 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1828 // shareSelections.setSelected(true);
1829 // shareSelections.setText(MessageManager
1830 // .getString("label.share_selection_across_views"));
1831 // JCheckBox followHighlight = new JCheckBox();
1832 // followHighlight.setFont(verdana11);
1833 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1834 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1835 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1836 // followHighlight.setSelected(true);
1837 // followHighlight.setText(MessageManager
1838 // .getString("label.scroll_highlighted_regions"));
1840 seqLimit.setFont(LABEL_FONT);
1841 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1842 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1843 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1844 smoothFont.setFont(LABEL_FONT);
1845 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1846 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1847 smoothFont.setText(MessageManager.getString("label.smooth_font"));
1848 scaleProteinToCdna.setFont(LABEL_FONT);
1849 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1850 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1851 scaleProteinToCdna.setText(
1852 MessageManager.getString("label.scale_protein_to_cdna"));
1853 scaleProteinToCdna.setToolTipText(
1854 MessageManager.getString("label.scale_protein_to_cdna_tip"));
1855 JLabel gapLabel = new JLabel();
1856 gapLabel.setFont(LABEL_FONT);
1857 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1858 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1859 JLabel fontLabel = new JLabel();
1860 fontLabel.setFont(LABEL_FONT);
1861 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1862 fontLabel.setText(MessageManager.getString("label.font"));
1863 fontSizeCB.setFont(LABEL_FONT);
1864 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
1865 fontStyleCB.setFont(LABEL_FONT);
1866 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
1867 fontNameCB.setFont(LABEL_FONT);
1868 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
1869 gapSymbolCB.setFont(LABEL_FONT);
1870 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
1871 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1872 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1873 gapSymbolCB.setRenderer(dlcr);
1875 startupCheckbox.setText(MessageManager.getString("action.open_file"));
1876 startupCheckbox.setFont(LABEL_FONT);
1877 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1878 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1879 startupCheckbox.setSelected(true);
1880 startupFileTextfield.setFont(LABEL_FONT);
1881 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
1882 final String tooltip = JvSwingUtils.wrapTooltip(true,
1883 MessageManager.getString("label.double_click_to_browse"));
1884 startupFileTextfield.setToolTipText(tooltip);
1885 startupFileTextfield.addMouseListener(new MouseAdapter()
1888 public void mouseClicked(MouseEvent e)
1890 if (e.getClickCount() > 1)
1892 startupFileTextfield_mouseClicked();
1897 sortby.setFont(LABEL_FONT);
1898 sortby.setBounds(new Rectangle(172, 260, 155, 21));
1899 JLabel sortLabel = new JLabel();
1900 sortLabel.setFont(LABEL_FONT);
1901 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1902 sortLabel.setText(MessageManager.getString("label.sort_by"));
1903 sortAnnBy.setFont(LABEL_FONT);
1904 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
1905 JLabel sortAnnLabel = new JLabel();
1906 sortAnnLabel.setFont(LABEL_FONT);
1907 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1908 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
1909 sortAutocalc.setFont(LABEL_FONT);
1910 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
1912 JPanel annsettingsPanel = new JPanel();
1913 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
1914 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1915 annsettingsPanel.setBorder(new EtchedBorder());
1916 visualTab.add(annsettingsPanel);
1917 Border jb = new EmptyBorder(1, 1, 4, 5);
1918 annotations.setBorder(jb);
1919 showOccupancy.setBorder(jb);
1920 quality.setBorder(jb);
1921 conservation.setBorder(jb);
1922 identity.setBorder(jb);
1923 showConsensbits.setBorder(jb);
1924 showGroupbits.setBorder(jb);
1925 showGroupConsensus.setBorder(jb);
1926 showGroupConservation.setBorder(jb);
1927 showConsensHistogram.setBorder(jb);
1928 showConsensLogo.setBorder(jb);
1930 JPanel autoAnnotSettings = new JPanel();
1931 annsettingsPanel.add(autoAnnotSettings);
1932 autoAnnotSettings.setLayout(new GridLayout(0, 2));
1933 autoAnnotSettings.add(annotations);
1934 autoAnnotSettings.add(quality);
1935 // second row of autoannotation box
1936 autoAnnotSettings = new JPanel();
1937 annsettingsPanel.add(autoAnnotSettings);
1939 autoAnnotSettings.setLayout(new GridLayout(0, 3));
1940 autoAnnotSettings.add(conservation);
1941 autoAnnotSettings.add(identity);
1942 autoAnnotSettings.add(showOccupancy);
1943 autoAnnotSettings.add(showGroupbits);
1944 autoAnnotSettings.add(showGroupConservation);
1945 autoAnnotSettings.add(showGroupConsensus);
1946 autoAnnotSettings.add(showConsensbits);
1947 autoAnnotSettings.add(showConsensHistogram);
1948 autoAnnotSettings.add(showConsensLogo);
1950 JPanel tooltipSettings = new JPanel();
1951 tooltipSettings.setBorder(new TitledBorder(
1952 MessageManager.getString("label.sequence_id_tooltip")));
1953 tooltipSettings.setBounds(173, 140, 220, 62);
1954 tooltipSettings.setLayout(new GridLayout(2, 1));
1955 tooltipSettings.add(showDbRefTooltip);
1956 tooltipSettings.add(showNpTooltip);
1957 visualTab.add(tooltipSettings);
1959 wrap.setFont(LABEL_FONT);
1960 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
1961 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
1962 wrap.setText(MessageManager.getString("label.wrap_alignment"));
1963 rightAlign.setFont(LABEL_FONT);
1964 rightAlign.setForeground(Color.black);
1965 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
1966 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
1967 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
1968 idItalics.setFont(LABEL_FONT_ITALIC);
1969 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
1970 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
1972 MessageManager.getString("label.sequence_name_italics"));
1973 openoverv.setFont(LABEL_FONT);
1974 openoverv.setActionCommand(
1975 MessageManager.getString("label.open_overview"));
1976 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
1977 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
1978 openoverv.setText(MessageManager.getString("label.open_overview"));
1979 JPanel jPanel2 = new JPanel();
1980 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
1981 jPanel2.setLayout(new GridLayout(14, 1));
1982 jPanel2.add(fullScreen);
1983 jPanel2.add(openoverv);
1984 jPanel2.add(seqLimit);
1985 jPanel2.add(rightAlign);
1986 jPanel2.add(fontLabel);
1987 jPanel2.add(showUnconserved);
1988 jPanel2.add(idItalics);
1989 jPanel2.add(smoothFont);
1990 jPanel2.add(scaleProteinToCdna);
1991 jPanel2.add(gapLabel);
1993 jPanel2.add(sortLabel);
1994 jPanel2.add(sortAnnLabel);
1995 jPanel2.add(startupCheckbox);
1996 visualTab.add(jPanel2);
1997 visualTab.add(startupFileTextfield);
1998 visualTab.add(sortby);
1999 visualTab.add(sortAnnBy);
2000 visualTab.add(sortAutocalc);
2001 visualTab.add(gapSymbolCB);
2002 visualTab.add(fontNameCB);
2003 visualTab.add(fontSizeCB);
2004 visualTab.add(fontStyleCB);
2006 if (Platform.isJS())
2008 startupCheckbox.setVisible(false);
2009 startupFileTextfield.setVisible(false);
2016 * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
2019 protected void loadLastSavedBackupsOptions()
2021 BackupFilesPresetEntry savedPreset = BackupFilesPresetEntry
2022 .getSavedBackupEntry();
2024 .setSelected(Cache.getDefault(BackupFiles.ENABLED, !Platform.isJS()));
2026 BackupFilesPresetEntry backupfilesCustomEntry = BackupFilesPresetEntry
2027 .createBackupFilesPresetEntry(Cache
2028 .getDefault(BackupFilesPresetEntry.CUSTOMCONFIG, null));
2029 if (backupfilesCustomEntry == null)
2031 backupfilesCustomEntry = BackupFilesPresetEntry.backupfilesPresetEntriesValues
2032 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT);
2034 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
2035 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM,
2036 backupfilesCustomEntry);
2038 setComboIntStringKey(backupfilesPresetsCombo,
2039 Cache.getDefault(BackupFiles.NS + "_PRESET",
2040 BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT));
2042 backupsSetOptions(savedPreset);
2044 backupsOptionsSetEnabled();
2045 updateBackupFilesExampleLabel();
2048 private boolean warnAboutSuffixReverseChange()
2050 BackupFilesPresetEntry bfpe = BackupFilesPresetEntry
2051 .getSavedBackupEntry();
2052 boolean savedSuffixReverse = bfpe.reverse;
2053 int savedSuffixDigits = bfpe.digits;
2054 String savedSuffixTemplate = bfpe.suffix;
2056 boolean nowSuffixReverse = suffixReverse.isSelected();
2057 int nowSuffixDigits = getSpinnerInt(suffixDigitsSpinner, 3);
2058 String nowSuffixTemplate = suffixTemplate.getText();
2059 return nowSuffixReverse != savedSuffixReverse
2060 && nowSuffixDigits == savedSuffixDigits
2061 && nowSuffixTemplate != null
2062 && nowSuffixTemplate.equals(savedSuffixTemplate);
2066 * Initialises the Backups tabbed panel.
2070 private JPanel initBackupsTab()
2072 JPanel backupsTab = new JPanel();
2073 backupsTab.setBorder(new TitledBorder(
2074 MessageManager.getString("label.backup_files")));
2075 backupsTab.setLayout(new GridBagLayout());
2077 GridBagConstraints gbc = new GridBagConstraints();
2080 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2081 gbc.fill = GridBagConstraints.NONE;
2083 initBackupsTabPresetsPanel();
2084 initBackupsTabSuffixPanel();
2085 initBackupsTabKeepFilesPanel();
2086 initBackupsTabFilenameExamplesPanel();
2088 enableBackupFiles.setFont(LABEL_FONT_BOLD);
2090 .setText(MessageManager.getString("label.enable_backupfiles"));
2091 enableBackupFiles.addActionListener(new ActionListener()
2094 public void actionPerformed(ActionEvent e)
2096 // enable other options only when the first is checked
2097 backupsOptionsSetEnabled();
2102 // enable checkbox 1 col
2106 gbc.gridy = 0; // row 0
2107 backupsTab.add(enableBackupFiles, gbc);
2109 // summary of scheme box (over two rows)
2113 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
2114 gbc.fill = GridBagConstraints.BOTH;
2115 backupsTab.add(exampleFilesPanel, gbc);
2117 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2118 gbc.fill = GridBagConstraints.NONE;
2120 // fill empty space on right
2123 backupsTab.add(new JPanel(), gbc);
2128 gbc.gridy++; // row 1
2129 backupsTab.add(presetsPanel, gbc);
2131 // now using whole row
2136 gbc.gridy++; // row 2
2137 backupsTab.add(keepfilesPanel, gbc);
2139 // filename strategy box
2140 gbc.gridy++; // row 3
2141 backupsTab.add(suffixPanel, gbc);
2144 gbc.gridy++; // row 4
2146 backupsTab.add(new JPanel(), gbc);
2148 backupsOptionsSetEnabled();
2152 private JPanel initBackupsTabPresetsPanel()
2155 String title = MessageManager.getString("label.schemes");
2157 presetsPanel.setLayout(new GridBagLayout());
2159 GridBagConstraints gbc = new GridBagConstraints();
2162 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
2163 gbc.fill = GridBagConstraints.NONE;
2171 presetsComboLabel = new JLabel(title + ":");
2172 presetsPanel.add(presetsComboLabel, gbc);
2174 List<Object> entries = Arrays
2175 .asList((Object[]) BackupFilesPresetEntry.backupfilesPresetEntries);
2176 List<String> tooltips = Arrays.asList(
2177 BackupFilesPresetEntry.backupfilesPresetEntryDescriptions);
2178 backupfilesPresetsCombo = JvSwingUtils.buildComboWithTooltips(entries,
2181 for (int i = 0; i < BackupFilesPresetEntry.backupfilesPresetEntries.length; i++)
2183 backupfilesPresetsCombo
2184 .addItem(BackupFilesPresetEntry.backupfilesPresetEntries[i]);
2188 backupfilesPresetsCombo.addActionListener(new ActionListener()
2191 public void actionPerformed(ActionEvent e)
2193 int key = getComboIntStringKey(backupfilesPresetsCombo);
2194 if (!customiseCheckbox.isSelected())
2196 backupfilesPresetsComboLastSelected = key;
2198 if (key == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
2200 if (customiseCheckbox.isSelected())
2202 // got here by clicking on customiseCheckbox so don't change the values
2203 backupfilesCustomOptionsSetEnabled();
2207 backupsTabUpdatePresets();
2208 backupfilesCustomOptionsSetEnabled();
2213 customiseCheckbox.setSelected(false);
2214 backupsTabUpdatePresets();
2215 backupfilesCustomOptionsSetEnabled();
2220 // dropdown list of preset schemes
2222 presetsPanel.add(backupfilesPresetsCombo, gbc);
2224 revertButton.setText(MessageManager.getString("label.cancel_changes"));
2225 revertButton.setToolTipText(
2226 MessageManager.getString("label.cancel_changes_description"));
2227 revertButton.addActionListener(new ActionListener()
2230 public void actionPerformed(ActionEvent e)
2233 BackupFilesPresetEntry.backupfilesPresetEntriesValues.get(
2234 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM));
2235 backupfilesCustomOptionsSetEnabled();
2239 revertButton.setFont(LABEL_FONT);
2241 customiseCheckbox.setFont(LABEL_FONT);
2242 customiseCheckbox.setText(MessageManager.getString("label.customise"));
2243 customiseCheckbox.addActionListener(new ActionListener()
2246 public void actionPerformed(ActionEvent e)
2248 int currently = getComboIntStringKey(backupfilesPresetsCombo);
2249 if (customiseCheckbox.isSelected())
2251 backupfilesPresetsComboLastSelected = currently;
2252 setComboIntStringKey(backupfilesPresetsCombo,
2253 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2257 setComboIntStringKey(backupfilesPresetsCombo,
2258 backupfilesPresetsComboLastSelected);
2261 backupfilesCustomOptionsSetEnabled();
2264 customiseCheckbox.setToolTipText(
2265 MessageManager.getString("label.customise_description"));
2267 // customise checkbox
2270 presetsPanel.add(customiseCheckbox, gbc);
2272 // "Cancel changes" button (aligned with combo box above)
2274 presetsPanel.add(revertButton, gbc);
2276 return presetsPanel;
2279 private JPanel initBackupsTabFilenameExamplesPanel()
2281 String title = MessageManager
2282 .getString("label.scheme_examples");
2283 TitledBorder tb = new TitledBorder(title);
2284 exampleFilesPanel.setBorder(tb);
2285 exampleFilesPanel.setLayout(new GridBagLayout());
2288 backupfilesExampleLabel.setEditable(false);
2289 backupfilesExampleLabel
2290 .setBackground(exampleFilesPanel.getBackground());
2292 updateBackupFilesExampleLabel();
2294 GridBagConstraints gbc = new GridBagConstraints();
2297 gbc.fill = GridBagConstraints.NONE;
2298 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2300 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
2301 return exampleFilesPanel;
2304 private void backupsTabUpdatePresets()
2306 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
2309 String value = entry.v;
2311 if (BackupFilesPresetEntry.backupfilesPresetEntriesValues
2315 BackupFilesPresetEntry.backupfilesPresetEntriesValues
2321 "Preset '" + value + "' [key:" + key + "] not implemented");
2324 // Custom options will now be enabled when the customiseCheckbox is checked
2325 // (performed above)
2326 // backupfilesCustomOptionsSetEnabled();
2327 updateBackupFilesExampleLabel();
2330 protected int getComboIntStringKey(
2331 JComboBox<Object> backupfilesPresetsCombo2)
2333 IntKeyStringValueEntry e;
2336 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2
2338 } catch (Exception ex)
2341 "Problem casting Combo entry to IntKeyStringValueEntry.");
2344 return e != null ? e.k : 0;
2347 protected void setComboIntStringKey(
2348 JComboBox<Object> backupfilesPresetsCombo2,
2351 for (int i = 0; i < backupfilesPresetsCombo2.getItemCount(); i++)
2353 IntKeyStringValueEntry e;
2356 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2.getItemAt(i);
2357 } catch (Exception ex)
2360 "Problem casting Combo entry to IntKeyStringValueEntry. Skipping item. ");
2365 backupfilesPresetsCombo2.setSelectedIndex(i);
2369 // backupsTabUpdatePresets();
2372 private JPanel initBackupsTabSuffixPanel()
2374 suffixPanel.setBorder(new TitledBorder(
2375 MessageManager.getString("label.backup_filename_strategy")));
2376 suffixPanel.setLayout(new GridBagLayout());
2379 .setText(MessageManager.getString("label.append_to_filename"));
2380 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
2381 suffixTemplateLabel.setFont(LABEL_FONT);
2383 final String tooltip = JvSwingUtils.wrapTooltip(true,
2384 MessageManager.getString("label.append_to_filename_tooltip"));
2385 suffixTemplate.setToolTipText(tooltip);
2386 suffixTemplate.addActionListener(new ActionListener()
2389 public void actionPerformed(ActionEvent e)
2391 updateBackupFilesExampleLabel();
2392 backupfilesCustomOptionsSetEnabled();
2393 backupfilesRevertButtonSetEnabled(true);
2397 suffixTemplate.addKeyListener(new KeyListener()
2400 public void keyReleased(KeyEvent e)
2402 updateBackupFilesExampleLabel();
2403 backupfilesCustomOptionsSetEnabled();
2404 backupfilesRevertButtonSetEnabled(true);
2408 public void keyPressed(KeyEvent e)
2412 // disable use of ':' or '/' or '\'
2414 public void keyTyped(KeyEvent e)
2416 char c = e.getKeyChar();
2417 if (c == ':' || c == '/' || c == '\\')
2419 // don't process ':' or '/' or '\'
2428 .setText(MessageManager.getString("label.index_digits"));
2429 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
2430 suffixDigitsLabel.setFont(LABEL_FONT);
2431 ChangeListener c = new ChangeListener()
2434 public void stateChanged(ChangeEvent e)
2436 backupfilesRevertButtonSetEnabled(true);
2437 updateBackupFilesExampleLabel();
2441 setIntegerSpinner(suffixDigitsSpinner, BackupFilesPresetEntry.DIGITSMIN,
2442 BackupFilesPresetEntry.DIGITSMAX, 3, c);
2444 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
2445 MessageManager.getString("label.increment_index"));
2446 suffixReverse.addActionListener(new ActionListener()
2449 public void actionPerformed(ActionEvent e)
2451 boolean okay = true;
2452 if (warnAboutSuffixReverseChange())
2455 okay = confirmSuffixReverseChange();
2459 backupfilesRevertButtonSetEnabled(true);
2460 updateBackupFilesExampleLabel();
2464 boolean savedSuffixReverse = BackupFilesPresetEntry
2465 .getSavedBackupEntry().reverse;
2466 suffixReverse.setSelected(savedSuffixReverse);
2471 GridBagConstraints sgbc = new GridBagConstraints();
2473 // first row (template text box)
2474 sgbc.anchor = GridBagConstraints.WEST;
2478 sgbc.gridheight = 1;
2481 sgbc.fill = GridBagConstraints.NONE;
2482 suffixPanel.add(suffixTemplateLabel, sgbc);
2485 sgbc.fill = GridBagConstraints.HORIZONTAL;
2486 suffixPanel.add(suffixTemplate, sgbc);
2488 // second row (number of digits spinner)
2492 sgbc.fill = GridBagConstraints.NONE;
2493 suffixPanel.add(suffixDigitsLabel, sgbc);
2496 sgbc.fill = GridBagConstraints.HORIZONTAL;
2497 suffixPanel.add(suffixDigitsSpinner, sgbc);
2499 // third row (forward order radio selection)
2502 sgbc.gridwidth = GridBagConstraints.REMAINDER;
2503 sgbc.fill = GridBagConstraints.HORIZONTAL;
2504 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
2506 // fourth row (reverse order radio selection)
2508 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
2512 private boolean confirmSuffixReverseChange()
2514 boolean ret = false;
2515 String warningMessage = MessageManager
2516 .getString("label.warning_confirm_change_reverse");
2517 int confirm = JvOptionPane.showConfirmDialog(Desktop.desktop,
2519 MessageManager.getString("label.change_increment_decrement"),
2520 JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE);
2522 ret = (confirm == JvOptionPane.YES_OPTION);
2526 private JPanel initBackupsTabKeepFilesPanel()
2528 keepfilesPanel.setBorder(
2529 new TitledBorder(MessageManager.getString("label.keep_files")));
2530 keepfilesPanel.setLayout(new GridBagLayout());
2532 backupfilesKeepAll.setLabels(
2533 MessageManager.getString("label.keep_all_backup_files"),
2534 MessageManager.getString(
2535 "label.keep_only_this_number_of_backup_files"));
2536 backupfilesKeepAll.addTrueActionListener(new ActionListener()
2539 public void actionPerformed(ActionEvent e)
2541 backupfilesRevertButtonSetEnabled(true);
2542 updateBackupFilesExampleLabel();
2545 backupfilesKeepAll.addActionListener(new ActionListener()
2548 public void actionPerformed(ActionEvent e)
2550 backupfilesRevertButtonSetEnabled(true);
2551 keepRollMaxOptionsEnabled();
2552 updateBackupFilesExampleLabel();
2556 ChangeListener c = new ChangeListener()
2559 public void stateChanged(ChangeEvent e)
2561 backupfilesRevertButtonSetEnabled(true);
2562 updateBackupFilesExampleLabel();
2566 setIntegerSpinner(backupfilesRollMaxSpinner,
2567 BackupFilesPresetEntry.ROLLMAXMIN,
2568 BackupFilesPresetEntry.ROLLMAXMAX, 4, true, c);
2570 backupfilesConfirmDelete.setLabels(
2571 MessageManager.getString("label.always_ask"),
2572 MessageManager.getString("label.auto_delete"));
2573 backupfilesConfirmDelete.addActionListener(new ActionListener()
2576 public void actionPerformed(ActionEvent e)
2578 backupfilesRevertButtonSetEnabled(true);
2581 // update the enabled section
2582 keepRollMaxOptionsEnabled();
2584 GridBagConstraints kgbc = new GridBagConstraints();
2586 // first row (template text box)
2587 kgbc.anchor = GridBagConstraints.WEST;
2590 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2591 kgbc.gridheight = 1;
2594 kgbc.fill = GridBagConstraints.HORIZONTAL;
2595 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
2601 kgbc.gridwidth = GridBagConstraints.RELATIVE;
2602 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
2605 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2606 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
2608 // third row (indented)
2610 kgbc.insets = new Insets(0, 20, 0, 0);
2613 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2614 kgbc.fill = GridBagConstraints.HORIZONTAL;
2617 JPanel jp = new JPanel();
2618 jp.setLayout(new FlowLayout());
2620 .setText(MessageManager
2621 .getString("label.autodelete_old_backup_files"));
2622 oldBackupFilesLabel.setFont(LABEL_FONT);
2623 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
2624 jp.add(oldBackupFilesLabel);
2625 jp.add(backupfilesConfirmDelete.getTrueButton());
2626 jp.add(backupfilesConfirmDelete.getFalseButton());
2627 keepfilesPanel.add(jp, kgbc);
2629 return keepfilesPanel;
2632 protected void updateBackupFilesExampleLabel()
2634 int exampleindex = 12;
2635 String base = MessageManager.getString("label.filename") + ".fa";
2636 if (base == null || base.length() == 0)
2638 base = "file_name.fa";
2641 boolean reverse = suffixReverse.isSelected();
2642 boolean keepAll = backupfilesKeepAll.isSelected();
2644 String suffix = suffixTemplate.getText();
2647 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
2648 if (suffix == null || suffix.length() == 0)
2650 backupfilesExampleLabel
2651 .setText(MessageManager.getString("label.no_backup_files"));
2652 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
2656 rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 4);
2657 rollMax = rollMax < 1 ? 1 : rollMax;
2659 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
2664 digits = getSpinnerInt(suffixDigitsSpinner, 3);
2665 digits = digits < 1 ? 1 : digits;
2667 int lowersurround = 2;
2668 int uppersurround = 0;
2669 StringBuilder exampleSB = new StringBuilder();
2670 boolean firstLine = true;
2676 int max = keepAll ? exampleindex : rollMax;
2677 for (int index = min; index <= max; index++)
2679 if (index == min + lowersurround && index < max - uppersurround - 1)
2681 exampleSB.append("\n...");
2684 else if (index > min + lowersurround && index < max - uppersurround)
2696 exampleSB.append("\n");
2699 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2700 base, suffix, digits));
2703 // no extra text needed
2705 else if (index == min)
2707 String newest = MessageManager.getString("label.braced_newest");
2708 if (newest != null && newest.length() > 0)
2710 exampleSB.append(" " + newest);
2713 else if (index == max)
2715 String oldest = MessageManager.getString("label.braced_oldest");
2716 if (oldest != null && oldest.length() > 0)
2718 exampleSB.append(" " + oldest);
2727 int min = (keepAll || exampleindex - rollMax < 0) ? 1
2728 : exampleindex - rollMax + 1;
2729 int max = exampleindex;
2731 for (int index = min; index <= max; index++)
2734 if (index == min + lowersurround && index < max - uppersurround - 1)
2736 exampleSB.append("\n...");
2739 else if (index > min + lowersurround && index < max - uppersurround)
2751 exampleSB.append("\n");
2754 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2755 base, suffix, digits));
2758 // no extra text needed
2760 else if (index == min)
2762 String oldest = MessageManager.getString("label.braced_oldest");
2763 if (oldest != null && oldest.length() > 0)
2765 exampleSB.append(" " + oldest);
2768 else if (index == max)
2770 String newest = MessageManager.getString("label.braced_newest");
2771 if (newest != null && newest.length() > 0)
2773 exampleSB.append(" " + newest);
2781 // add some extra empty lines to pad out the example files box. ugh, please tell
2782 // me how to do this better
2783 int remainingLines = lowersurround + uppersurround + 1 - lineNumber;
2784 if (remainingLines > 0)
2786 for (int i = 0; i < remainingLines; i++)
2788 exampleSB.append("\n ");
2793 backupfilesExampleLabel.setText(exampleSB.toString());
2796 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2797 boolean useExistingVal, ChangeListener c)
2804 i = ((Integer) s.getValue()).intValue();
2805 } catch (Exception e)
2808 "Exception casting the initial value of s.getValue()");
2812 setIntegerSpinner(s, min, max, i, c);
2815 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2818 // integer spinner for number of digits
2827 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
2830 s.addChangeListener(c);
2834 protected static int getSpinnerInt(JSpinner s, int def)
2840 i = (Integer) s.getValue();
2841 } catch (Exception e)
2843 Cache.log.error("Failed casting (Integer) JSpinner s.getValue()");
2848 private void keepRollMaxOptionsEnabled()
2850 boolean enabled = backupfilesKeepAll.isEnabled()
2851 && !backupfilesKeepAll.isSelected();
2852 oldBackupFilesLabel.setEnabled(enabled);
2853 backupfilesRollMaxSpinner.setEnabled(enabled);
2854 backupfilesConfirmDelete.setEnabled(enabled);
2857 private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
2859 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2860 && customiseCheckbox.isSelected()
2861 && suffixTemplate.getText()
2862 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2863 keepfilesPanel.setEnabled(enabled);
2864 backupfilesKeepAll.setEnabled(enabled);
2865 oldBackupFilesLabel.setEnabled(enabled);
2866 keepRollMaxOptionsEnabled();
2869 private void backupfilesSuffixTemplateDigitsSetEnabled()
2871 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
2872 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2873 suffixDigitsLabel.setEnabled(enabled);
2874 suffixDigitsSpinner.setEnabled(enabled);
2875 suffixReverse.setEnabled(enabled);
2878 private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
2880 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2881 && customiseCheckbox.isSelected();
2882 suffixPanel.setEnabled(enabled);
2883 suffixTemplateLabel.setEnabled(enabled);
2884 suffixTemplate.setEnabled(enabled);
2885 backupfilesSuffixTemplateDigitsSetEnabled();
2888 private void backupfilesRevertButtonSetEnabled(boolean tryEnabled)
2890 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2891 && customiseCheckbox.isSelected() && backupfilesCustomChanged();
2892 revertButton.setEnabled(enabled);
2895 private boolean backupfilesCustomChanged()
2897 BackupFilesPresetEntry custom = BackupFilesPresetEntry.backupfilesPresetEntriesValues
2898 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2899 BackupFilesPresetEntry current = getBackupfilesCurrentEntry();
2900 return !custom.equals(current);
2903 protected BackupFilesPresetEntry getBackupfilesCurrentEntry()
2905 String suffix = suffixTemplate.getText();
2906 int digits = getSpinnerInt(suffixDigitsSpinner, 3);
2907 boolean reverse = suffixReverse.isSelected();
2908 boolean keepAll = backupfilesKeepAll.isSelected();
2909 int rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 3);
2910 boolean confirmDelete = backupfilesConfirmDelete.isSelected();
2912 BackupFilesPresetEntry bfpe = new BackupFilesPresetEntry(suffix, digits,
2913 reverse, keepAll, rollMax, confirmDelete);
2918 protected void backupfilesCustomOptionsSetEnabled()
2920 boolean enabled = customiseCheckbox.isSelected();
2922 backupfilesRevertButtonSetEnabled(enabled);
2923 backupfilesSuffixTemplateSetEnabled(enabled);
2924 backupfilesKeepAllSetEnabled(enabled);
2927 private void backupfilesSummarySetEnabled()
2929 boolean enabled = enableBackupFiles.isSelected();
2930 backupfilesExampleLabel.setEnabled(enabled);
2931 exampleFilesPanel.setEnabled(enabled);
2934 private void backupfilesPresetsSetEnabled()
2936 boolean enabled = enableBackupFiles.isSelected();
2937 presetsPanel.setEnabled(enabled);
2938 presetsComboLabel.setEnabled(enabled);
2939 backupfilesPresetsCombo.setEnabled(enabled);
2940 customiseCheckbox.setEnabled(enabled);
2941 revertButton.setEnabled(enabled);
2944 protected void backupsOptionsSetEnabled()
2946 backupfilesPresetsSetEnabled();
2947 backupfilesSummarySetEnabled();
2948 backupfilesCustomOptionsSetEnabled();
2951 protected void backupsSetOptions(String suffix, int digits,
2952 boolean reverse, boolean keepAll, int rollMax,
2953 boolean confirmDelete)
2955 suffixTemplate.setText(suffix);
2956 suffixDigitsSpinner.setValue(digits);
2957 suffixReverse.setSelected(reverse);
2958 backupfilesKeepAll.setSelected(keepAll);
2959 backupfilesRollMaxSpinner.setValue(rollMax);
2960 backupfilesConfirmDelete.setSelected(confirmDelete);
2963 protected void backupsSetOptions(BackupFilesPresetEntry p)
2965 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
2969 protected void autoIdWidth_actionPerformed()
2971 // TODO Auto-generated method stub
2975 protected void userIdWidth_actionPerformed()
2977 // TODO Auto-generated method stub
2981 protected void maxColour_actionPerformed(JPanel panel)
2985 protected void minColour_actionPerformed(JPanel panel)
2989 protected void gapColour_actionPerformed(JPanel panel)
2993 protected void hiddenColour_actionPerformed(JPanel panel)
2997 protected void showunconserved_actionPerformed(ActionEvent e)
2999 // TODO Auto-generated method stub
3003 protected void useLegacyGaps_actionPerformed(ActionEvent e)
3007 protected void resetOvDefaults_actionPerformed(ActionEvent e)
3017 public void ok_actionPerformed(ActionEvent e)
3027 public void cancel_actionPerformed(ActionEvent e)
3037 public void annotations_actionPerformed(ActionEvent e)
3044 public void startupFileTextfield_mouseClicked()
3048 public void newLink_actionPerformed(ActionEvent e)
3053 public void editLink_actionPerformed(ActionEvent e)
3058 public void deleteLink_actionPerformed(ActionEvent e)
3063 public void defaultBrowser_mouseClicked(MouseEvent e)
3068 public void linkURLList_keyTyped(KeyEvent e)
3073 public void setProxyAuthEnabled()
3075 boolean enabled = proxyAuth.isSelected() && proxyAuth.isEnabled();
3076 proxyAuthUsernameLabel.setEnabled(enabled);
3077 proxyAuthPasswordLabel.setEnabled(enabled);
3078 passwordNotStoredLabel.setEnabled(enabled);
3079 proxyAuthUsernameTB.setEnabled(enabled);
3080 proxyAuthPasswordTB.setEnabled(enabled);
3083 public void setCustomProxyEnabled()
3085 boolean enabled = customProxy.isSelected();
3086 portLabel.setEnabled(enabled);
3087 serverLabel.setEnabled(enabled);
3088 portLabel2.setEnabled(enabled);
3089 serverLabel2.setEnabled(enabled);
3090 httpLabel.setEnabled(enabled);
3091 httpsLabel.setEnabled(enabled);
3092 proxyServerHttpTB.setEnabled(enabled);
3093 proxyPortHttpTB.setEnabled(enabled);
3094 proxyServerHttpsTB.setEnabled(enabled);
3095 proxyPortHttpsTB.setEnabled(enabled);
3096 proxyAuth.setEnabled(enabled);
3097 setProxyAuthEnabled();
3100 public void proxyType_actionPerformed()
3102 setCustomProxyEnabled();
3105 public void proxyAuth_actionPerformed()
3107 setProxyAuthEnabled();
3111 * Customer renderer for JTable: supports column of radio buttons
3113 public class RadioButtonRenderer extends JRadioButton
3114 implements TableCellRenderer
3116 public RadioButtonRenderer()
3118 setHorizontalAlignment(CENTER);
3119 setToolTipText(MessageManager.getString("label.urltooltip"));
3123 public Component getTableCellRendererComponent(JTable table,
3124 Object value, boolean isSelected, boolean hasFocus, int row,
3127 setSelected((boolean) value);
3129 // set colours to match rest of table
3132 setBackground(table.getSelectionBackground());
3133 setForeground(table.getSelectionForeground());
3137 setBackground(table.getBackground());
3138 setForeground(table.getForeground());
3145 * Customer cell editor for JTable: supports column of radio buttons in
3146 * conjunction with renderer
3148 public class RadioButtonEditor extends AbstractCellEditor
3149 implements TableCellEditor
3151 private JRadioButton button = new JRadioButton();
3153 public RadioButtonEditor()
3155 button.setHorizontalAlignment(SwingConstants.CENTER);
3156 this.button.addActionListener(new ActionListener()
3159 public void actionPerformed(ActionEvent e)
3161 fireEditingStopped();
3167 public Component getTableCellEditorComponent(JTable table, Object value,
3168 boolean isSelected, int row, int column)
3170 button.setSelected((boolean) value);
3175 public Object getCellEditorValue()
3177 return button.isSelected();