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)
386 new GPreferences(selectTab, null);
389 public GPreferences(int selectTab, String message)
393 jbInit(selectTab, message);
394 } catch (Exception ex)
396 ex.printStackTrace();
401 * Construct the panel and its tabbed sub-panels.
405 private void jbInit() throws Exception
410 private void jbInit(int selectTab) throws Exception
412 jbInit(selectTab, null);
415 public final static int CONNECTIONS_TAB = 5;
417 private void jbInit(int selectTab, String message) throws Exception
419 final JTabbedPane tabbedPane = new JTabbedPane();
420 this.setLayout(new BorderLayout());
424 JLabel messageLabel = new JLabel(message, JLabel.CENTER);
425 messageLabel.setFont(LABEL_FONT_BOLD);
426 messageLabel.setForeground(Color.RED.darker());
427 this.add(messageLabel, BorderLayout.NORTH);
430 JPanel okCancelPanel = initOkCancelPanel();
431 this.add(tabbedPane, BorderLayout.CENTER);
432 this.add(okCancelPanel, BorderLayout.SOUTH);
434 tabbedPane.add(initVisualTab(),
435 MessageManager.getString("label.visual"));
437 tabbedPane.add(initColoursTab(),
438 MessageManager.getString("label.colours"));
440 tabbedPane.add(initOverviewTab(),
441 MessageManager.getString("label.overview"));
443 tabbedPane.add(initStructureTab(),
444 MessageManager.getString("label.structure"));
446 tabbedPane.add(initConnectionsTab(),
447 MessageManager.getString("label.connections"));
449 if (!Platform.isJS())
451 tabbedPane.add(initBackupsTab(),
452 MessageManager.getString("label.backups"));
455 tabbedPane.add(initLinksTab(),
456 MessageManager.getString("label.urllinks"));
458 tabbedPane.add(initOutputTab(),
459 MessageManager.getString("label.output"));
461 tabbedPane.add(initEditingTab(),
462 MessageManager.getString("label.editing"));
465 * See WsPreferences for the real work of configuring this tab.
467 if (!Platform.isJS())
469 wsTab.setLayout(new BorderLayout());
470 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
474 * Handler to validate a tab before leaving it - currently only for
477 tabbedPane.addChangeListener(new ChangeListener()
479 private Component lastTab;
482 public void stateChanged(ChangeEvent e)
484 if (lastTab == structureTab
485 && tabbedPane.getSelectedComponent() != structureTab)
487 if (!validateStructure())
489 tabbedPane.setSelectedComponent(structureTab);
493 lastTab = tabbedPane.getSelectedComponent();
498 // select a given tab - currently only for Connections
501 case CONNECTIONS_TAB:
502 tabbedPane.setSelectedComponent(connectTab);
510 * Initialises the Editing tabbed panel.
514 private JPanel initEditingTab()
516 JPanel editingTab = new JPanel();
517 editingTab.setLayout(null);
518 autoCalculateConsCheck.setFont(LABEL_FONT);
519 autoCalculateConsCheck.setText(
520 MessageManager.getString("label.autocalculate_consensus"));
521 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
522 padGaps.setFont(LABEL_FONT);
524 MessageManager.getString("label.pad_gaps_when_editing"));
525 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
526 sortByTree.setFont(LABEL_FONT);
528 .setText(MessageManager.getString("label.sort_with_new_tree"));
529 sortByTree.setToolTipText(MessageManager.getString(
530 "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
531 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
532 editingTab.add(autoCalculateConsCheck);
533 editingTab.add(padGaps);
534 editingTab.add(sortByTree);
539 * Initialises the Output tab
543 private JPanel initOutputTab()
545 JPanel outputTab = new JPanel();
546 outputTab.setLayout(null);
548 JLabel epsLabel = new JLabel(
549 MessageManager.formatMessage("label.rendering_style", "EPS"));
550 epsLabel.setFont(LABEL_FONT);
551 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
552 epsLabel.setBounds(new Rectangle(9, 31, 160, 24));
553 epsRendering.setFont(LABEL_FONT);
554 epsRendering.setBounds(new Rectangle(174, 34, 187, 21));
555 JLabel htmlLabel = new JLabel(
556 MessageManager.formatMessage("label.rendering_style", "HTML"));
557 htmlLabel.setFont(LABEL_FONT);
558 htmlLabel.setHorizontalAlignment(SwingConstants.RIGHT);
559 htmlLabel.setBounds(new Rectangle(9, 55, 160, 24));
560 htmlRendering.setFont(LABEL_FONT);
561 htmlRendering.setBounds(new Rectangle(174, 58, 187, 21));
562 JLabel svgLabel = new JLabel(
563 MessageManager.formatMessage("label.rendering_style", "SVG"));
564 svgLabel.setFont(LABEL_FONT);
565 svgLabel.setHorizontalAlignment(SwingConstants.RIGHT);
566 svgLabel.setBounds(new Rectangle(9, 79, 160, 24));
567 svgRendering.setFont(LABEL_FONT);
568 svgRendering.setBounds(new Rectangle(174, 82, 187, 21));
570 JLabel jLabel1 = new JLabel();
571 jLabel1.setFont(LABEL_FONT);
572 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
573 jLabel1.setText(MessageManager.getString("label.append_start_end"));
574 jLabel1.setFont(LABEL_FONT);
576 fastajv.setFont(LABEL_FONT);
577 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
578 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
579 blcjv.setText(MessageManager.getString("label.blc") + " ");
580 fastajv.setText(MessageManager.getString("label.fasta") + " ");
581 msfjv.setText(MessageManager.getString("label.msf") + " ");
582 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
583 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
584 msfjv.setFont(LABEL_FONT);
585 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
586 pirjv.setText(MessageManager.getString("label.pir") + " ");
587 JPanel jPanel11 = new JPanel();
588 jPanel11.setFont(LABEL_FONT);
589 TitledBorder titledBorder2 = new TitledBorder(
590 MessageManager.getString("label.file_output"));
591 jPanel11.setBorder(titledBorder2);
592 jPanel11.setBounds(new Rectangle(30, 120, 196, 182));
593 GridLayout gridLayout3 = new GridLayout();
594 jPanel11.setLayout(gridLayout3);
595 gridLayout3.setRows(8);
596 blcjv.setFont(LABEL_FONT);
597 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
598 clustaljv.setFont(LABEL_FONT);
599 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
600 pfamjv.setFont(LABEL_FONT);
601 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
602 pileupjv.setFont(LABEL_FONT);
603 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
604 pirjv.setFont(LABEL_FONT);
605 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
606 autoIdWidth.setFont(LABEL_FONT);
608 MessageManager.getString("label.automatically_set_id_width"));
609 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
610 .getString("label.adjusts_width_generated_eps_png")));
611 autoIdWidth.setBounds(new Rectangle(228, 144, 320, 23));
612 autoIdWidth.addActionListener(new ActionListener()
616 public void actionPerformed(ActionEvent e)
618 autoIdWidth_actionPerformed();
621 userIdWidthlabel.setFont(LABEL_FONT);
622 userIdWidthlabel.setText(
623 MessageManager.getString("label.figure_id_column_width"));
624 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
625 .getString("label.manually_specify_width_left_column")));
626 userIdWidthlabel.setToolTipText(
627 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
628 "label.manually_specify_width_left_column")));
629 userIdWidthlabel.setBounds(new Rectangle(236, 168, 320, 23));
630 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
631 userIdWidth.setText("");
632 userIdWidth.setBounds(new Rectangle(232, 192, 84, 23));
633 userIdWidth.addActionListener(new ActionListener()
637 public void actionPerformed(ActionEvent e)
639 userIdWidth_actionPerformed();
642 modellerOutput.setFont(LABEL_FONT);
644 .setText(MessageManager.getString("label.use_modeller_output"));
645 modellerOutput.setBounds(new Rectangle(228, 274, 320, 23));
646 embbedBioJSON.setFont(LABEL_FONT);
647 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
648 embbedBioJSON.setBounds(new Rectangle(228, 248, 250, 23));
650 jPanel11.add(jLabel1);
652 jPanel11.add(clustaljv);
653 jPanel11.add(fastajv);
655 jPanel11.add(pfamjv);
656 jPanel11.add(pileupjv);
658 outputTab.add(autoIdWidth);
659 outputTab.add(userIdWidth);
660 outputTab.add(userIdWidthlabel);
661 outputTab.add(modellerOutput);
662 if (!Platform.isJS())
665 * JalviewJS doesn't support Lineart option or SVG output
667 outputTab.add(embbedBioJSON);
668 outputTab.add(epsLabel);
669 outputTab.add(epsRendering);
670 outputTab.add(htmlLabel);
671 outputTab.add(htmlRendering);
672 outputTab.add(svgLabel);
673 outputTab.add(svgRendering);
675 outputTab.add(jPanel11);
680 * Initialises the Connections tabbed panel.
684 private JPanel initConnectionsTab()
686 connectTab = new JPanel();
687 connectTab.setLayout(new GridBagLayout());
689 // Label for browser text box
690 JLabel browserLabel = new JLabel();
691 browserLabel.setFont(LABEL_FONT);
692 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
693 browserLabel.setText(
694 MessageManager.getString("label.default_browser_unix"));
695 defaultBrowser.setFont(LABEL_FONT);
696 defaultBrowser.setText("");
697 final String tooltip = JvSwingUtils.wrapTooltip(true,
698 MessageManager.getString("label.double_click_to_browse"));
699 defaultBrowser.setToolTipText(tooltip);
700 defaultBrowser.addMouseListener(new MouseAdapter()
703 public void mouseClicked(MouseEvent e)
705 if (e.getClickCount() > 1)
707 defaultBrowser_mouseClicked(e);
712 JPanel proxyPanel = initConnTabProxyPanel();
713 initConnTabCheckboxes();
715 // Add default Browser text box
716 connectTab.add(browserLabel,
717 new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
718 GridBagConstraints.WEST, GridBagConstraints.NONE,
719 new Insets(10, 0, 5, 5), 5, 1));
720 defaultBrowser.setFont(LABEL_FONT);
721 defaultBrowser.setText("");
723 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
724 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
725 new Insets(10, 0, 5, 10), 30, 1));
727 // Add proxy server panel
728 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
729 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
730 new Insets(10, 0, 5, 12), 4, 10));
732 // Add usage stats, version check and questionnaire checkboxes
733 connectTab.add(usagestats,
734 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
735 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
736 new Insets(0, 2, 5, 5), 70, 1));
737 connectTab.add(questionnaire,
738 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
739 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
740 new Insets(0, 2, 5, 10), 70, 1));
741 connectTab.add(versioncheck,
742 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
743 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
744 new Insets(0, 2, 5, 5), 70, 1));
746 versioncheck.setVisible(false);
748 // Add padding so the panel doesn't look ridiculous
749 JPanel spacePanel = new JPanel();
750 connectTab.add(spacePanel,
751 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
752 GridBagConstraints.WEST, GridBagConstraints.BOTH,
753 new Insets(0, 0, 0, 5), 70, 1));
759 * Initialises the Links tabbed panel.
763 private JPanel initLinksTab()
765 JPanel linkTab = new JPanel();
766 linkTab.setLayout(new GridBagLayout());
768 // Set up table for Url links
769 linkUrlTable.getTableHeader().setReorderingAllowed(false);
770 linkUrlTable.setFillsViewportHeight(true);
771 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
772 linkUrlTable.setAutoCreateRowSorter(true);
773 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
775 // adjust row height so radio buttons actually fit
776 // don't do this in the renderer, it causes the awt thread to activate
778 JRadioButton temp = new JRadioButton();
779 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
781 // Table in scrollpane so that the table is given a scrollbar
782 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
783 linkScrollPane.setBorder(null);
785 // Panel for links functionality
786 JPanel linkPanel = new JPanel(new GridBagLayout());
787 linkPanel.setBorder(new TitledBorder(
788 MessageManager.getString("label.url_linkfrom_sequence_id")));
790 // Put the Url links panel together
792 // Buttons go at top right, resizing only resizes the blank space vertically
793 JPanel buttonPanel = initLinkTabUrlButtons();
794 GridBagConstraints linkConstraints1 = new GridBagConstraints();
795 linkConstraints1.insets = new Insets(0, 0, 5, 0);
796 linkConstraints1.gridx = 0;
797 linkConstraints1.gridy = 0;
798 linkConstraints1.weightx = 1.0;
799 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
800 linkTab.add(buttonPanel, linkConstraints1);
802 // Links table goes at top left, resizing resizes the table
803 GridBagConstraints linkConstraints2 = new GridBagConstraints();
804 linkConstraints2.insets = new Insets(0, 0, 5, 5);
805 linkConstraints2.gridx = 0;
806 linkConstraints2.gridy = 1;
807 linkConstraints2.weightx = 1.0;
808 linkConstraints2.weighty = 1.0;
809 linkConstraints2.fill = GridBagConstraints.BOTH;
810 linkTab.add(linkScrollPane, linkConstraints2);
812 // Filter box and buttons goes at bottom left, resizing resizes the text box
813 JPanel filterPanel = initLinkTabFilterPanel();
814 GridBagConstraints linkConstraints3 = new GridBagConstraints();
815 linkConstraints3.insets = new Insets(0, 0, 0, 5);
816 linkConstraints3.gridx = 0;
817 linkConstraints3.gridy = 2;
818 linkConstraints3.weightx = 1.0;
819 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
820 linkTab.add(filterPanel, linkConstraints3);
825 private JPanel initLinkTabFilterPanel()
827 // Filter textbox and reset button
828 JLabel filterLabel = new JLabel(
829 MessageManager.getString("label.filter"));
830 filterLabel.setFont(LABEL_FONT);
831 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
832 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
834 filterTB.setFont(LABEL_FONT);
835 filterTB.setText("");
837 doReset.setText(MessageManager.getString("action.showall"));
838 userOnly.setText(MessageManager.getString("action.customfilter"));
840 // Panel for filter functionality
841 JPanel filterPanel = new JPanel(new GridBagLayout());
842 filterPanel.setBorder(new TitledBorder("Filter"));
843 GridBagConstraints gbc = new GridBagConstraints();
846 gbc.fill = GridBagConstraints.NONE;
847 gbc.anchor = GridBagConstraints.WEST;
849 filterPanel.add(filterLabel, gbc);
851 GridBagConstraints gbc1 = new GridBagConstraints();
854 gbc1.fill = GridBagConstraints.HORIZONTAL;
855 gbc1.anchor = GridBagConstraints.WEST;
857 filterPanel.add(filterTB, gbc1);
859 GridBagConstraints gbc2 = new GridBagConstraints();
861 gbc2.fill = GridBagConstraints.NONE;
862 gbc2.anchor = GridBagConstraints.WEST;
863 filterPanel.add(doReset, gbc2);
865 GridBagConstraints gbc3 = new GridBagConstraints();
867 gbc3.fill = GridBagConstraints.NONE;
868 gbc3.anchor = GridBagConstraints.WEST;
869 filterPanel.add(userOnly, gbc3);
874 private JPanel initLinkTabUrlButtons()
876 // Buttons for new / edit / delete Url links
877 JButton newLink = new JButton();
878 newLink.setText(MessageManager.getString("action.new"));
880 editLink.setText(MessageManager.getString("action.edit"));
882 deleteLink.setText(MessageManager.getString("action.delete"));
884 // no current selection, so initially disable delete/edit buttons
885 editLink.setEnabled(false);
886 deleteLink.setEnabled(false);
888 newLink.addActionListener(new java.awt.event.ActionListener()
891 public void actionPerformed(ActionEvent e)
893 newLink_actionPerformed(e);
897 editLink.setText(MessageManager.getString("action.edit"));
898 editLink.addActionListener(new java.awt.event.ActionListener()
901 public void actionPerformed(ActionEvent e)
903 editLink_actionPerformed(e);
907 deleteLink.setText(MessageManager.getString("action.delete"));
908 deleteLink.addActionListener(new java.awt.event.ActionListener()
911 public void actionPerformed(ActionEvent e)
913 deleteLink_actionPerformed(e);
917 JPanel buttonPanel = new JPanel(new GridBagLayout());
918 buttonPanel.setBorder(new TitledBorder("Edit links"));
919 GridBagConstraints gbc = new GridBagConstraints();
922 gbc.fill = GridBagConstraints.NONE;
923 buttonPanel.add(newLink, gbc);
925 GridBagConstraints gbc1 = new GridBagConstraints();
928 gbc1.fill = GridBagConstraints.NONE;
929 buttonPanel.add(editLink, gbc1);
931 GridBagConstraints gbc2 = new GridBagConstraints();
934 gbc2.fill = GridBagConstraints.NONE;
935 buttonPanel.add(deleteLink, gbc2);
937 GridBagConstraints gbc3 = new GridBagConstraints();
940 gbc3.fill = GridBagConstraints.HORIZONTAL;
942 JPanel spacePanel = new JPanel();
943 spacePanel.setBorder(null);
944 buttonPanel.add(spacePanel, gbc3);
950 * Initialises the proxy server panel in the Connections tab
952 * @return the proxy server panel
954 private JPanel initConnTabProxyPanel()
956 // Label for server text box
957 serverLabel.setText(MessageManager.getString("label.host") + ": ");
958 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
959 serverLabel.setFont(LABEL_FONT);
960 serverLabel2.setText(MessageManager.getString("label.host") + ": ");
961 serverLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
962 serverLabel2.setFont(LABEL_FONT);
964 // Proxy server and port text boxes
965 proxyServerHttpTB.setFont(LABEL_FONT);
966 proxyServerHttpTB.setColumns(40);
967 proxyPortHttpTB.setFont(LABEL_FONT);
968 proxyPortHttpTB.setColumns(4);
969 proxyServerHttpsTB.setFont(LABEL_FONT);
970 proxyServerHttpsTB.setColumns(40);
971 proxyPortHttpsTB.setFont(LABEL_FONT);
972 proxyPortHttpsTB.setColumns(4);
973 proxyAuthUsernameTB.setFont(LABEL_FONT);
974 proxyAuthUsernameTB.setColumns(30);
975 proxyAuthPasswordTB.setFont(LABEL_FONT);
976 proxyAuthPasswordTB.setColumns(30);
978 // Label for Port text box
979 portLabel.setFont(LABEL_FONT);
980 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
981 portLabel.setText(MessageManager.getString("label.port") + ": ");
982 portLabel2.setFont(LABEL_FONT);
983 portLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
984 portLabel2.setText(MessageManager.getString("label.port") + ": ");
986 httpLabel.setText("HTTP");
987 httpLabel.setFont(LABEL_FONT_BOLD);
988 httpLabel.setHorizontalAlignment(SwingConstants.LEFT);
989 httpsLabel.setText("HTTPS");
990 httpsLabel.setFont(LABEL_FONT_BOLD);
991 httpsLabel.setHorizontalAlignment(SwingConstants.LEFT);
993 proxyAuthUsernameLabel
994 .setText(MessageManager.getString("label.username") + ": ");
995 proxyAuthUsernameLabel.setFont(LABEL_FONT);
996 proxyAuthUsernameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
997 proxyAuthPasswordLabel
998 .setText(MessageManager.getString("label.password") + ": ");
999 proxyAuthPasswordLabel.setFont(LABEL_FONT);
1000 proxyAuthPasswordLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1001 passwordNotStoredLabel.setText(
1002 "(" + MessageManager.getString("label.not_stored") + ")");
1003 passwordNotStoredLabel.setFont(LABEL_FONT_ITALIC);
1004 passwordNotStoredLabel.setHorizontalAlignment(SwingConstants.LEFT);
1006 // Proxy type radio buttons
1007 noProxy.setFont(LABEL_FONT);
1008 noProxy.setHorizontalAlignment(SwingConstants.LEFT);
1009 noProxy.setText(MessageManager.getString("label.no_proxy"));
1010 systemProxy.setFont(LABEL_FONT);
1011 systemProxy.setHorizontalAlignment(SwingConstants.LEFT);
1012 systemProxy.setText(MessageManager.formatMessage("label.system_proxy",
1013 displayUserHostPort(Cache.startupProxyProperties[4],
1014 Cache.startupProxyProperties[0],
1015 Cache.startupProxyProperties[1]),
1016 displayUserHostPort(Cache.startupProxyProperties[6],
1017 Cache.startupProxyProperties[2],
1018 Cache.startupProxyProperties[3])));
1019 customProxy.setFont(LABEL_FONT);
1020 customProxy.setHorizontalAlignment(SwingConstants.LEFT);
1021 customProxy.setText(
1022 MessageManager.getString("label.use_proxy_server") + ":");
1023 ActionListener al = new ActionListener()
1026 public void actionPerformed(ActionEvent e)
1028 proxyType_actionPerformed();
1031 noProxy.addActionListener(al);
1032 systemProxy.addActionListener(al);
1033 customProxy.addActionListener(al);
1034 proxyType.add(noProxy);
1035 proxyType.add(systemProxy);
1036 proxyType.add(customProxy);
1038 proxyAuth.setFont(LABEL_FONT);
1039 proxyAuth.setHorizontalAlignment(SwingConstants.LEFT);
1040 proxyAuth.setText(MessageManager.getString("label.auth_required"));
1041 proxyAuth.addActionListener(new ActionListener()
1044 public void actionPerformed(ActionEvent e)
1046 proxyAuth_actionPerformed();
1050 setCustomProxyEnabled();
1052 // Make proxy server panel
1053 JPanel proxyPanel = new JPanel();
1054 TitledBorder titledBorder1 = new TitledBorder(
1055 MessageManager.getString("label.proxy_servers"));
1056 proxyPanel.setBorder(titledBorder1);
1057 proxyPanel.setLayout(new GridBagLayout());
1058 GridBagConstraints gbc = new GridBagConstraints();
1059 gbc.fill = GridBagConstraints.HORIZONTAL;
1062 GridBagConstraints c = new GridBagConstraints();
1063 // Proxy type radio buttons (3)
1064 JPanel ptPanel = new JPanel();
1065 ptPanel.setLayout(new GridBagLayout());
1070 c.fill = GridBagConstraints.HORIZONTAL;
1071 ptPanel.add(noProxy, c);
1073 ptPanel.add(systemProxy, c);
1075 ptPanel.add(customProxy, c);
1078 proxyPanel.add(ptPanel, gbc);
1080 // host and port text boxes
1081 JPanel hpPanel = new JPanel();
1082 hpPanel.setLayout(new GridBagLayout());
1083 // HTTP host port row
1088 c.anchor = GridBagConstraints.LINE_START;
1089 hpPanel.add(httpLabel, c);
1093 c.anchor = GridBagConstraints.LINE_END;
1094 hpPanel.add(serverLabel, c);
1098 c.anchor = GridBagConstraints.LINE_START;
1099 hpPanel.add(proxyServerHttpTB, c);
1103 c.anchor = GridBagConstraints.LINE_END;
1104 hpPanel.add(portLabel, c);
1108 c.anchor = GridBagConstraints.LINE_START;
1109 hpPanel.add(proxyPortHttpTB, c);
1111 // HTTPS host port row
1116 c.anchor = GridBagConstraints.LINE_START;
1117 hpPanel.add(httpsLabel, c);
1120 c.anchor = GridBagConstraints.LINE_END;
1121 hpPanel.add(serverLabel2, c);
1124 c.anchor = GridBagConstraints.LINE_START;
1125 hpPanel.add(proxyServerHttpsTB, c);
1128 c.anchor = GridBagConstraints.LINE_END;
1129 hpPanel.add(portLabel2, c);
1132 c.anchor = GridBagConstraints.LINE_START;
1133 hpPanel.add(proxyPortHttpsTB, c);
1136 proxyPanel.add(hpPanel, gbc);
1138 // Require authentication checkbox
1140 proxyPanel.add(proxyAuth, gbc);
1142 // username and password
1143 JPanel upPanel = new JPanel();
1144 upPanel.setLayout(new GridBagLayout());
1150 c.anchor = GridBagConstraints.LINE_END;
1151 upPanel.add(proxyAuthUsernameLabel, c);
1155 c.anchor = GridBagConstraints.LINE_START;
1156 upPanel.add(proxyAuthUsernameTB, c);
1162 c.anchor = GridBagConstraints.LINE_END;
1163 upPanel.add(proxyAuthPasswordLabel, c);
1167 c.anchor = GridBagConstraints.LINE_START;
1168 upPanel.add(proxyAuthPasswordTB, c);
1172 c.anchor = GridBagConstraints.LINE_START;
1173 upPanel.add(passwordNotStoredLabel, c);
1176 proxyPanel.add(upPanel, gbc);
1181 private String displayUserHostPort(String user, String host, String port)
1183 boolean hostBlank = (host == null || host.isEmpty());
1184 boolean portBlank = (port == null || port.isEmpty());
1185 if (hostBlank && portBlank)
1187 return MessageManager.getString("label.none");
1190 StringBuilder sb = new StringBuilder();
1193 sb.append(user.isEmpty() || user.indexOf(" ") > -1 ? '"' + user + '"'
1197 sb.append(hostBlank ? "" : host);
1203 return sb.toString();
1207 * Initialises the checkboxes in the Connections tab
1209 private void initConnTabCheckboxes()
1211 // Usage stats checkbox label
1213 MessageManager.getString("label.send_usage_statistics"));
1214 usagestats.setFont(LABEL_FONT);
1215 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
1216 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
1218 // Questionnaire checkbox label
1219 questionnaire.setText(
1220 MessageManager.getString("label.check_for_questionnaires"));
1221 questionnaire.setFont(LABEL_FONT);
1222 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
1223 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
1225 // Check for latest version checkbox label
1226 versioncheck.setText(
1227 MessageManager.getString("label.check_for_latest_version"));
1228 versioncheck.setFont(LABEL_FONT);
1229 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
1230 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
1234 * Initialises the parent panel which contains the tabbed sections.
1238 private JPanel initOkCancelPanel()
1240 JButton ok = new JButton();
1241 ok.setText(MessageManager.getString("action.ok"));
1242 ok.addActionListener(new ActionListener()
1245 public void actionPerformed(ActionEvent e)
1247 ok_actionPerformed(e);
1250 JButton cancel = new JButton();
1251 cancel.setText(MessageManager.getString("action.cancel"));
1252 cancel.addActionListener(new ActionListener()
1255 public void actionPerformed(ActionEvent e)
1257 cancel_actionPerformed(e);
1260 JPanel okCancelPanel = new JPanel();
1261 okCancelPanel.add(ok);
1262 okCancelPanel.add(cancel);
1263 return okCancelPanel;
1267 * Initialises the Colours tabbed panel.
1271 private JPanel initColoursTab()
1273 JPanel coloursTab = new JPanel();
1274 coloursTab.setBorder(new TitledBorder(
1275 MessageManager.getString("action.open_new_alignment")));
1276 coloursTab.setLayout(new FlowLayout());
1277 JLabel mincolourLabel = new JLabel();
1278 mincolourLabel.setFont(LABEL_FONT);
1279 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1280 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
1281 minColour.setFont(LABEL_FONT);
1282 minColour.setBorder(BorderFactory.createEtchedBorder());
1283 minColour.setPreferredSize(new Dimension(40, 20));
1284 minColour.addMouseListener(new MouseAdapter()
1287 public void mousePressed(MouseEvent e)
1289 minColour_actionPerformed(minColour);
1292 JLabel maxcolourLabel = new JLabel();
1293 maxcolourLabel.setFont(LABEL_FONT);
1294 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1295 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
1296 maxColour.setFont(LABEL_FONT);
1297 maxColour.setBorder(BorderFactory.createEtchedBorder());
1298 maxColour.setPreferredSize(new Dimension(40, 20));
1299 maxColour.addMouseListener(new MouseAdapter()
1302 public void mousePressed(MouseEvent e)
1304 maxColour_actionPerformed(maxColour);
1308 protColour.setFont(LABEL_FONT);
1309 protColour.setBounds(new Rectangle(172, 225, 155, 21));
1310 JLabel protColourLabel = new JLabel();
1311 protColourLabel.setFont(LABEL_FONT);
1312 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1313 protColourLabel.setText(
1314 MessageManager.getString("label.prot_alignment_colour") + " ");
1315 JvSwingUtils.addtoLayout(coloursTab,
1317 .getString("label.default_colour_scheme_for_alignment"),
1318 protColourLabel, protColour);
1320 nucColour.setFont(LABEL_FONT);
1321 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1322 JLabel nucColourLabel = new JLabel();
1323 nucColourLabel.setFont(LABEL_FONT);
1324 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1325 nucColourLabel.setText(
1326 MessageManager.getString("label.nuc_alignment_colour") + " ");
1327 JvSwingUtils.addtoLayout(coloursTab,
1329 .getString("label.default_colour_scheme_for_alignment"),
1330 nucColourLabel, nucColour);
1332 JPanel annotationShding = new JPanel();
1333 annotationShding.setBorder(new TitledBorder(
1334 MessageManager.getString("label.annotation_shading_default")));
1335 annotationShding.setLayout(new GridLayout(1, 2));
1336 JvSwingUtils.addtoLayout(annotationShding,
1337 MessageManager.getString(
1338 "label.default_minimum_colour_annotation_shading"),
1339 mincolourLabel, minColour);
1340 JvSwingUtils.addtoLayout(annotationShding,
1341 MessageManager.getString(
1342 "label.default_maximum_colour_annotation_shading"),
1343 maxcolourLabel, maxColour);
1344 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1349 * Initialises the Overview tabbed panel.
1353 private JPanel initOverviewTab()
1355 JPanel overviewPanel = new JPanel();
1356 overviewPanel.setBorder(new TitledBorder(
1357 MessageManager.getString("label.overview_settings")));
1359 gapColour.setFont(LABEL_FONT);
1360 // fixing the border colours stops apparent colour bleed from the panel
1361 gapColour.setBorder(
1362 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1363 gapColour.setPreferredSize(new Dimension(40, 20));
1364 gapColour.addMouseListener(new MouseAdapter()
1367 public void mousePressed(MouseEvent e)
1369 gapColour_actionPerformed(gapColour);
1373 hiddenColour.setFont(LABEL_FONT);
1374 // fixing the border colours stops apparent colour bleed from the panel
1375 hiddenColour.setBorder(
1376 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1377 hiddenColour.setPreferredSize(new Dimension(40, 20));
1378 hiddenColour.addMouseListener(new MouseAdapter()
1381 public void mousePressed(MouseEvent e)
1383 hiddenColour_actionPerformed(hiddenColour);
1387 useLegacyGap = new JCheckBox(
1388 MessageManager.getString("label.ov_legacy_gap"));
1389 useLegacyGap.setFont(LABEL_FONT);
1390 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1391 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1392 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1393 gapLabel.setFont(LABEL_FONT);
1394 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1395 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1396 showHiddenAtStart = new JCheckBox(
1397 MessageManager.getString("label.ov_show_hide_default"));
1398 showHiddenAtStart.setFont(LABEL_FONT);
1399 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1400 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1401 JLabel hiddenLabel = new JLabel(
1402 MessageManager.getString("label.hidden_colour"));
1403 hiddenLabel.setFont(LABEL_FONT);
1404 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1405 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1407 useLegacyGap.addActionListener(new ActionListener()
1410 public void actionPerformed(ActionEvent e)
1412 useLegacyGaps_actionPerformed(e);
1416 overviewPanel.setLayout(new GridBagLayout());
1417 GridBagConstraints c1 = new GridBagConstraints();
1419 c1.fill = GridBagConstraints.HORIZONTAL;
1424 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1425 overviewPanel.add(useLegacyGap, c1);
1427 GridBagConstraints c2 = new GridBagConstraints();
1428 c2.fill = GridBagConstraints.HORIZONTAL;
1431 c2.insets = new Insets(0, 15, 0, 10);
1432 overviewPanel.add(gapLabel, c2);
1434 GridBagConstraints c3 = new GridBagConstraints();
1435 c3.fill = GridBagConstraints.HORIZONTAL;
1438 c3.insets = new Insets(0, 0, 0, 15);
1439 overviewPanel.add(gapColour, c3);
1441 GridBagConstraints c4 = new GridBagConstraints();
1442 c4.fill = GridBagConstraints.HORIZONTAL;
1446 overviewPanel.add(showHiddenAtStart, c4);
1448 GridBagConstraints c5 = new GridBagConstraints();
1449 c5.fill = GridBagConstraints.HORIZONTAL;
1452 c5.insets = new Insets(0, 15, 0, 10);
1453 overviewPanel.add(hiddenLabel, c5);
1455 GridBagConstraints c6 = new GridBagConstraints();
1456 c6.fill = GridBagConstraints.HORIZONTAL;
1459 c6.insets = new Insets(0, 0, 0, 15);
1460 overviewPanel.add(hiddenColour, c6);
1462 JButton resetButton = new JButton(
1463 MessageManager.getString("label.reset_to_defaults"));
1465 resetButton.addActionListener(new ActionListener()
1468 public void actionPerformed(ActionEvent e)
1470 resetOvDefaults_actionPerformed(e);
1474 GridBagConstraints c7 = new GridBagConstraints();
1475 c7.fill = GridBagConstraints.NONE;
1478 c7.insets = new Insets(10, 0, 0, 0);
1479 c7.anchor = GridBagConstraints.WEST;
1480 overviewPanel.add(resetButton, c7);
1482 // Add padding so the panel doesn't look ridiculous
1483 JPanel spacePanel = new JPanel();
1484 overviewPanel.add(spacePanel,
1485 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1486 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1487 new Insets(0, 0, 0, 5), 0, 0));
1489 return overviewPanel;
1493 * Initialises the Structure tabbed panel.
1497 private JPanel initStructureTab()
1499 structureTab = new JPanel();
1501 structureTab.setBorder(new TitledBorder(
1502 MessageManager.getString("label.structure_options")));
1503 structureTab.setLayout(null);
1504 final int width = 420;
1505 final int height = 22;
1506 final int lineSpacing = 25;
1509 structFromPdb.setFont(LABEL_FONT);
1511 .setText(MessageManager.getString("label.struct_from_pdb"));
1512 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1513 structFromPdb.addActionListener(new ActionListener()
1516 public void actionPerformed(ActionEvent e)
1518 boolean selected = structFromPdb.isSelected();
1519 // enable other options only when the first is checked
1520 useRnaView.setEnabled(selected);
1521 addSecondaryStructure.setEnabled(selected);
1522 addTempFactor.setEnabled(selected);
1525 structureTab.add(structFromPdb);
1527 // indent checkboxes that are conditional on the first one
1528 ypos += lineSpacing;
1529 useRnaView.setFont(LABEL_FONT);
1530 useRnaView.setText(MessageManager.getString("label.use_rnaview"));
1531 useRnaView.setBounds(new Rectangle(25, ypos, width, height));
1532 structureTab.add(useRnaView);
1534 ypos += lineSpacing;
1535 addSecondaryStructure.setFont(LABEL_FONT);
1536 addSecondaryStructure
1537 .setText(MessageManager.getString("label.autoadd_secstr"));
1538 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1539 structureTab.add(addSecondaryStructure);
1541 ypos += lineSpacing;
1542 addTempFactor.setFont(LABEL_FONT);
1543 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1544 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1545 structureTab.add(addTempFactor);
1547 ypos += lineSpacing;
1548 JLabel viewerLabel = new JLabel();
1549 viewerLabel.setFont(LABEL_FONT);
1550 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1551 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1552 viewerLabel.setBounds(new Rectangle(10, ypos, 220, height));
1553 structureTab.add(viewerLabel);
1556 * add all external viewers as options here - check
1557 * when selected whether the program is installed
1559 structViewer.setFont(LABEL_FONT);
1560 structViewer.setBounds(new Rectangle(190, ypos, 120, height));
1561 structViewer.addItem(ViewerType.JMOL.name());
1562 structViewer.addItem(ViewerType.CHIMERA.name());
1563 structViewer.addItem(ViewerType.CHIMERAX.name());
1564 structViewer.addItem(ViewerType.PYMOL.name());
1565 structViewer.addActionListener(new ActionListener()
1568 public void actionPerformed(ActionEvent e)
1570 structureViewer_actionPerformed(
1571 (String) structViewer.getSelectedItem());
1574 structureTab.add(structViewer);
1576 ypos += lineSpacing;
1577 structureViewerPathLabel = new JLabel();
1578 structureViewerPathLabel.setFont(LABEL_FONT);// new Font("SansSerif", 0, 11));
1579 structureViewerPathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1580 structureViewerPathLabel.setText(MessageManager
1581 .formatMessage("label.viewer_path", "Chimera(X)"));
1582 structureViewerPathLabel.setBounds(new Rectangle(10, ypos, 170, height));
1583 structureViewerPathLabel.setEnabled(false);
1584 structureTab.add(structureViewerPathLabel);
1586 structureViewerPath.setFont(LABEL_FONT);
1587 structureViewerPath.setText("");
1588 structureViewerPath.setEnabled(false);
1589 final String tooltip = JvSwingUtils.wrapTooltip(true,
1590 MessageManager.getString("label.viewer_path_tip"));
1591 structureViewerPath.setToolTipText(tooltip);
1592 structureViewerPath.setBounds(new Rectangle(190, ypos, 290, height));
1593 structureViewerPath.addMouseListener(new MouseAdapter()
1596 public void mouseClicked(MouseEvent e)
1598 if (structureViewerPath.isEnabled() && e.getClickCount() == 2)
1600 String chosen = openFileChooser();
1603 structureViewerPath.setText(chosen);
1608 structureTab.add(structureViewerPath);
1610 ypos += lineSpacing;
1611 nwMapping.setFont(LABEL_FONT);
1612 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1613 siftsMapping.setFont(LABEL_FONT);
1614 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1615 mappingMethod.add(nwMapping);
1616 mappingMethod.add(siftsMapping);
1617 JPanel mappingPanel = new JPanel();
1618 mappingPanel.setFont(LABEL_FONT);
1619 TitledBorder mmTitledBorder = new TitledBorder(
1620 MessageManager.getString("label.mapping_method"));
1621 mmTitledBorder.setTitleFont(LABEL_FONT);
1622 mappingPanel.setBorder(mmTitledBorder);
1623 mappingPanel.setBounds(new Rectangle(10, ypos, 472, 45));
1624 // GridLayout mappingLayout = new GridLayout();
1625 mappingPanel.setLayout(new GridLayout());
1626 mappingPanel.add(nwMapping);
1627 mappingPanel.add(siftsMapping);
1628 structureTab.add(mappingPanel);
1630 ypos += lineSpacing;
1631 ypos += lineSpacing;
1632 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1633 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1634 docFieldPref.setBounds(new Rectangle(10, ypos, 470, 120));
1635 structureTab.add(docFieldPref);
1638 * hide Chimera options in JalviewJS
1640 if (Platform.isJS())
1642 structureViewerPathLabel.setVisible(false);
1643 structureViewerPath.setVisible(false);
1644 viewerLabel.setVisible(false);
1645 structViewer.setVisible(false);
1648 return structureTab;
1652 * Action on choosing a structure viewer from combobox options.
1654 * @param selectedItem
1656 protected void structureViewer_actionPerformed(String selectedItem)
1661 * Show a dialog for the user to choose a file. Returns the chosen path, or
1666 protected String openFileChooser()
1668 String choice = null;
1669 JFileChooser chooser = new JFileChooser();
1671 // chooser.setFileView(new JalviewFileView());
1672 chooser.setDialogTitle(
1673 MessageManager.getString("label.open_local_file"));
1674 chooser.setToolTipText(MessageManager.getString("action.open"));
1676 int value = chooser.showOpenDialog(this);
1678 if (value == JFileChooser.APPROVE_OPTION)
1680 choice = chooser.getSelectedFile().getPath();
1686 * Validate the structure tab preferences; if invalid, set focus on this tab.
1690 protected boolean validateStructure(FocusEvent e)
1692 if (!validateStructure())
1694 e.getComponent().requestFocusInWindow();
1700 protected boolean validateStructure()
1706 * Initialises the Visual tabbed panel.
1710 private JPanel initVisualTab()
1712 JPanel visualTab = new JPanel();
1713 visualTab.setBorder(new TitledBorder(
1714 MessageManager.getString("action.open_new_alignment")));
1715 visualTab.setLayout(null);
1716 fullScreen.setFont(LABEL_FONT);
1717 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1718 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1719 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1720 quality.setEnabled(false);
1721 quality.setFont(LABEL_FONT);
1722 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1723 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1724 quality.setSelected(true);
1725 quality.setText(MessageManager.getString("label.quality"));
1726 conservation.setEnabled(false);
1727 conservation.setFont(LABEL_FONT);
1728 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1729 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1730 conservation.setSelected(true);
1731 conservation.setText(MessageManager.getString("label.conservation"));
1732 identity.setEnabled(false);
1733 identity.setFont(LABEL_FONT);
1734 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1735 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1736 identity.setSelected(true);
1737 identity.setText(MessageManager.getString("label.consensus"));
1738 showOccupancy.setFont(LABEL_FONT);
1739 showOccupancy.setEnabled(false);
1740 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1741 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1742 showOccupancy.setSelected(true);
1743 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1745 JLabel showGroupbits = new JLabel();
1746 showGroupbits.setFont(LABEL_FONT);
1747 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1748 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1750 .setText(MessageManager.getString("action.show_group") + ":");
1751 JLabel showConsensbits = new JLabel();
1752 showConsensbits.setFont(LABEL_FONT);
1753 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1754 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1756 .setText(MessageManager.getString("label.consensus") + ":");
1757 showConsensHistogram.setEnabled(false);
1758 showConsensHistogram.setFont(LABEL_FONT);
1759 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1760 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1761 showConsensHistogram.setSelected(true);
1762 showConsensHistogram
1763 .setText(MessageManager.getString("label.histogram"));
1764 showConsensLogo.setEnabled(false);
1765 showConsensLogo.setFont(LABEL_FONT);
1766 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1767 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1768 showConsensLogo.setSelected(true);
1769 showConsensLogo.setText(MessageManager.getString("label.logo"));
1770 showGroupConsensus.setEnabled(false);
1771 showGroupConsensus.setFont(LABEL_FONT);
1772 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1773 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1774 showGroupConsensus.setSelected(true);
1775 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1776 showGroupConservation.setEnabled(false);
1777 showGroupConservation.setFont(LABEL_FONT);
1778 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1779 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1780 showGroupConservation.setSelected(true);
1781 showGroupConservation
1782 .setText(MessageManager.getString("label.conservation"));
1783 showNpTooltip.setEnabled(true);
1784 showNpTooltip.setFont(LABEL_FONT);
1785 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1786 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1787 showNpTooltip.setSelected(true);
1788 showNpTooltip.setText(
1789 MessageManager.getString("label.non_positional_features"));
1790 showDbRefTooltip.setEnabled(true);
1791 showDbRefTooltip.setFont(LABEL_FONT);
1792 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1793 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1794 showDbRefTooltip.setSelected(true);
1796 .setText(MessageManager.getString("label.database_references"));
1797 annotations.setFont(LABEL_FONT);
1798 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1799 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1800 annotations.setSelected(true);
1801 annotations.setText(MessageManager.getString("label.show_annotations"));
1802 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1803 annotations.addActionListener(new ActionListener()
1806 public void actionPerformed(ActionEvent e)
1808 annotations_actionPerformed(e);
1811 identity.addActionListener(new ActionListener()
1814 public void actionPerformed(ActionEvent e)
1816 annotations_actionPerformed(e);
1819 showGroupConsensus.addActionListener(new ActionListener()
1822 public void actionPerformed(ActionEvent e)
1824 annotations_actionPerformed(e);
1827 showUnconserved.setFont(LABEL_FONT);
1828 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1829 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1830 showUnconserved.setSelected(true);
1832 .setText(MessageManager.getString("action.show_unconserved"));
1833 showUnconserved.addActionListener(new ActionListener()
1836 public void actionPerformed(ActionEvent e)
1838 showunconserved_actionPerformed(e);
1842 // TODO these are not yet added to / action from Preferences
1843 // JCheckBox shareSelections = new JCheckBox();
1844 // shareSelections.setFont(verdana11);
1845 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1846 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1847 // shareSelections.setSelected(true);
1848 // shareSelections.setText(MessageManager
1849 // .getString("label.share_selection_across_views"));
1850 // JCheckBox followHighlight = new JCheckBox();
1851 // followHighlight.setFont(verdana11);
1852 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1853 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1854 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1855 // followHighlight.setSelected(true);
1856 // followHighlight.setText(MessageManager
1857 // .getString("label.scroll_highlighted_regions"));
1859 seqLimit.setFont(LABEL_FONT);
1860 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1861 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1862 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1863 smoothFont.setFont(LABEL_FONT);
1864 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1865 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1866 smoothFont.setText(MessageManager.getString("label.smooth_font"));
1867 scaleProteinToCdna.setFont(LABEL_FONT);
1868 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1869 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1870 scaleProteinToCdna.setText(
1871 MessageManager.getString("label.scale_protein_to_cdna"));
1872 scaleProteinToCdna.setToolTipText(
1873 MessageManager.getString("label.scale_protein_to_cdna_tip"));
1874 JLabel gapLabel = new JLabel();
1875 gapLabel.setFont(LABEL_FONT);
1876 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1877 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1878 JLabel fontLabel = new JLabel();
1879 fontLabel.setFont(LABEL_FONT);
1880 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1881 fontLabel.setText(MessageManager.getString("label.font"));
1882 fontSizeCB.setFont(LABEL_FONT);
1883 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
1884 fontStyleCB.setFont(LABEL_FONT);
1885 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
1886 fontNameCB.setFont(LABEL_FONT);
1887 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
1888 gapSymbolCB.setFont(LABEL_FONT);
1889 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
1890 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1891 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1892 gapSymbolCB.setRenderer(dlcr);
1894 startupCheckbox.setText(MessageManager.getString("action.open_file"));
1895 startupCheckbox.setFont(LABEL_FONT);
1896 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1897 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1898 startupCheckbox.setSelected(true);
1899 startupFileTextfield.setFont(LABEL_FONT);
1900 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
1901 final String tooltip = JvSwingUtils.wrapTooltip(true,
1902 MessageManager.getString("label.double_click_to_browse"));
1903 startupFileTextfield.setToolTipText(tooltip);
1904 startupFileTextfield.addMouseListener(new MouseAdapter()
1907 public void mouseClicked(MouseEvent e)
1909 if (e.getClickCount() > 1)
1911 startupFileTextfield_mouseClicked();
1916 sortby.setFont(LABEL_FONT);
1917 sortby.setBounds(new Rectangle(172, 260, 155, 21));
1918 JLabel sortLabel = new JLabel();
1919 sortLabel.setFont(LABEL_FONT);
1920 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1921 sortLabel.setText(MessageManager.getString("label.sort_by"));
1922 sortAnnBy.setFont(LABEL_FONT);
1923 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
1924 JLabel sortAnnLabel = new JLabel();
1925 sortAnnLabel.setFont(LABEL_FONT);
1926 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1927 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
1928 sortAutocalc.setFont(LABEL_FONT);
1929 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
1931 JPanel annsettingsPanel = new JPanel();
1932 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
1933 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1934 annsettingsPanel.setBorder(new EtchedBorder());
1935 visualTab.add(annsettingsPanel);
1936 Border jb = new EmptyBorder(1, 1, 4, 5);
1937 annotations.setBorder(jb);
1938 showOccupancy.setBorder(jb);
1939 quality.setBorder(jb);
1940 conservation.setBorder(jb);
1941 identity.setBorder(jb);
1942 showConsensbits.setBorder(jb);
1943 showGroupbits.setBorder(jb);
1944 showGroupConsensus.setBorder(jb);
1945 showGroupConservation.setBorder(jb);
1946 showConsensHistogram.setBorder(jb);
1947 showConsensLogo.setBorder(jb);
1949 JPanel autoAnnotSettings = new JPanel();
1950 annsettingsPanel.add(autoAnnotSettings);
1951 autoAnnotSettings.setLayout(new GridLayout(0, 2));
1952 autoAnnotSettings.add(annotations);
1953 autoAnnotSettings.add(quality);
1954 // second row of autoannotation box
1955 autoAnnotSettings = new JPanel();
1956 annsettingsPanel.add(autoAnnotSettings);
1958 autoAnnotSettings.setLayout(new GridLayout(0, 3));
1959 autoAnnotSettings.add(conservation);
1960 autoAnnotSettings.add(identity);
1961 autoAnnotSettings.add(showOccupancy);
1962 autoAnnotSettings.add(showGroupbits);
1963 autoAnnotSettings.add(showGroupConservation);
1964 autoAnnotSettings.add(showGroupConsensus);
1965 autoAnnotSettings.add(showConsensbits);
1966 autoAnnotSettings.add(showConsensHistogram);
1967 autoAnnotSettings.add(showConsensLogo);
1969 JPanel tooltipSettings = new JPanel();
1970 tooltipSettings.setBorder(new TitledBorder(
1971 MessageManager.getString("label.sequence_id_tooltip")));
1972 tooltipSettings.setBounds(173, 140, 220, 62);
1973 tooltipSettings.setLayout(new GridLayout(2, 1));
1974 tooltipSettings.add(showDbRefTooltip);
1975 tooltipSettings.add(showNpTooltip);
1976 visualTab.add(tooltipSettings);
1978 wrap.setFont(LABEL_FONT);
1979 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
1980 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
1981 wrap.setText(MessageManager.getString("label.wrap_alignment"));
1982 rightAlign.setFont(LABEL_FONT);
1983 rightAlign.setForeground(Color.black);
1984 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
1985 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
1986 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
1987 idItalics.setFont(LABEL_FONT_ITALIC);
1988 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
1989 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
1991 MessageManager.getString("label.sequence_name_italics"));
1992 openoverv.setFont(LABEL_FONT);
1993 openoverv.setActionCommand(
1994 MessageManager.getString("label.open_overview"));
1995 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
1996 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
1997 openoverv.setText(MessageManager.getString("label.open_overview"));
1998 JPanel jPanel2 = new JPanel();
1999 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
2000 jPanel2.setLayout(new GridLayout(14, 1));
2001 jPanel2.add(fullScreen);
2002 jPanel2.add(openoverv);
2003 jPanel2.add(seqLimit);
2004 jPanel2.add(rightAlign);
2005 jPanel2.add(fontLabel);
2006 jPanel2.add(showUnconserved);
2007 jPanel2.add(idItalics);
2008 jPanel2.add(smoothFont);
2009 jPanel2.add(scaleProteinToCdna);
2010 jPanel2.add(gapLabel);
2012 jPanel2.add(sortLabel);
2013 jPanel2.add(sortAnnLabel);
2014 jPanel2.add(startupCheckbox);
2015 visualTab.add(jPanel2);
2016 visualTab.add(startupFileTextfield);
2017 visualTab.add(sortby);
2018 visualTab.add(sortAnnBy);
2019 visualTab.add(sortAutocalc);
2020 visualTab.add(gapSymbolCB);
2021 visualTab.add(fontNameCB);
2022 visualTab.add(fontSizeCB);
2023 visualTab.add(fontStyleCB);
2025 if (Platform.isJS())
2027 startupCheckbox.setVisible(false);
2028 startupFileTextfield.setVisible(false);
2035 * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
2038 protected void loadLastSavedBackupsOptions()
2040 BackupFilesPresetEntry savedPreset = BackupFilesPresetEntry
2041 .getSavedBackupEntry();
2043 .setSelected(Cache.getDefault(BackupFiles.ENABLED, !Platform.isJS()));
2045 BackupFilesPresetEntry backupfilesCustomEntry = BackupFilesPresetEntry
2046 .createBackupFilesPresetEntry(Cache
2047 .getDefault(BackupFilesPresetEntry.CUSTOMCONFIG, null));
2048 if (backupfilesCustomEntry == null)
2050 backupfilesCustomEntry = BackupFilesPresetEntry.backupfilesPresetEntriesValues
2051 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT);
2053 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
2054 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM,
2055 backupfilesCustomEntry);
2057 setComboIntStringKey(backupfilesPresetsCombo,
2058 Cache.getDefault(BackupFiles.NS + "_PRESET",
2059 BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT));
2061 backupsSetOptions(savedPreset);
2063 backupsOptionsSetEnabled();
2064 updateBackupFilesExampleLabel();
2067 private boolean warnAboutSuffixReverseChange()
2069 BackupFilesPresetEntry bfpe = BackupFilesPresetEntry
2070 .getSavedBackupEntry();
2071 boolean savedSuffixReverse = bfpe.reverse;
2072 int savedSuffixDigits = bfpe.digits;
2073 String savedSuffixTemplate = bfpe.suffix;
2075 boolean nowSuffixReverse = suffixReverse.isSelected();
2076 int nowSuffixDigits = getSpinnerInt(suffixDigitsSpinner, 3);
2077 String nowSuffixTemplate = suffixTemplate.getText();
2078 return nowSuffixReverse != savedSuffixReverse
2079 && nowSuffixDigits == savedSuffixDigits
2080 && nowSuffixTemplate != null
2081 && nowSuffixTemplate.equals(savedSuffixTemplate);
2085 * Initialises the Backups tabbed panel.
2089 private JPanel initBackupsTab()
2091 JPanel backupsTab = new JPanel();
2092 backupsTab.setBorder(new TitledBorder(
2093 MessageManager.getString("label.backup_files")));
2094 backupsTab.setLayout(new GridBagLayout());
2096 GridBagConstraints gbc = new GridBagConstraints();
2099 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2100 gbc.fill = GridBagConstraints.NONE;
2102 initBackupsTabPresetsPanel();
2103 initBackupsTabSuffixPanel();
2104 initBackupsTabKeepFilesPanel();
2105 initBackupsTabFilenameExamplesPanel();
2107 enableBackupFiles.setFont(LABEL_FONT_BOLD);
2109 .setText(MessageManager.getString("label.enable_backupfiles"));
2110 enableBackupFiles.addActionListener(new ActionListener()
2113 public void actionPerformed(ActionEvent e)
2115 // enable other options only when the first is checked
2116 backupsOptionsSetEnabled();
2121 // enable checkbox 1 col
2125 gbc.gridy = 0; // row 0
2126 backupsTab.add(enableBackupFiles, gbc);
2128 // summary of scheme box (over two rows)
2132 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
2133 gbc.fill = GridBagConstraints.BOTH;
2134 backupsTab.add(exampleFilesPanel, gbc);
2136 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2137 gbc.fill = GridBagConstraints.NONE;
2139 // fill empty space on right
2142 backupsTab.add(new JPanel(), gbc);
2147 gbc.gridy++; // row 1
2148 backupsTab.add(presetsPanel, gbc);
2150 // now using whole row
2155 gbc.gridy++; // row 2
2156 backupsTab.add(keepfilesPanel, gbc);
2158 // filename strategy box
2159 gbc.gridy++; // row 3
2160 backupsTab.add(suffixPanel, gbc);
2163 gbc.gridy++; // row 4
2165 backupsTab.add(new JPanel(), gbc);
2167 backupsOptionsSetEnabled();
2171 private JPanel initBackupsTabPresetsPanel()
2174 String title = MessageManager.getString("label.schemes");
2176 presetsPanel.setLayout(new GridBagLayout());
2178 GridBagConstraints gbc = new GridBagConstraints();
2181 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
2182 gbc.fill = GridBagConstraints.NONE;
2190 presetsComboLabel = new JLabel(title + ":");
2191 presetsPanel.add(presetsComboLabel, gbc);
2193 List<Object> entries = Arrays
2194 .asList((Object[]) BackupFilesPresetEntry.backupfilesPresetEntries);
2195 List<String> tooltips = Arrays.asList(
2196 BackupFilesPresetEntry.backupfilesPresetEntryDescriptions);
2197 backupfilesPresetsCombo = JvSwingUtils.buildComboWithTooltips(entries,
2200 for (int i = 0; i < BackupFilesPresetEntry.backupfilesPresetEntries.length; i++)
2202 backupfilesPresetsCombo
2203 .addItem(BackupFilesPresetEntry.backupfilesPresetEntries[i]);
2207 backupfilesPresetsCombo.addActionListener(new ActionListener()
2210 public void actionPerformed(ActionEvent e)
2212 int key = getComboIntStringKey(backupfilesPresetsCombo);
2213 if (!customiseCheckbox.isSelected())
2215 backupfilesPresetsComboLastSelected = key;
2217 if (key == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
2219 if (customiseCheckbox.isSelected())
2221 // got here by clicking on customiseCheckbox so don't change the values
2222 backupfilesCustomOptionsSetEnabled();
2226 backupsTabUpdatePresets();
2227 backupfilesCustomOptionsSetEnabled();
2232 customiseCheckbox.setSelected(false);
2233 backupsTabUpdatePresets();
2234 backupfilesCustomOptionsSetEnabled();
2239 // dropdown list of preset schemes
2241 presetsPanel.add(backupfilesPresetsCombo, gbc);
2243 revertButton.setText(MessageManager.getString("label.cancel_changes"));
2244 revertButton.setToolTipText(
2245 MessageManager.getString("label.cancel_changes_description"));
2246 revertButton.addActionListener(new ActionListener()
2249 public void actionPerformed(ActionEvent e)
2252 BackupFilesPresetEntry.backupfilesPresetEntriesValues.get(
2253 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM));
2254 backupfilesCustomOptionsSetEnabled();
2258 revertButton.setFont(LABEL_FONT);
2260 customiseCheckbox.setFont(LABEL_FONT);
2261 customiseCheckbox.setText(MessageManager.getString("label.customise"));
2262 customiseCheckbox.addActionListener(new ActionListener()
2265 public void actionPerformed(ActionEvent e)
2267 int currently = getComboIntStringKey(backupfilesPresetsCombo);
2268 if (customiseCheckbox.isSelected())
2270 backupfilesPresetsComboLastSelected = currently;
2271 setComboIntStringKey(backupfilesPresetsCombo,
2272 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2276 setComboIntStringKey(backupfilesPresetsCombo,
2277 backupfilesPresetsComboLastSelected);
2280 backupfilesCustomOptionsSetEnabled();
2283 customiseCheckbox.setToolTipText(
2284 MessageManager.getString("label.customise_description"));
2286 // customise checkbox
2289 presetsPanel.add(customiseCheckbox, gbc);
2291 // "Cancel changes" button (aligned with combo box above)
2293 presetsPanel.add(revertButton, gbc);
2295 return presetsPanel;
2298 private JPanel initBackupsTabFilenameExamplesPanel()
2300 String title = MessageManager
2301 .getString("label.scheme_examples");
2302 TitledBorder tb = new TitledBorder(title);
2303 exampleFilesPanel.setBorder(tb);
2304 exampleFilesPanel.setLayout(new GridBagLayout());
2307 backupfilesExampleLabel.setEditable(false);
2308 backupfilesExampleLabel
2309 .setBackground(exampleFilesPanel.getBackground());
2311 updateBackupFilesExampleLabel();
2313 GridBagConstraints gbc = new GridBagConstraints();
2316 gbc.fill = GridBagConstraints.NONE;
2317 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2319 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
2320 return exampleFilesPanel;
2323 private void backupsTabUpdatePresets()
2325 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
2328 String value = entry.v;
2330 if (BackupFilesPresetEntry.backupfilesPresetEntriesValues
2334 BackupFilesPresetEntry.backupfilesPresetEntriesValues
2340 "Preset '" + value + "' [key:" + key + "] not implemented");
2343 // Custom options will now be enabled when the customiseCheckbox is checked
2344 // (performed above)
2345 // backupfilesCustomOptionsSetEnabled();
2346 updateBackupFilesExampleLabel();
2349 protected int getComboIntStringKey(
2350 JComboBox<Object> backupfilesPresetsCombo2)
2352 IntKeyStringValueEntry e;
2355 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2
2357 } catch (Exception ex)
2360 "Problem casting Combo entry to IntKeyStringValueEntry.");
2363 return e != null ? e.k : 0;
2366 protected void setComboIntStringKey(
2367 JComboBox<Object> backupfilesPresetsCombo2,
2370 for (int i = 0; i < backupfilesPresetsCombo2.getItemCount(); i++)
2372 IntKeyStringValueEntry e;
2375 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2.getItemAt(i);
2376 } catch (Exception ex)
2379 "Problem casting Combo entry to IntKeyStringValueEntry. Skipping item. ");
2384 backupfilesPresetsCombo2.setSelectedIndex(i);
2388 // backupsTabUpdatePresets();
2391 private JPanel initBackupsTabSuffixPanel()
2393 suffixPanel.setBorder(new TitledBorder(
2394 MessageManager.getString("label.backup_filename_strategy")));
2395 suffixPanel.setLayout(new GridBagLayout());
2398 .setText(MessageManager.getString("label.append_to_filename"));
2399 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
2400 suffixTemplateLabel.setFont(LABEL_FONT);
2402 final String tooltip = JvSwingUtils.wrapTooltip(true,
2403 MessageManager.getString("label.append_to_filename_tooltip"));
2404 suffixTemplate.setToolTipText(tooltip);
2405 suffixTemplate.addActionListener(new ActionListener()
2408 public void actionPerformed(ActionEvent e)
2410 updateBackupFilesExampleLabel();
2411 backupfilesCustomOptionsSetEnabled();
2412 backupfilesRevertButtonSetEnabled(true);
2416 suffixTemplate.addKeyListener(new KeyListener()
2419 public void keyReleased(KeyEvent e)
2421 updateBackupFilesExampleLabel();
2422 backupfilesCustomOptionsSetEnabled();
2423 backupfilesRevertButtonSetEnabled(true);
2427 public void keyPressed(KeyEvent e)
2431 // disable use of ':' or '/' or '\'
2433 public void keyTyped(KeyEvent e)
2435 char c = e.getKeyChar();
2436 if (c == ':' || c == '/' || c == '\\')
2438 // don't process ':' or '/' or '\'
2447 .setText(MessageManager.getString("label.index_digits"));
2448 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
2449 suffixDigitsLabel.setFont(LABEL_FONT);
2450 ChangeListener c = new ChangeListener()
2453 public void stateChanged(ChangeEvent e)
2455 backupfilesRevertButtonSetEnabled(true);
2456 updateBackupFilesExampleLabel();
2460 setIntegerSpinner(suffixDigitsSpinner, BackupFilesPresetEntry.DIGITSMIN,
2461 BackupFilesPresetEntry.DIGITSMAX, 3, c);
2463 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
2464 MessageManager.getString("label.increment_index"));
2465 suffixReverse.addActionListener(new ActionListener()
2468 public void actionPerformed(ActionEvent e)
2470 boolean okay = true;
2471 if (warnAboutSuffixReverseChange())
2474 okay = confirmSuffixReverseChange();
2478 backupfilesRevertButtonSetEnabled(true);
2479 updateBackupFilesExampleLabel();
2483 boolean savedSuffixReverse = BackupFilesPresetEntry
2484 .getSavedBackupEntry().reverse;
2485 suffixReverse.setSelected(savedSuffixReverse);
2490 GridBagConstraints sgbc = new GridBagConstraints();
2492 // first row (template text box)
2493 sgbc.anchor = GridBagConstraints.WEST;
2497 sgbc.gridheight = 1;
2500 sgbc.fill = GridBagConstraints.NONE;
2501 suffixPanel.add(suffixTemplateLabel, sgbc);
2504 sgbc.fill = GridBagConstraints.HORIZONTAL;
2505 suffixPanel.add(suffixTemplate, sgbc);
2507 // second row (number of digits spinner)
2511 sgbc.fill = GridBagConstraints.NONE;
2512 suffixPanel.add(suffixDigitsLabel, sgbc);
2515 sgbc.fill = GridBagConstraints.HORIZONTAL;
2516 suffixPanel.add(suffixDigitsSpinner, sgbc);
2518 // third row (forward order radio selection)
2521 sgbc.gridwidth = GridBagConstraints.REMAINDER;
2522 sgbc.fill = GridBagConstraints.HORIZONTAL;
2523 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
2525 // fourth row (reverse order radio selection)
2527 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
2531 private boolean confirmSuffixReverseChange()
2533 boolean ret = false;
2534 String warningMessage = MessageManager
2535 .getString("label.warning_confirm_change_reverse");
2536 int confirm = JvOptionPane.showConfirmDialog(Desktop.desktop,
2538 MessageManager.getString("label.change_increment_decrement"),
2539 JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE);
2541 ret = (confirm == JvOptionPane.YES_OPTION);
2545 private JPanel initBackupsTabKeepFilesPanel()
2547 keepfilesPanel.setBorder(
2548 new TitledBorder(MessageManager.getString("label.keep_files")));
2549 keepfilesPanel.setLayout(new GridBagLayout());
2551 backupfilesKeepAll.setLabels(
2552 MessageManager.getString("label.keep_all_backup_files"),
2553 MessageManager.getString(
2554 "label.keep_only_this_number_of_backup_files"));
2555 backupfilesKeepAll.addTrueActionListener(new ActionListener()
2558 public void actionPerformed(ActionEvent e)
2560 backupfilesRevertButtonSetEnabled(true);
2561 updateBackupFilesExampleLabel();
2564 backupfilesKeepAll.addActionListener(new ActionListener()
2567 public void actionPerformed(ActionEvent e)
2569 backupfilesRevertButtonSetEnabled(true);
2570 keepRollMaxOptionsEnabled();
2571 updateBackupFilesExampleLabel();
2575 ChangeListener c = new ChangeListener()
2578 public void stateChanged(ChangeEvent e)
2580 backupfilesRevertButtonSetEnabled(true);
2581 updateBackupFilesExampleLabel();
2585 setIntegerSpinner(backupfilesRollMaxSpinner,
2586 BackupFilesPresetEntry.ROLLMAXMIN,
2587 BackupFilesPresetEntry.ROLLMAXMAX, 4, true, c);
2589 backupfilesConfirmDelete.setLabels(
2590 MessageManager.getString("label.always_ask"),
2591 MessageManager.getString("label.auto_delete"));
2592 backupfilesConfirmDelete.addActionListener(new ActionListener()
2595 public void actionPerformed(ActionEvent e)
2597 backupfilesRevertButtonSetEnabled(true);
2600 // update the enabled section
2601 keepRollMaxOptionsEnabled();
2603 GridBagConstraints kgbc = new GridBagConstraints();
2605 // first row (template text box)
2606 kgbc.anchor = GridBagConstraints.WEST;
2609 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2610 kgbc.gridheight = 1;
2613 kgbc.fill = GridBagConstraints.HORIZONTAL;
2614 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
2620 kgbc.gridwidth = GridBagConstraints.RELATIVE;
2621 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
2624 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2625 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
2627 // third row (indented)
2629 kgbc.insets = new Insets(0, 20, 0, 0);
2632 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2633 kgbc.fill = GridBagConstraints.HORIZONTAL;
2636 JPanel jp = new JPanel();
2637 jp.setLayout(new FlowLayout());
2639 .setText(MessageManager
2640 .getString("label.autodelete_old_backup_files"));
2641 oldBackupFilesLabel.setFont(LABEL_FONT);
2642 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
2643 jp.add(oldBackupFilesLabel);
2644 jp.add(backupfilesConfirmDelete.getTrueButton());
2645 jp.add(backupfilesConfirmDelete.getFalseButton());
2646 keepfilesPanel.add(jp, kgbc);
2648 return keepfilesPanel;
2651 protected void updateBackupFilesExampleLabel()
2653 int exampleindex = 12;
2654 String base = MessageManager.getString("label.filename") + ".fa";
2655 if (base == null || base.length() == 0)
2657 base = "file_name.fa";
2660 boolean reverse = suffixReverse.isSelected();
2661 boolean keepAll = backupfilesKeepAll.isSelected();
2663 String suffix = suffixTemplate.getText();
2666 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
2667 if (suffix == null || suffix.length() == 0)
2669 backupfilesExampleLabel
2670 .setText(MessageManager.getString("label.no_backup_files"));
2671 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
2675 rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 4);
2676 rollMax = rollMax < 1 ? 1 : rollMax;
2678 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
2683 digits = getSpinnerInt(suffixDigitsSpinner, 3);
2684 digits = digits < 1 ? 1 : digits;
2686 int lowersurround = 2;
2687 int uppersurround = 0;
2688 StringBuilder exampleSB = new StringBuilder();
2689 boolean firstLine = true;
2695 int max = keepAll ? exampleindex : rollMax;
2696 for (int index = min; index <= max; index++)
2698 if (index == min + lowersurround && index < max - uppersurround - 1)
2700 exampleSB.append("\n...");
2703 else if (index > min + lowersurround && index < max - uppersurround)
2715 exampleSB.append("\n");
2718 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2719 base, suffix, digits));
2722 // no extra text needed
2724 else if (index == min)
2726 String newest = MessageManager.getString("label.braced_newest");
2727 if (newest != null && newest.length() > 0)
2729 exampleSB.append(" " + newest);
2732 else if (index == max)
2734 String oldest = MessageManager.getString("label.braced_oldest");
2735 if (oldest != null && oldest.length() > 0)
2737 exampleSB.append(" " + oldest);
2746 int min = (keepAll || exampleindex - rollMax < 0) ? 1
2747 : exampleindex - rollMax + 1;
2748 int max = exampleindex;
2750 for (int index = min; index <= max; index++)
2753 if (index == min + lowersurround && index < max - uppersurround - 1)
2755 exampleSB.append("\n...");
2758 else if (index > min + lowersurround && index < max - uppersurround)
2770 exampleSB.append("\n");
2773 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2774 base, suffix, digits));
2777 // no extra text needed
2779 else if (index == min)
2781 String oldest = MessageManager.getString("label.braced_oldest");
2782 if (oldest != null && oldest.length() > 0)
2784 exampleSB.append(" " + oldest);
2787 else if (index == max)
2789 String newest = MessageManager.getString("label.braced_newest");
2790 if (newest != null && newest.length() > 0)
2792 exampleSB.append(" " + newest);
2800 // add some extra empty lines to pad out the example files box. ugh, please tell
2801 // me how to do this better
2802 int remainingLines = lowersurround + uppersurround + 1 - lineNumber;
2803 if (remainingLines > 0)
2805 for (int i = 0; i < remainingLines; i++)
2807 exampleSB.append("\n ");
2812 backupfilesExampleLabel.setText(exampleSB.toString());
2815 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2816 boolean useExistingVal, ChangeListener c)
2823 i = ((Integer) s.getValue()).intValue();
2824 } catch (Exception e)
2827 "Exception casting the initial value of s.getValue()");
2831 setIntegerSpinner(s, min, max, i, c);
2834 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2837 // integer spinner for number of digits
2846 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
2849 s.addChangeListener(c);
2853 protected static int getSpinnerInt(JSpinner s, int def)
2859 i = (Integer) s.getValue();
2860 } catch (Exception e)
2862 Cache.log.error("Failed casting (Integer) JSpinner s.getValue()");
2867 private void keepRollMaxOptionsEnabled()
2869 boolean enabled = backupfilesKeepAll.isEnabled()
2870 && !backupfilesKeepAll.isSelected();
2871 oldBackupFilesLabel.setEnabled(enabled);
2872 backupfilesRollMaxSpinner.setEnabled(enabled);
2873 backupfilesConfirmDelete.setEnabled(enabled);
2876 private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
2878 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2879 && customiseCheckbox.isSelected()
2880 && suffixTemplate.getText()
2881 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2882 keepfilesPanel.setEnabled(enabled);
2883 backupfilesKeepAll.setEnabled(enabled);
2884 oldBackupFilesLabel.setEnabled(enabled);
2885 keepRollMaxOptionsEnabled();
2888 private void backupfilesSuffixTemplateDigitsSetEnabled()
2890 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
2891 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2892 suffixDigitsLabel.setEnabled(enabled);
2893 suffixDigitsSpinner.setEnabled(enabled);
2894 suffixReverse.setEnabled(enabled);
2897 private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
2899 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2900 && customiseCheckbox.isSelected();
2901 suffixPanel.setEnabled(enabled);
2902 suffixTemplateLabel.setEnabled(enabled);
2903 suffixTemplate.setEnabled(enabled);
2904 backupfilesSuffixTemplateDigitsSetEnabled();
2907 private void backupfilesRevertButtonSetEnabled(boolean tryEnabled)
2909 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2910 && customiseCheckbox.isSelected() && backupfilesCustomChanged();
2911 revertButton.setEnabled(enabled);
2914 private boolean backupfilesCustomChanged()
2916 BackupFilesPresetEntry custom = BackupFilesPresetEntry.backupfilesPresetEntriesValues
2917 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2918 BackupFilesPresetEntry current = getBackupfilesCurrentEntry();
2919 return !custom.equals(current);
2922 protected BackupFilesPresetEntry getBackupfilesCurrentEntry()
2924 String suffix = suffixTemplate.getText();
2925 int digits = getSpinnerInt(suffixDigitsSpinner, 3);
2926 boolean reverse = suffixReverse.isSelected();
2927 boolean keepAll = backupfilesKeepAll.isSelected();
2928 int rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 3);
2929 boolean confirmDelete = backupfilesConfirmDelete.isSelected();
2931 BackupFilesPresetEntry bfpe = new BackupFilesPresetEntry(suffix, digits,
2932 reverse, keepAll, rollMax, confirmDelete);
2937 protected void backupfilesCustomOptionsSetEnabled()
2939 boolean enabled = customiseCheckbox.isSelected();
2941 backupfilesRevertButtonSetEnabled(enabled);
2942 backupfilesSuffixTemplateSetEnabled(enabled);
2943 backupfilesKeepAllSetEnabled(enabled);
2946 private void backupfilesSummarySetEnabled()
2948 boolean enabled = enableBackupFiles.isSelected();
2949 backupfilesExampleLabel.setEnabled(enabled);
2950 exampleFilesPanel.setEnabled(enabled);
2953 private void backupfilesPresetsSetEnabled()
2955 boolean enabled = enableBackupFiles.isSelected();
2956 presetsPanel.setEnabled(enabled);
2957 presetsComboLabel.setEnabled(enabled);
2958 backupfilesPresetsCombo.setEnabled(enabled);
2959 customiseCheckbox.setEnabled(enabled);
2960 revertButton.setEnabled(enabled);
2963 protected void backupsOptionsSetEnabled()
2965 backupfilesPresetsSetEnabled();
2966 backupfilesSummarySetEnabled();
2967 backupfilesCustomOptionsSetEnabled();
2970 protected void backupsSetOptions(String suffix, int digits,
2971 boolean reverse, boolean keepAll, int rollMax,
2972 boolean confirmDelete)
2974 suffixTemplate.setText(suffix);
2975 suffixDigitsSpinner.setValue(digits);
2976 suffixReverse.setSelected(reverse);
2977 backupfilesKeepAll.setSelected(keepAll);
2978 backupfilesRollMaxSpinner.setValue(rollMax);
2979 backupfilesConfirmDelete.setSelected(confirmDelete);
2982 protected void backupsSetOptions(BackupFilesPresetEntry p)
2984 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
2988 protected void autoIdWidth_actionPerformed()
2990 // TODO Auto-generated method stub
2994 protected void userIdWidth_actionPerformed()
2996 // TODO Auto-generated method stub
3000 protected void maxColour_actionPerformed(JPanel panel)
3004 protected void minColour_actionPerformed(JPanel panel)
3008 protected void gapColour_actionPerformed(JPanel panel)
3012 protected void hiddenColour_actionPerformed(JPanel panel)
3016 protected void showunconserved_actionPerformed(ActionEvent e)
3018 // TODO Auto-generated method stub
3022 protected void useLegacyGaps_actionPerformed(ActionEvent e)
3026 protected void resetOvDefaults_actionPerformed(ActionEvent e)
3036 public void ok_actionPerformed(ActionEvent e)
3046 public void cancel_actionPerformed(ActionEvent e)
3056 public void annotations_actionPerformed(ActionEvent e)
3063 public void startupFileTextfield_mouseClicked()
3067 public void newLink_actionPerformed(ActionEvent e)
3072 public void editLink_actionPerformed(ActionEvent e)
3077 public void deleteLink_actionPerformed(ActionEvent e)
3082 public void defaultBrowser_mouseClicked(MouseEvent e)
3087 public void linkURLList_keyTyped(KeyEvent e)
3092 public void setProxyAuthEnabled()
3094 boolean enabled = proxyAuth.isSelected() && proxyAuth.isEnabled();
3095 proxyAuthUsernameLabel.setEnabled(enabled);
3096 proxyAuthPasswordLabel.setEnabled(enabled);
3097 passwordNotStoredLabel.setEnabled(enabled);
3098 proxyAuthUsernameTB.setEnabled(enabled);
3099 proxyAuthPasswordTB.setEnabled(enabled);
3102 public void setCustomProxyEnabled()
3104 boolean enabled = customProxy.isSelected();
3105 portLabel.setEnabled(enabled);
3106 serverLabel.setEnabled(enabled);
3107 portLabel2.setEnabled(enabled);
3108 serverLabel2.setEnabled(enabled);
3109 httpLabel.setEnabled(enabled);
3110 httpsLabel.setEnabled(enabled);
3111 proxyServerHttpTB.setEnabled(enabled);
3112 proxyPortHttpTB.setEnabled(enabled);
3113 proxyServerHttpsTB.setEnabled(enabled);
3114 proxyPortHttpsTB.setEnabled(enabled);
3115 proxyAuth.setEnabled(enabled);
3116 setProxyAuthEnabled();
3119 public void proxyType_actionPerformed()
3121 setCustomProxyEnabled();
3124 public void proxyAuth_actionPerformed()
3126 setProxyAuthEnabled();
3130 * Customer renderer for JTable: supports column of radio buttons
3132 public class RadioButtonRenderer extends JRadioButton
3133 implements TableCellRenderer
3135 public RadioButtonRenderer()
3137 setHorizontalAlignment(CENTER);
3138 setToolTipText(MessageManager.getString("label.urltooltip"));
3142 public Component getTableCellRendererComponent(JTable table,
3143 Object value, boolean isSelected, boolean hasFocus, int row,
3146 setSelected((boolean) value);
3148 // set colours to match rest of table
3151 setBackground(table.getSelectionBackground());
3152 setForeground(table.getSelectionForeground());
3156 setBackground(table.getBackground());
3157 setForeground(table.getForeground());
3164 * Customer cell editor for JTable: supports column of radio buttons in
3165 * conjunction with renderer
3167 public class RadioButtonEditor extends AbstractCellEditor
3168 implements TableCellEditor
3170 private JRadioButton button = new JRadioButton();
3172 public RadioButtonEditor()
3174 button.setHorizontalAlignment(SwingConstants.CENTER);
3175 this.button.addActionListener(new ActionListener()
3178 public void actionPerformed(ActionEvent e)
3180 fireEditingStopped();
3186 public Component getTableCellEditorComponent(JTable table, Object value,
3187 boolean isSelected, int row, int column)
3189 button.setSelected((boolean) value);
3194 public Object getCellEditorValue()
3196 return button.isSelected();