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.event.DocumentEvent;
73 import javax.swing.event.DocumentListener;
74 import javax.swing.table.TableCellEditor;
75 import javax.swing.table.TableCellRenderer;
77 import jalview.bin.Cache;
78 import jalview.fts.core.FTSDataColumnPreferences;
79 import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource;
80 import jalview.fts.service.pdb.PDBFTSRestClient;
81 import jalview.gui.Desktop;
82 import jalview.gui.JalviewBooleanRadioButtons;
83 import jalview.gui.JvOptionPane;
84 import jalview.gui.JvSwingUtils;
85 import jalview.gui.StructureViewer.ViewerType;
86 import jalview.io.BackupFilenameParts;
87 import jalview.io.BackupFiles;
88 import jalview.io.BackupFilesPresetEntry;
89 import jalview.io.IntKeyStringValueEntry;
90 import jalview.util.MessageManager;
91 import jalview.util.Platform;
94 * Base class for the Preferences panel.
99 public class GPreferences extends JPanel
101 private static final Font LABEL_FONT = JvSwingUtils.getLabelFont();
103 private static final Font LABEL_FONT_ITALIC = JvSwingUtils
104 .getLabelFont(false, true);
106 private static final Font LABEL_FONT_BOLD = JvSwingUtils
107 .getLabelFont(true, false);
110 * Visual tab components
112 protected JCheckBox fullScreen = new JCheckBox();
114 protected JCheckBox openoverv = new JCheckBox();
116 protected JCheckBox seqLimit = new JCheckBox();
118 protected JCheckBox rightAlign = new JCheckBox();
120 protected JComboBox<String> fontSizeCB = new JComboBox<>();
122 protected JComboBox<String> fontStyleCB = new JComboBox<>();
124 protected JComboBox<String> fontNameCB = new JComboBox<>();
126 protected JCheckBox showOccupancy = new JCheckBox();
128 protected JCheckBox showUnconserved = new JCheckBox();
130 protected JCheckBox idItalics = new JCheckBox();
132 protected JCheckBox smoothFont = new JCheckBox();
134 protected JCheckBox scaleProteinToCdna = new JCheckBox();
136 protected JComboBox<String> gapSymbolCB = new JComboBox<>();
138 protected JCheckBox wrap = new JCheckBox();
140 protected JComboBox<String> sortby = new JComboBox<>();
142 protected JComboBox<String> sortAnnBy = new JComboBox<>();
144 protected JComboBox<String> sortAutocalc = new JComboBox<>();
146 protected JCheckBox startupCheckbox = new JCheckBox();
148 protected JTextField startupFileTextfield = new JTextField();
150 // below are in the 'second column'
151 protected JCheckBox annotations = new JCheckBox();
153 protected JCheckBox quality = new JCheckBox();
155 protected JCheckBox conservation = new JCheckBox();
157 protected JCheckBox identity = new JCheckBox();
159 protected JCheckBox showGroupConsensus = new JCheckBox();
161 protected JCheckBox showGroupConservation = new JCheckBox();
163 protected JCheckBox showConsensHistogram = new JCheckBox();
165 protected JCheckBox showConsensLogo = new JCheckBox();
167 protected JCheckBox showDbRefTooltip = new JCheckBox();
169 protected JCheckBox showNpTooltip = new JCheckBox();
172 * Structure tab and components
174 protected JPanel structureTab;
176 protected JCheckBox structFromPdb = new JCheckBox();
178 protected JCheckBox useRnaView = new JCheckBox();
180 protected JCheckBox addSecondaryStructure = new JCheckBox();
182 protected JCheckBox addTempFactor = new JCheckBox();
184 protected JComboBox<String> structViewer = new JComboBox<>();
186 protected JLabel structureViewerPathLabel;
188 protected JTextField structureViewerPath = new JTextField();
190 protected ButtonGroup mappingMethod = new ButtonGroup();
192 protected JRadioButton siftsMapping = new JRadioButton();
194 protected JRadioButton nwMapping = new JRadioButton();
197 * Colours tab components
199 protected JPanel minColour = new JPanel();
201 protected JPanel maxColour = new JPanel();
203 protected JComboBox<String> protColour = new JComboBox<>();
205 protected JComboBox<String> nucColour = new JComboBox<>();
208 * Overview tab components
210 protected JPanel gapColour = new JPanel();
212 protected JPanel hiddenColour = new JPanel();
214 protected JCheckBox useLegacyGap;
216 protected JCheckBox showHiddenAtStart;
218 protected JLabel gapLabel;
221 * Connections tab components
223 protected JPanel connectTab;
225 protected JTable linkUrlTable = new JTable();
227 protected JButton editLink = new JButton();
229 protected JButton deleteLink = new JButton();
231 protected JTextField filterTB = new JTextField();
233 protected JButton doReset = new JButton();
235 protected JButton userOnly = new JButton();
237 protected JLabel httpLabel = new JLabel();
239 protected JLabel httpsLabel = new JLabel();
241 protected JLabel portLabel = new JLabel();
243 protected JLabel serverLabel = new JLabel();
245 protected JLabel portLabel2 = new JLabel();
247 protected JLabel serverLabel2 = new JLabel();
249 protected JLabel proxyAuthUsernameLabel = new JLabel();
251 protected JLabel proxyAuthPasswordLabel = new JLabel();
253 protected JLabel passwordNotStoredLabel = new JLabel();
255 protected JTextField proxyServerHttpTB = new JTextField();
257 protected JTextField proxyPortHttpTB = new JTextField();
259 protected JTextField proxyServerHttpsTB = new JTextField();
261 protected JTextField proxyPortHttpsTB = new JTextField();
263 protected JCheckBox proxyAuth = new JCheckBox();
265 protected JTextField proxyAuthUsernameTB = new JTextField();
267 protected JPasswordField proxyAuthPasswordPB = new JPasswordField();
269 protected JTextField defaultBrowser = new JTextField();
271 protected ButtonGroup proxyType = new ButtonGroup();
273 protected JRadioButton noProxy = new JRadioButton();
275 protected JRadioButton systemProxy = new JRadioButton();
277 protected JRadioButton customProxy = new JRadioButton();
279 protected JButton applyProxyButton = new JButton();
281 protected JCheckBox usagestats = new JCheckBox();
283 protected JCheckBox questionnaire = new JCheckBox();
285 protected JCheckBox versioncheck = new JCheckBox();
288 * Output tab components
290 protected JComboBox<Object> epsRendering = new JComboBox<>();
292 protected JComboBox<Object> htmlRendering = new JComboBox<>();
294 protected JComboBox<Object> svgRendering = new JComboBox<>();
296 protected JLabel userIdWidthlabel = new JLabel();
298 protected JCheckBox autoIdWidth = new JCheckBox();
300 protected JTextField userIdWidth = new JTextField();
302 protected JCheckBox blcjv = new JCheckBox();
304 protected JCheckBox pileupjv = new JCheckBox();
306 protected JCheckBox clustaljv = new JCheckBox();
308 protected JCheckBox msfjv = new JCheckBox();
310 protected JCheckBox fastajv = new JCheckBox();
312 protected JCheckBox pfamjv = new JCheckBox();
314 protected JCheckBox pirjv = new JCheckBox();
316 protected JCheckBox modellerOutput = new JCheckBox();
318 protected JCheckBox embbedBioJSON = new JCheckBox();
321 * Editing tab components
323 protected JCheckBox autoCalculateConsCheck = new JCheckBox();
325 protected JCheckBox padGaps = new JCheckBox();
327 protected JCheckBox sortByTree = new JCheckBox();
332 protected JPanel wsTab = new JPanel();
335 * Backups tab components
336 * a lot of these are member variables instead of local variables only so that they
337 * can be enabled/disabled easily in one go
340 protected JCheckBox enableBackupFiles = new JCheckBox();
342 protected JPanel presetsPanel = new JPanel();
344 protected JLabel presetsComboLabel = new JLabel();
346 protected JCheckBox customiseCheckbox = new JCheckBox();
348 protected JButton revertButton = new JButton();
350 protected JComboBox<Object> backupfilesPresetsCombo = new JComboBox<>();
352 private int backupfilesPresetsComboLastSelected = 0;
354 protected JPanel suffixPanel = new JPanel();
356 protected JPanel keepfilesPanel = new JPanel();
358 protected JPanel exampleFilesPanel = new JPanel();
360 protected JTextField suffixTemplate = new JTextField(null, 8);
362 protected JLabel suffixTemplateLabel = new JLabel();
364 protected JLabel suffixDigitsLabel = new JLabel();
366 protected JSpinner suffixDigitsSpinner = new JSpinner();
368 protected JalviewBooleanRadioButtons suffixReverse = new JalviewBooleanRadioButtons();
370 protected JalviewBooleanRadioButtons backupfilesKeepAll = new JalviewBooleanRadioButtons();
372 public JSpinner backupfilesRollMaxSpinner = new JSpinner();
374 protected JLabel oldBackupFilesLabel = new JLabel();
376 protected JalviewBooleanRadioButtons backupfilesConfirmDelete = new JalviewBooleanRadioButtons();
378 protected JTextArea backupfilesExampleLabel = new JTextArea();
380 private final JTabbedPane tabbedPane = new JTabbedPane();
382 private JLabel messageLabel = new JLabel("", JLabel.CENTER);
385 * Creates a new GPreferences object.
387 public GPreferences()
392 } catch (Exception ex)
394 ex.printStackTrace();
399 * Construct the panel and its tabbed sub-panels.
403 private void jbInit() throws Exception
405 // final JTabbedPane tabbedPane = new JTabbedPane();
406 this.setLayout(new BorderLayout());
408 // message label at top
409 this.add(messageLabel, BorderLayout.NORTH);
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
457 * Adding a clearMessage() so messages are cleared when changing tabs.
459 tabbedPane.addChangeListener(new ChangeListener()
461 private Component lastTab;
464 public void stateChanged(ChangeEvent e)
466 if (lastTab == structureTab
467 && tabbedPane.getSelectedComponent() != structureTab)
469 if (!validateStructure())
471 tabbedPane.setSelectedComponent(structureTab);
475 lastTab = tabbedPane.getSelectedComponent();
483 public void setMessage(String message)
487 messageLabel.setText(message);
488 messageLabel.setFont(LABEL_FONT_BOLD);
489 messageLabel.setForeground(Color.RED.darker());
490 messageLabel.revalidate();
491 messageLabel.repaint();
493 // note message not cleared if message is null. call clearMessage()
499 public void clearMessage()
501 // only repaint if message exists
502 if (messageLabel.getText() != null
503 && messageLabel.getText().length() > 0)
505 messageLabel.setText("");
506 messageLabel.revalidate();
507 messageLabel.repaint();
513 public static enum TabRef
515 CONNECTIONS_TAB, STRUCTURE_TAB
518 public void selectTab(TabRef selectTab)
520 // select a given tab - currently only for Connections
523 case CONNECTIONS_TAB:
524 tabbedPane.setSelectedComponent(connectTab);
527 tabbedPane.setSelectedComponent(structureTab);
534 * Initialises the Editing tabbed panel.
538 private JPanel initEditingTab()
540 JPanel editingTab = new JPanel();
541 editingTab.setLayout(null);
542 autoCalculateConsCheck.setFont(LABEL_FONT);
543 autoCalculateConsCheck.setText(
544 MessageManager.getString("label.autocalculate_consensus"));
545 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
546 padGaps.setFont(LABEL_FONT);
548 MessageManager.getString("label.pad_gaps_when_editing"));
549 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
550 sortByTree.setFont(LABEL_FONT);
552 .setText(MessageManager.getString("label.sort_with_new_tree"));
553 sortByTree.setToolTipText(MessageManager.getString(
554 "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
555 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
556 editingTab.add(autoCalculateConsCheck);
557 editingTab.add(padGaps);
558 editingTab.add(sortByTree);
563 * Initialises the Output tab
567 private JPanel initOutputTab()
569 JPanel outputTab = new JPanel();
570 outputTab.setLayout(null);
572 JLabel epsLabel = new JLabel(
573 MessageManager.formatMessage("label.rendering_style", "EPS"));
574 epsLabel.setFont(LABEL_FONT);
575 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
576 epsLabel.setBounds(new Rectangle(9, 31, 160, 24));
577 epsRendering.setFont(LABEL_FONT);
578 epsRendering.setBounds(new Rectangle(174, 34, 187, 21));
579 JLabel htmlLabel = new JLabel(
580 MessageManager.formatMessage("label.rendering_style", "HTML"));
581 htmlLabel.setFont(LABEL_FONT);
582 htmlLabel.setHorizontalAlignment(SwingConstants.RIGHT);
583 htmlLabel.setBounds(new Rectangle(9, 55, 160, 24));
584 htmlRendering.setFont(LABEL_FONT);
585 htmlRendering.setBounds(new Rectangle(174, 58, 187, 21));
586 JLabel svgLabel = new JLabel(
587 MessageManager.formatMessage("label.rendering_style", "SVG"));
588 svgLabel.setFont(LABEL_FONT);
589 svgLabel.setHorizontalAlignment(SwingConstants.RIGHT);
590 svgLabel.setBounds(new Rectangle(9, 79, 160, 24));
591 svgRendering.setFont(LABEL_FONT);
592 svgRendering.setBounds(new Rectangle(174, 82, 187, 21));
594 JLabel jLabel1 = new JLabel();
595 jLabel1.setFont(LABEL_FONT);
596 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
597 jLabel1.setText(MessageManager.getString("label.append_start_end"));
598 jLabel1.setFont(LABEL_FONT);
600 fastajv.setFont(LABEL_FONT);
601 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
602 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
603 blcjv.setText(MessageManager.getString("label.blc") + " ");
604 fastajv.setText(MessageManager.getString("label.fasta") + " ");
605 msfjv.setText(MessageManager.getString("label.msf") + " ");
606 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
607 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
608 msfjv.setFont(LABEL_FONT);
609 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
610 pirjv.setText(MessageManager.getString("label.pir") + " ");
611 JPanel jPanel11 = new JPanel();
612 jPanel11.setFont(LABEL_FONT);
613 TitledBorder titledBorder2 = new TitledBorder(
614 MessageManager.getString("label.file_output"));
615 jPanel11.setBorder(titledBorder2);
616 jPanel11.setBounds(new Rectangle(30, 120, 196, 182));
617 GridLayout gridLayout3 = new GridLayout();
618 jPanel11.setLayout(gridLayout3);
619 gridLayout3.setRows(8);
620 blcjv.setFont(LABEL_FONT);
621 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
622 clustaljv.setFont(LABEL_FONT);
623 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
624 pfamjv.setFont(LABEL_FONT);
625 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
626 pileupjv.setFont(LABEL_FONT);
627 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
628 pirjv.setFont(LABEL_FONT);
629 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
630 autoIdWidth.setFont(LABEL_FONT);
632 MessageManager.getString("label.automatically_set_id_width"));
633 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
634 .getString("label.adjusts_width_generated_eps_png")));
635 autoIdWidth.setBounds(new Rectangle(228, 144, 320, 23));
636 autoIdWidth.addActionListener(new ActionListener()
640 public void actionPerformed(ActionEvent e)
642 autoIdWidth_actionPerformed();
645 userIdWidthlabel.setFont(LABEL_FONT);
646 userIdWidthlabel.setText(
647 MessageManager.getString("label.figure_id_column_width"));
648 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
649 .getString("label.manually_specify_width_left_column")));
650 userIdWidthlabel.setToolTipText(
651 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
652 "label.manually_specify_width_left_column")));
653 userIdWidthlabel.setBounds(new Rectangle(236, 168, 320, 23));
654 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
655 userIdWidth.setText("");
656 userIdWidth.setBounds(new Rectangle(232, 192, 84, 23));
657 userIdWidth.addActionListener(new ActionListener()
661 public void actionPerformed(ActionEvent e)
663 userIdWidth_actionPerformed();
666 modellerOutput.setFont(LABEL_FONT);
668 .setText(MessageManager.getString("label.use_modeller_output"));
669 modellerOutput.setBounds(new Rectangle(228, 274, 320, 23));
670 embbedBioJSON.setFont(LABEL_FONT);
671 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
672 embbedBioJSON.setBounds(new Rectangle(228, 248, 250, 23));
674 jPanel11.add(jLabel1);
676 jPanel11.add(clustaljv);
677 jPanel11.add(fastajv);
679 jPanel11.add(pfamjv);
680 jPanel11.add(pileupjv);
682 outputTab.add(autoIdWidth);
683 outputTab.add(userIdWidth);
684 outputTab.add(userIdWidthlabel);
685 outputTab.add(modellerOutput);
686 if (!Platform.isJS())
689 * JalviewJS doesn't support Lineart option or SVG output
691 outputTab.add(embbedBioJSON);
692 outputTab.add(epsLabel);
693 outputTab.add(epsRendering);
694 outputTab.add(htmlLabel);
695 outputTab.add(htmlRendering);
696 outputTab.add(svgLabel);
697 outputTab.add(svgRendering);
699 outputTab.add(jPanel11);
704 * Initialises the Connections tabbed panel.
708 private JPanel initConnectionsTab()
710 connectTab = new JPanel();
711 connectTab.setLayout(new GridBagLayout());
713 // Label for browser text box
714 JLabel browserLabel = new JLabel();
715 browserLabel.setFont(LABEL_FONT);
716 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
717 browserLabel.setText(
718 MessageManager.getString("label.default_browser_unix"));
719 defaultBrowser.setFont(LABEL_FONT);
720 defaultBrowser.setText("");
721 final String tooltip = JvSwingUtils.wrapTooltip(true,
722 MessageManager.getString("label.double_click_to_browse"));
723 defaultBrowser.setToolTipText(tooltip);
724 defaultBrowser.addMouseListener(new MouseAdapter()
727 public void mouseClicked(MouseEvent e)
729 if (e.getClickCount() > 1)
731 defaultBrowser_mouseClicked(e);
736 JPanel proxyPanel = initConnTabProxyPanel();
737 initConnTabCheckboxes();
739 // Add default Browser text box
740 connectTab.add(browserLabel,
741 new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
742 GridBagConstraints.WEST, GridBagConstraints.NONE,
743 new Insets(10, 0, 5, 5), 5, 1));
744 defaultBrowser.setFont(LABEL_FONT);
745 defaultBrowser.setText("");
747 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
748 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
749 new Insets(10, 0, 5, 10), 30, 1));
751 // Add proxy server panel
752 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
753 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
754 new Insets(10, 0, 5, 12), 4, 10));
756 // Add usage stats, version check and questionnaire checkboxes
757 connectTab.add(usagestats,
758 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
759 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
760 new Insets(0, 2, 5, 5), 70, 1));
761 connectTab.add(questionnaire,
762 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
763 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
764 new Insets(0, 2, 5, 10), 70, 1));
765 connectTab.add(versioncheck,
766 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
767 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
768 new Insets(0, 2, 5, 5), 70, 1));
770 versioncheck.setVisible(false);
772 // Add padding so the panel doesn't look ridiculous
773 JPanel spacePanel = new JPanel();
774 connectTab.add(spacePanel,
775 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
776 GridBagConstraints.WEST, GridBagConstraints.BOTH,
777 new Insets(0, 0, 0, 5), 70, 1));
783 * Initialises the Links tabbed panel.
787 private JPanel initLinksTab()
789 JPanel linkTab = new JPanel();
790 linkTab.setLayout(new GridBagLayout());
792 // Set up table for Url links
793 linkUrlTable.getTableHeader().setReorderingAllowed(false);
794 linkUrlTable.setFillsViewportHeight(true);
795 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
796 linkUrlTable.setAutoCreateRowSorter(true);
797 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
799 // adjust row height so radio buttons actually fit
800 // don't do this in the renderer, it causes the awt thread to activate
802 JRadioButton temp = new JRadioButton();
803 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
805 // Table in scrollpane so that the table is given a scrollbar
806 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
807 linkScrollPane.setBorder(null);
809 // Panel for links functionality
810 JPanel linkPanel = new JPanel(new GridBagLayout());
811 linkPanel.setBorder(new TitledBorder(
812 MessageManager.getString("label.url_linkfrom_sequence_id")));
814 // Put the Url links panel together
816 // Buttons go at top right, resizing only resizes the blank space vertically
817 JPanel buttonPanel = initLinkTabUrlButtons();
818 GridBagConstraints linkConstraints1 = new GridBagConstraints();
819 linkConstraints1.insets = new Insets(0, 0, 5, 0);
820 linkConstraints1.gridx = 0;
821 linkConstraints1.gridy = 0;
822 linkConstraints1.weightx = 1.0;
823 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
824 linkTab.add(buttonPanel, linkConstraints1);
826 // Links table goes at top left, resizing resizes the table
827 GridBagConstraints linkConstraints2 = new GridBagConstraints();
828 linkConstraints2.insets = new Insets(0, 0, 5, 5);
829 linkConstraints2.gridx = 0;
830 linkConstraints2.gridy = 1;
831 linkConstraints2.weightx = 1.0;
832 linkConstraints2.weighty = 1.0;
833 linkConstraints2.fill = GridBagConstraints.BOTH;
834 linkTab.add(linkScrollPane, linkConstraints2);
836 // Filter box and buttons goes at bottom left, resizing resizes the text box
837 JPanel filterPanel = initLinkTabFilterPanel();
838 GridBagConstraints linkConstraints3 = new GridBagConstraints();
839 linkConstraints3.insets = new Insets(0, 0, 0, 5);
840 linkConstraints3.gridx = 0;
841 linkConstraints3.gridy = 2;
842 linkConstraints3.weightx = 1.0;
843 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
844 linkTab.add(filterPanel, linkConstraints3);
849 private JPanel initLinkTabFilterPanel()
851 // Filter textbox and reset button
852 JLabel filterLabel = new JLabel(
853 MessageManager.getString("label.filter"));
854 filterLabel.setFont(LABEL_FONT);
855 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
856 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
858 filterTB.setFont(LABEL_FONT);
859 filterTB.setText("");
861 doReset.setText(MessageManager.getString("action.showall"));
862 userOnly.setText(MessageManager.getString("action.customfilter"));
864 // Panel for filter functionality
865 JPanel filterPanel = new JPanel(new GridBagLayout());
866 filterPanel.setBorder(new TitledBorder("Filter"));
867 GridBagConstraints gbc = new GridBagConstraints();
870 gbc.fill = GridBagConstraints.NONE;
871 gbc.anchor = GridBagConstraints.WEST;
873 filterPanel.add(filterLabel, gbc);
875 GridBagConstraints gbc1 = new GridBagConstraints();
878 gbc1.fill = GridBagConstraints.HORIZONTAL;
879 gbc1.anchor = GridBagConstraints.WEST;
881 filterPanel.add(filterTB, gbc1);
883 GridBagConstraints gbc2 = new GridBagConstraints();
885 gbc2.fill = GridBagConstraints.NONE;
886 gbc2.anchor = GridBagConstraints.WEST;
887 filterPanel.add(doReset, gbc2);
889 GridBagConstraints gbc3 = new GridBagConstraints();
891 gbc3.fill = GridBagConstraints.NONE;
892 gbc3.anchor = GridBagConstraints.WEST;
893 filterPanel.add(userOnly, gbc3);
898 private JPanel initLinkTabUrlButtons()
900 // Buttons for new / edit / delete Url links
901 JButton newLink = new JButton();
902 newLink.setText(MessageManager.getString("action.new"));
904 editLink.setText(MessageManager.getString("action.edit"));
906 deleteLink.setText(MessageManager.getString("action.delete"));
908 // no current selection, so initially disable delete/edit buttons
909 editLink.setEnabled(false);
910 deleteLink.setEnabled(false);
912 newLink.addActionListener(new java.awt.event.ActionListener()
915 public void actionPerformed(ActionEvent e)
917 newLink_actionPerformed(e);
921 editLink.setText(MessageManager.getString("action.edit"));
922 editLink.addActionListener(new java.awt.event.ActionListener()
925 public void actionPerformed(ActionEvent e)
927 editLink_actionPerformed(e);
931 deleteLink.setText(MessageManager.getString("action.delete"));
932 deleteLink.addActionListener(new java.awt.event.ActionListener()
935 public void actionPerformed(ActionEvent e)
937 deleteLink_actionPerformed(e);
941 JPanel buttonPanel = new JPanel(new GridBagLayout());
942 buttonPanel.setBorder(new TitledBorder("Edit links"));
943 GridBagConstraints gbc = new GridBagConstraints();
946 gbc.fill = GridBagConstraints.NONE;
947 buttonPanel.add(newLink, gbc);
949 GridBagConstraints gbc1 = new GridBagConstraints();
952 gbc1.fill = GridBagConstraints.NONE;
953 buttonPanel.add(editLink, gbc1);
955 GridBagConstraints gbc2 = new GridBagConstraints();
958 gbc2.fill = GridBagConstraints.NONE;
959 buttonPanel.add(deleteLink, gbc2);
961 GridBagConstraints gbc3 = new GridBagConstraints();
964 gbc3.fill = GridBagConstraints.HORIZONTAL;
966 JPanel spacePanel = new JPanel();
967 spacePanel.setBorder(null);
968 buttonPanel.add(spacePanel, gbc3);
974 * Initialises the proxy server panel in the Connections tab
976 * @return the proxy server panel
978 private JPanel initConnTabProxyPanel()
980 // Label for server text box
981 serverLabel.setText(MessageManager.getString("label.host") + ": ");
982 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
983 serverLabel.setFont(LABEL_FONT);
984 serverLabel2.setText(MessageManager.getString("label.host") + ": ");
985 serverLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
986 serverLabel2.setFont(LABEL_FONT);
988 // Proxy server and port text boxes
989 proxyServerHttpTB.setFont(LABEL_FONT);
990 proxyServerHttpTB.setColumns(40);
991 proxyPortHttpTB.setFont(LABEL_FONT);
992 proxyPortHttpTB.setColumns(4);
993 proxyServerHttpsTB.setFont(LABEL_FONT);
994 proxyServerHttpsTB.setColumns(40);
995 proxyPortHttpsTB.setFont(LABEL_FONT);
996 proxyPortHttpsTB.setColumns(4);
997 proxyAuthUsernameTB.setFont(LABEL_FONT);
998 proxyAuthUsernameTB.setColumns(30);
1000 // check for any change to enable applyProxyButton
1001 DocumentListener d = new DocumentListener()
1004 public void changedUpdate(DocumentEvent e)
1006 applyProxyButtonEnabled(true);
1010 public void insertUpdate(DocumentEvent e)
1012 applyProxyButtonEnabled(true);
1016 public void removeUpdate(DocumentEvent e)
1018 applyProxyButtonEnabled(true);
1021 proxyServerHttpTB.getDocument().addDocumentListener(d);
1022 proxyPortHttpTB.getDocument().addDocumentListener(d);
1023 proxyServerHttpsTB.getDocument().addDocumentListener(d);
1024 proxyPortHttpsTB.getDocument().addDocumentListener(d);
1025 proxyAuthUsernameTB.getDocument().addDocumentListener(d);
1026 proxyAuthPasswordPB.setFont(LABEL_FONT);
1027 proxyAuthPasswordPB.setColumns(30);
1028 proxyAuthPasswordPB.getDocument()
1029 .addDocumentListener(new DocumentListener()
1032 public void changedUpdate(DocumentEvent e)
1034 proxyAuthPasswordCheckHighlight(true);
1035 applyProxyButtonEnabled(true);
1039 public void insertUpdate(DocumentEvent e)
1041 proxyAuthPasswordCheckHighlight(true);
1042 applyProxyButtonEnabled(true);
1046 public void removeUpdate(DocumentEvent e)
1048 proxyAuthPasswordCheckHighlight(true);
1049 applyProxyButtonEnabled(true);
1054 // Label for Port text box
1055 portLabel.setFont(LABEL_FONT);
1056 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1057 portLabel.setText(MessageManager.getString("label.port") + ": ");
1058 portLabel2.setFont(LABEL_FONT);
1059 portLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
1060 portLabel2.setText(MessageManager.getString("label.port") + ": ");
1062 httpLabel.setText("HTTP");
1063 httpLabel.setFont(LABEL_FONT_BOLD);
1064 httpLabel.setHorizontalAlignment(SwingConstants.LEFT);
1065 httpsLabel.setText("HTTPS");
1066 httpsLabel.setFont(LABEL_FONT_BOLD);
1067 httpsLabel.setHorizontalAlignment(SwingConstants.LEFT);
1069 proxyAuthUsernameLabel
1070 .setText(MessageManager.getString("label.username") + ": ");
1071 proxyAuthUsernameLabel.setFont(LABEL_FONT);
1072 proxyAuthUsernameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1073 proxyAuthPasswordLabel
1074 .setText(MessageManager.getString("label.password") + ": ");
1075 proxyAuthPasswordLabel.setFont(LABEL_FONT);
1076 proxyAuthPasswordLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1077 passwordNotStoredLabel.setText(
1078 "(" + MessageManager.getString("label.not_stored") + ")");
1079 passwordNotStoredLabel.setFont(LABEL_FONT_ITALIC);
1080 passwordNotStoredLabel.setHorizontalAlignment(SwingConstants.LEFT);
1082 // Proxy type radio buttons
1083 noProxy.setFont(LABEL_FONT);
1084 noProxy.setHorizontalAlignment(SwingConstants.LEFT);
1085 noProxy.setText(MessageManager.getString("label.no_proxy"));
1086 systemProxy.setFont(LABEL_FONT);
1087 systemProxy.setHorizontalAlignment(SwingConstants.LEFT);
1088 systemProxy.setText(MessageManager.formatMessage("label.system_proxy",
1089 displayUserHostPort(Cache.startupProxyProperties[4],
1090 Cache.startupProxyProperties[0],
1091 Cache.startupProxyProperties[1]),
1092 displayUserHostPort(Cache.startupProxyProperties[6],
1093 Cache.startupProxyProperties[2],
1094 Cache.startupProxyProperties[3])));
1095 customProxy.setFont(LABEL_FONT);
1096 customProxy.setHorizontalAlignment(SwingConstants.LEFT);
1097 customProxy.setText(
1098 MessageManager.getString("label.use_proxy_server") + ":");
1099 ActionListener al = new ActionListener()
1102 public void actionPerformed(ActionEvent e)
1104 proxyType_actionPerformed();
1107 noProxy.addActionListener(al);
1108 systemProxy.addActionListener(al);
1109 customProxy.addActionListener(al);
1110 proxyType.add(noProxy);
1111 proxyType.add(systemProxy);
1112 proxyType.add(customProxy);
1114 proxyAuth.setFont(LABEL_FONT);
1115 proxyAuth.setHorizontalAlignment(SwingConstants.LEFT);
1116 proxyAuth.setText(MessageManager.getString("label.auth_required"));
1117 proxyAuth.addActionListener(new ActionListener()
1120 public void actionPerformed(ActionEvent e)
1122 proxyAuth_actionPerformed();
1126 setCustomProxyEnabled();
1128 // Make proxy server panel
1129 JPanel proxyPanel = new JPanel();
1130 TitledBorder titledBorder1 = new TitledBorder(
1131 MessageManager.getString("label.proxy_servers"));
1132 proxyPanel.setBorder(titledBorder1);
1133 proxyPanel.setLayout(new GridBagLayout());
1134 GridBagConstraints gbc = new GridBagConstraints();
1135 gbc.fill = GridBagConstraints.HORIZONTAL;
1138 GridBagConstraints c = new GridBagConstraints();
1139 // Proxy type radio buttons (3)
1140 JPanel ptPanel = new JPanel();
1141 ptPanel.setLayout(new GridBagLayout());
1146 c.fill = GridBagConstraints.HORIZONTAL;
1147 ptPanel.add(noProxy, c);
1149 ptPanel.add(systemProxy, c);
1151 ptPanel.add(customProxy, c);
1154 proxyPanel.add(ptPanel, gbc);
1156 // host and port text boxes
1157 JPanel hpPanel = new JPanel();
1158 hpPanel.setLayout(new GridBagLayout());
1159 // HTTP host port row
1164 c.anchor = GridBagConstraints.LINE_START;
1165 hpPanel.add(httpLabel, c);
1169 c.anchor = GridBagConstraints.LINE_END;
1170 hpPanel.add(serverLabel, c);
1174 c.anchor = GridBagConstraints.LINE_START;
1175 hpPanel.add(proxyServerHttpTB, c);
1179 c.anchor = GridBagConstraints.LINE_END;
1180 hpPanel.add(portLabel, c);
1184 c.anchor = GridBagConstraints.LINE_START;
1185 hpPanel.add(proxyPortHttpTB, c);
1187 // HTTPS host port row
1192 c.anchor = GridBagConstraints.LINE_START;
1193 hpPanel.add(httpsLabel, c);
1196 c.anchor = GridBagConstraints.LINE_END;
1197 hpPanel.add(serverLabel2, c);
1200 c.anchor = GridBagConstraints.LINE_START;
1201 hpPanel.add(proxyServerHttpsTB, c);
1204 c.anchor = GridBagConstraints.LINE_END;
1205 hpPanel.add(portLabel2, c);
1208 c.anchor = GridBagConstraints.LINE_START;
1209 hpPanel.add(proxyPortHttpsTB, c);
1212 proxyPanel.add(hpPanel, gbc);
1214 if (!Platform.isJS())
1216 * java.net.Authenticator is not implemented in SwingJS. Not displaying the
1217 * Authentication options in Preferences.
1223 // Require authentication checkbox
1225 proxyPanel.add(proxyAuth, gbc);
1227 // username and password
1228 JPanel upPanel = new JPanel();
1229 upPanel.setLayout(new GridBagLayout());
1235 c.anchor = GridBagConstraints.LINE_END;
1236 upPanel.add(proxyAuthUsernameLabel, c);
1240 c.anchor = GridBagConstraints.LINE_START;
1241 upPanel.add(proxyAuthUsernameTB, c);
1247 c.anchor = GridBagConstraints.LINE_END;
1248 upPanel.add(proxyAuthPasswordLabel, c);
1252 c.anchor = GridBagConstraints.LINE_START;
1253 upPanel.add(proxyAuthPasswordPB, c);
1257 c.anchor = GridBagConstraints.LINE_START;
1258 upPanel.add(passwordNotStoredLabel, c);
1261 proxyPanel.add(upPanel, gbc);
1265 applyProxyButton.setText(MessageManager.getString("action.apply"));
1266 applyProxyButton.addActionListener(new ActionListener()
1269 public void actionPerformed(ActionEvent e)
1271 saveProxySettings();
1272 applyProxyButton.setEnabled(false);
1276 gbc.fill = GridBagConstraints.NONE;
1277 gbc.anchor = GridBagConstraints.LINE_END;
1278 proxyPanel.add(applyProxyButton, gbc);
1283 public void proxyAuthPasswordCheckHighlight(boolean enabled)
1285 proxyAuthPasswordCheckHighlight(enabled, false);
1288 public void proxyAuthPasswordCheckHighlight(boolean enabled,
1291 if (enabled && proxyType.isSelected(customProxy.getModel())
1292 && proxyAuth.isSelected()
1293 && !proxyAuthUsernameTB.getText().isEmpty()
1294 && proxyAuthPasswordPB.getDocument().getLength() == 0)
1297 proxyAuthPasswordPB.grabFocus();
1298 proxyAuthPasswordPB.setBackground(Color.PINK);
1302 proxyAuthPasswordPB.setBackground(Color.WHITE);
1306 public void applyProxyButtonEnabled(boolean enabled)
1308 applyProxyButton.setEnabled(enabled);
1311 public void saveProxySettings()
1313 // overridden in Preferences
1316 private String displayUserHostPort(String user, String host, String port)
1318 boolean hostBlank = (host == null || host.isEmpty());
1319 boolean portBlank = (port == null || port.isEmpty());
1320 if (hostBlank && portBlank)
1322 return MessageManager.getString("label.none");
1325 StringBuilder sb = new StringBuilder();
1328 sb.append(user.isEmpty() || user.indexOf(" ") > -1 ? '"' + user + '"'
1332 sb.append(hostBlank ? "" : host);
1338 return sb.toString();
1342 * Initialises the checkboxes in the Connections tab
1344 private void initConnTabCheckboxes()
1346 // Usage stats checkbox label
1348 MessageManager.getString("label.send_usage_statistics"));
1349 usagestats.setFont(LABEL_FONT);
1350 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
1351 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
1353 // Questionnaire checkbox label
1354 questionnaire.setText(
1355 MessageManager.getString("label.check_for_questionnaires"));
1356 questionnaire.setFont(LABEL_FONT);
1357 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
1358 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
1360 // Check for latest version checkbox label
1361 versioncheck.setText(
1362 MessageManager.getString("label.check_for_latest_version"));
1363 versioncheck.setFont(LABEL_FONT);
1364 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
1365 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
1369 * Initialises the parent panel which contains the tabbed sections.
1373 private JPanel initOkCancelPanel()
1375 JButton ok = new JButton();
1376 ok.setText(MessageManager.getString("action.ok"));
1377 ok.addActionListener(new ActionListener()
1380 public void actionPerformed(ActionEvent e)
1382 ok_actionPerformed(e);
1385 JButton cancel = new JButton();
1386 cancel.setText(MessageManager.getString("action.cancel"));
1387 cancel.addActionListener(new ActionListener()
1390 public void actionPerformed(ActionEvent e)
1392 cancel_actionPerformed(e);
1395 JPanel okCancelPanel = new JPanel();
1396 okCancelPanel.add(ok);
1397 okCancelPanel.add(cancel);
1398 return okCancelPanel;
1402 * Initialises the Colours tabbed panel.
1406 private JPanel initColoursTab()
1408 JPanel coloursTab = new JPanel();
1409 coloursTab.setBorder(new TitledBorder(
1410 MessageManager.getString("action.open_new_alignment")));
1411 coloursTab.setLayout(new FlowLayout());
1412 JLabel mincolourLabel = new JLabel();
1413 mincolourLabel.setFont(LABEL_FONT);
1414 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1415 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
1416 minColour.setFont(LABEL_FONT);
1417 minColour.setBorder(BorderFactory.createEtchedBorder());
1418 minColour.setPreferredSize(new Dimension(40, 20));
1419 minColour.addMouseListener(new MouseAdapter()
1422 public void mousePressed(MouseEvent e)
1424 minColour_actionPerformed(minColour);
1427 JLabel maxcolourLabel = new JLabel();
1428 maxcolourLabel.setFont(LABEL_FONT);
1429 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1430 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
1431 maxColour.setFont(LABEL_FONT);
1432 maxColour.setBorder(BorderFactory.createEtchedBorder());
1433 maxColour.setPreferredSize(new Dimension(40, 20));
1434 maxColour.addMouseListener(new MouseAdapter()
1437 public void mousePressed(MouseEvent e)
1439 maxColour_actionPerformed(maxColour);
1443 protColour.setFont(LABEL_FONT);
1444 protColour.setBounds(new Rectangle(172, 225, 155, 21));
1445 JLabel protColourLabel = new JLabel();
1446 protColourLabel.setFont(LABEL_FONT);
1447 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1448 protColourLabel.setText(
1449 MessageManager.getString("label.prot_alignment_colour") + " ");
1450 JvSwingUtils.addtoLayout(coloursTab,
1452 .getString("label.default_colour_scheme_for_alignment"),
1453 protColourLabel, protColour);
1455 nucColour.setFont(LABEL_FONT);
1456 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1457 JLabel nucColourLabel = new JLabel();
1458 nucColourLabel.setFont(LABEL_FONT);
1459 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1460 nucColourLabel.setText(
1461 MessageManager.getString("label.nuc_alignment_colour") + " ");
1462 JvSwingUtils.addtoLayout(coloursTab,
1464 .getString("label.default_colour_scheme_for_alignment"),
1465 nucColourLabel, nucColour);
1467 JPanel annotationShding = new JPanel();
1468 annotationShding.setBorder(new TitledBorder(
1469 MessageManager.getString("label.annotation_shading_default")));
1470 annotationShding.setLayout(new GridLayout(1, 2));
1471 JvSwingUtils.addtoLayout(annotationShding,
1472 MessageManager.getString(
1473 "label.default_minimum_colour_annotation_shading"),
1474 mincolourLabel, minColour);
1475 JvSwingUtils.addtoLayout(annotationShding,
1476 MessageManager.getString(
1477 "label.default_maximum_colour_annotation_shading"),
1478 maxcolourLabel, maxColour);
1479 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1484 * Initialises the Overview tabbed panel.
1488 private JPanel initOverviewTab()
1490 JPanel overviewPanel = new JPanel();
1491 overviewPanel.setBorder(new TitledBorder(
1492 MessageManager.getString("label.overview_settings")));
1494 gapColour.setFont(LABEL_FONT);
1495 // fixing the border colours stops apparent colour bleed from the panel
1496 gapColour.setBorder(
1497 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1498 gapColour.setPreferredSize(new Dimension(40, 20));
1499 gapColour.addMouseListener(new MouseAdapter()
1502 public void mousePressed(MouseEvent e)
1504 gapColour_actionPerformed(gapColour);
1508 hiddenColour.setFont(LABEL_FONT);
1509 // fixing the border colours stops apparent colour bleed from the panel
1510 hiddenColour.setBorder(
1511 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1512 hiddenColour.setPreferredSize(new Dimension(40, 20));
1513 hiddenColour.addMouseListener(new MouseAdapter()
1516 public void mousePressed(MouseEvent e)
1518 hiddenColour_actionPerformed(hiddenColour);
1522 useLegacyGap = new JCheckBox(
1523 MessageManager.getString("label.ov_legacy_gap"));
1524 useLegacyGap.setFont(LABEL_FONT);
1525 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1526 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1527 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1528 gapLabel.setFont(LABEL_FONT);
1529 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1530 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1531 showHiddenAtStart = new JCheckBox(
1532 MessageManager.getString("label.ov_show_hide_default"));
1533 showHiddenAtStart.setFont(LABEL_FONT);
1534 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1535 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1536 JLabel hiddenLabel = new JLabel(
1537 MessageManager.getString("label.hidden_colour"));
1538 hiddenLabel.setFont(LABEL_FONT);
1539 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1540 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1542 useLegacyGap.addActionListener(new ActionListener()
1545 public void actionPerformed(ActionEvent e)
1547 useLegacyGaps_actionPerformed(e);
1551 overviewPanel.setLayout(new GridBagLayout());
1552 GridBagConstraints c1 = new GridBagConstraints();
1554 c1.fill = GridBagConstraints.HORIZONTAL;
1559 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1560 overviewPanel.add(useLegacyGap, c1);
1562 GridBagConstraints c2 = new GridBagConstraints();
1563 c2.fill = GridBagConstraints.HORIZONTAL;
1566 c2.insets = new Insets(0, 15, 0, 10);
1567 overviewPanel.add(gapLabel, c2);
1569 GridBagConstraints c3 = new GridBagConstraints();
1570 c3.fill = GridBagConstraints.HORIZONTAL;
1573 c3.insets = new Insets(0, 0, 0, 15);
1574 overviewPanel.add(gapColour, c3);
1576 GridBagConstraints c4 = new GridBagConstraints();
1577 c4.fill = GridBagConstraints.HORIZONTAL;
1581 overviewPanel.add(showHiddenAtStart, c4);
1583 GridBagConstraints c5 = new GridBagConstraints();
1584 c5.fill = GridBagConstraints.HORIZONTAL;
1587 c5.insets = new Insets(0, 15, 0, 10);
1588 overviewPanel.add(hiddenLabel, c5);
1590 GridBagConstraints c6 = new GridBagConstraints();
1591 c6.fill = GridBagConstraints.HORIZONTAL;
1594 c6.insets = new Insets(0, 0, 0, 15);
1595 overviewPanel.add(hiddenColour, c6);
1597 JButton resetButton = new JButton(
1598 MessageManager.getString("label.reset_to_defaults"));
1600 resetButton.addActionListener(new ActionListener()
1603 public void actionPerformed(ActionEvent e)
1605 resetOvDefaults_actionPerformed(e);
1609 GridBagConstraints c7 = new GridBagConstraints();
1610 c7.fill = GridBagConstraints.NONE;
1613 c7.insets = new Insets(10, 0, 0, 0);
1614 c7.anchor = GridBagConstraints.WEST;
1615 overviewPanel.add(resetButton, c7);
1617 // Add padding so the panel doesn't look ridiculous
1618 JPanel spacePanel = new JPanel();
1619 overviewPanel.add(spacePanel,
1620 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1621 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1622 new Insets(0, 0, 0, 5), 0, 0));
1624 return overviewPanel;
1628 * Initialises the Structure tabbed panel.
1632 private JPanel initStructureTab()
1634 structureTab = new JPanel();
1636 structureTab.setBorder(new TitledBorder(
1637 MessageManager.getString("label.structure_options")));
1638 structureTab.setLayout(null);
1639 final int width = 420;
1640 final int height = 22;
1641 final int lineSpacing = 25;
1644 structFromPdb.setFont(LABEL_FONT);
1646 .setText(MessageManager.getString("label.struct_from_pdb"));
1647 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1648 structFromPdb.addActionListener(new ActionListener()
1651 public void actionPerformed(ActionEvent e)
1653 boolean selected = structFromPdb.isSelected();
1654 // enable other options only when the first is checked
1655 useRnaView.setEnabled(selected);
1656 addSecondaryStructure.setEnabled(selected);
1657 addTempFactor.setEnabled(selected);
1660 structureTab.add(structFromPdb);
1662 // indent checkboxes that are conditional on the first one
1663 ypos += lineSpacing;
1664 useRnaView.setFont(LABEL_FONT);
1665 useRnaView.setText(MessageManager.getString("label.use_rnaview"));
1666 useRnaView.setBounds(new Rectangle(25, ypos, width, height));
1667 structureTab.add(useRnaView);
1669 ypos += lineSpacing;
1670 addSecondaryStructure.setFont(LABEL_FONT);
1671 addSecondaryStructure
1672 .setText(MessageManager.getString("label.autoadd_secstr"));
1673 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1674 structureTab.add(addSecondaryStructure);
1676 ypos += lineSpacing;
1677 addTempFactor.setFont(LABEL_FONT);
1678 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1679 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1680 structureTab.add(addTempFactor);
1682 ypos += lineSpacing;
1683 JLabel viewerLabel = new JLabel();
1684 viewerLabel.setFont(LABEL_FONT);
1685 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1686 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1687 viewerLabel.setBounds(new Rectangle(10, ypos, 220, height));
1688 structureTab.add(viewerLabel);
1691 * add all external viewers as options here - check
1692 * when selected whether the program is installed
1694 structViewer.setFont(LABEL_FONT);
1695 structViewer.setBounds(new Rectangle(190, ypos, 120, height));
1696 structViewer.addItem(ViewerType.JMOL.name());
1697 structViewer.addItem(ViewerType.CHIMERA.name());
1698 structViewer.addItem(ViewerType.CHIMERAX.name());
1699 structViewer.addItem(ViewerType.PYMOL.name());
1700 structViewer.addActionListener(new ActionListener()
1703 public void actionPerformed(ActionEvent e)
1705 structureViewer_actionPerformed(
1706 (String) structViewer.getSelectedItem());
1709 structureTab.add(structViewer);
1711 ypos += lineSpacing;
1712 structureViewerPathLabel = new JLabel();
1713 structureViewerPathLabel.setFont(LABEL_FONT);// new Font("SansSerif", 0,
1715 structureViewerPathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1716 structureViewerPathLabel.setText(MessageManager
1717 .formatMessage("label.viewer_path", "Chimera(X)"));
1718 structureViewerPathLabel
1719 .setBounds(new Rectangle(10, ypos, 170, height));
1720 structureViewerPathLabel.setEnabled(false);
1721 structureTab.add(structureViewerPathLabel);
1723 structureViewerPath.setFont(LABEL_FONT);
1724 structureViewerPath.setText("");
1725 structureViewerPath.setEnabled(false);
1726 final String tooltip = JvSwingUtils.wrapTooltip(true,
1727 MessageManager.getString("label.viewer_path_tip"));
1728 structureViewerPath.setToolTipText(tooltip);
1729 structureViewerPath.setBounds(new Rectangle(190, ypos, 290, height));
1730 structureViewerPath.addMouseListener(new MouseAdapter()
1733 public void mouseClicked(MouseEvent e)
1735 if (structureViewerPath.isEnabled() && e.getClickCount() == 2)
1737 String chosen = openFileChooser();
1740 structureViewerPath.setText(chosen);
1745 structureTab.add(structureViewerPath);
1747 ypos += lineSpacing;
1748 nwMapping.setFont(LABEL_FONT);
1749 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1750 siftsMapping.setFont(LABEL_FONT);
1751 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1752 mappingMethod.add(nwMapping);
1753 mappingMethod.add(siftsMapping);
1754 JPanel mappingPanel = new JPanel();
1755 mappingPanel.setFont(LABEL_FONT);
1756 TitledBorder mmTitledBorder = new TitledBorder(
1757 MessageManager.getString("label.mapping_method"));
1758 mmTitledBorder.setTitleFont(LABEL_FONT);
1759 mappingPanel.setBorder(mmTitledBorder);
1760 mappingPanel.setBounds(new Rectangle(10, ypos, 472, 45));
1761 // GridLayout mappingLayout = new GridLayout();
1762 mappingPanel.setLayout(new GridLayout());
1763 mappingPanel.add(nwMapping);
1764 mappingPanel.add(siftsMapping);
1765 structureTab.add(mappingPanel);
1767 ypos += lineSpacing;
1768 ypos += lineSpacing;
1769 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1770 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1771 docFieldPref.setBounds(new Rectangle(10, ypos, 470, 120));
1772 structureTab.add(docFieldPref);
1775 * hide Chimera options in JalviewJS
1777 if (Platform.isJS())
1779 structureViewerPathLabel.setVisible(false);
1780 structureViewerPath.setVisible(false);
1781 viewerLabel.setVisible(false);
1782 structViewer.setVisible(false);
1785 return structureTab;
1789 * Action on choosing a structure viewer from combobox options.
1791 * @param selectedItem
1793 protected void structureViewer_actionPerformed(String selectedItem)
1798 * Show a dialog for the user to choose a file. Returns the chosen path, or null
1803 protected String openFileChooser()
1805 String choice = null;
1806 JFileChooser chooser = new JFileChooser();
1808 // Enable appBundleIsTraversable in macOS FileChooser to allow selecting
1809 // hidden executables within .app dirs
1810 if (Platform.isMac())
1812 chooser.putClientProperty("JFileChooser.appBundleIsTraversable",
1816 // chooser.setFileView(new JalviewFileView());
1817 chooser.setDialogTitle(
1818 MessageManager.getString("label.open_local_file"));
1819 chooser.setToolTipText(MessageManager.getString("action.open"));
1821 int value = chooser.showOpenDialog(this);
1823 if (value == JFileChooser.APPROVE_OPTION)
1825 choice = chooser.getSelectedFile().getPath();
1831 * Validate the structure tab preferences; if invalid, set focus on this tab.
1835 protected boolean validateStructure(FocusEvent e)
1837 if (!validateStructure())
1839 e.getComponent().requestFocusInWindow();
1845 protected boolean validateStructure()
1851 * Initialises the Visual tabbed panel.
1855 private JPanel initVisualTab()
1857 JPanel visualTab = new JPanel();
1858 visualTab.setBorder(new TitledBorder(
1859 MessageManager.getString("action.open_new_alignment")));
1860 visualTab.setLayout(null);
1861 fullScreen.setFont(LABEL_FONT);
1862 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1863 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1864 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1865 quality.setEnabled(false);
1866 quality.setFont(LABEL_FONT);
1867 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1868 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1869 quality.setSelected(true);
1870 quality.setText(MessageManager.getString("label.quality"));
1871 conservation.setEnabled(false);
1872 conservation.setFont(LABEL_FONT);
1873 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1874 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1875 conservation.setSelected(true);
1876 conservation.setText(MessageManager.getString("label.conservation"));
1877 identity.setEnabled(false);
1878 identity.setFont(LABEL_FONT);
1879 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1880 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1881 identity.setSelected(true);
1882 identity.setText(MessageManager.getString("label.consensus"));
1883 showOccupancy.setFont(LABEL_FONT);
1884 showOccupancy.setEnabled(false);
1885 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1886 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1887 showOccupancy.setSelected(true);
1888 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1890 JLabel showGroupbits = new JLabel();
1891 showGroupbits.setFont(LABEL_FONT);
1892 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1893 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1895 .setText(MessageManager.getString("action.show_group") + ":");
1896 JLabel showConsensbits = new JLabel();
1897 showConsensbits.setFont(LABEL_FONT);
1898 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1899 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1901 .setText(MessageManager.getString("label.consensus") + ":");
1902 showConsensHistogram.setEnabled(false);
1903 showConsensHistogram.setFont(LABEL_FONT);
1904 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1905 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1906 showConsensHistogram.setSelected(true);
1907 showConsensHistogram
1908 .setText(MessageManager.getString("label.histogram"));
1909 showConsensLogo.setEnabled(false);
1910 showConsensLogo.setFont(LABEL_FONT);
1911 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1912 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1913 showConsensLogo.setSelected(true);
1914 showConsensLogo.setText(MessageManager.getString("label.logo"));
1915 showGroupConsensus.setEnabled(false);
1916 showGroupConsensus.setFont(LABEL_FONT);
1917 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1918 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1919 showGroupConsensus.setSelected(true);
1920 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1921 showGroupConservation.setEnabled(false);
1922 showGroupConservation.setFont(LABEL_FONT);
1923 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1924 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1925 showGroupConservation.setSelected(true);
1926 showGroupConservation
1927 .setText(MessageManager.getString("label.conservation"));
1928 showNpTooltip.setEnabled(true);
1929 showNpTooltip.setFont(LABEL_FONT);
1930 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1931 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1932 showNpTooltip.setSelected(true);
1933 showNpTooltip.setText(
1934 MessageManager.getString("label.non_positional_features"));
1935 showDbRefTooltip.setEnabled(true);
1936 showDbRefTooltip.setFont(LABEL_FONT);
1937 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1938 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1939 showDbRefTooltip.setSelected(true);
1941 .setText(MessageManager.getString("label.database_references"));
1942 annotations.setFont(LABEL_FONT);
1943 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1944 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1945 annotations.setSelected(true);
1946 annotations.setText(MessageManager.getString("label.show_annotations"));
1947 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1948 annotations.addActionListener(new ActionListener()
1951 public void actionPerformed(ActionEvent e)
1953 annotations_actionPerformed(e);
1956 identity.addActionListener(new ActionListener()
1959 public void actionPerformed(ActionEvent e)
1961 annotations_actionPerformed(e);
1964 showGroupConsensus.addActionListener(new ActionListener()
1967 public void actionPerformed(ActionEvent e)
1969 annotations_actionPerformed(e);
1972 showUnconserved.setFont(LABEL_FONT);
1973 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1974 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1975 showUnconserved.setSelected(true);
1977 .setText(MessageManager.getString("action.show_unconserved"));
1978 showUnconserved.addActionListener(new ActionListener()
1981 public void actionPerformed(ActionEvent e)
1983 showunconserved_actionPerformed(e);
1987 // TODO these are not yet added to / action from Preferences
1988 // JCheckBox shareSelections = new JCheckBox();
1989 // shareSelections.setFont(verdana11);
1990 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1991 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1992 // shareSelections.setSelected(true);
1993 // shareSelections.setText(MessageManager
1994 // .getString("label.share_selection_across_views"));
1995 // JCheckBox followHighlight = new JCheckBox();
1996 // followHighlight.setFont(verdana11);
1997 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1998 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1999 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
2000 // followHighlight.setSelected(true);
2001 // followHighlight.setText(MessageManager
2002 // .getString("label.scroll_highlighted_regions"));
2004 seqLimit.setFont(LABEL_FONT);
2005 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
2006 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
2007 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
2008 smoothFont.setFont(LABEL_FONT);
2009 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
2010 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
2011 smoothFont.setText(MessageManager.getString("label.smooth_font"));
2012 scaleProteinToCdna.setFont(LABEL_FONT);
2013 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
2014 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
2015 scaleProteinToCdna.setText(
2016 MessageManager.getString("label.scale_protein_to_cdna"));
2017 scaleProteinToCdna.setToolTipText(
2018 MessageManager.getString("label.scale_protein_to_cdna_tip"));
2019 JLabel gapLabel = new JLabel();
2020 gapLabel.setFont(LABEL_FONT);
2021 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2022 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
2023 JLabel fontLabel = new JLabel();
2024 fontLabel.setFont(LABEL_FONT);
2025 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2026 fontLabel.setText(MessageManager.getString("label.font"));
2027 fontSizeCB.setFont(LABEL_FONT);
2028 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
2029 fontStyleCB.setFont(LABEL_FONT);
2030 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
2031 fontNameCB.setFont(LABEL_FONT);
2032 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
2033 gapSymbolCB.setFont(LABEL_FONT);
2034 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
2035 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
2036 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
2037 gapSymbolCB.setRenderer(dlcr);
2039 startupCheckbox.setText(MessageManager.getString("action.open_file"));
2040 startupCheckbox.setFont(LABEL_FONT);
2041 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
2042 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
2043 startupCheckbox.setSelected(true);
2044 startupFileTextfield.setFont(LABEL_FONT);
2045 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
2046 final String tooltip = JvSwingUtils.wrapTooltip(true,
2047 MessageManager.getString("label.double_click_to_browse"));
2048 startupFileTextfield.setToolTipText(tooltip);
2049 startupFileTextfield.addMouseListener(new MouseAdapter()
2052 public void mouseClicked(MouseEvent e)
2054 if (e.getClickCount() > 1)
2056 startupFileTextfield_mouseClicked();
2061 sortby.setFont(LABEL_FONT);
2062 sortby.setBounds(new Rectangle(172, 260, 155, 21));
2063 JLabel sortLabel = new JLabel();
2064 sortLabel.setFont(LABEL_FONT);
2065 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2066 sortLabel.setText(MessageManager.getString("label.sort_by"));
2067 sortAnnBy.setFont(LABEL_FONT);
2068 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
2069 JLabel sortAnnLabel = new JLabel();
2070 sortAnnLabel.setFont(LABEL_FONT);
2071 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2072 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
2073 sortAutocalc.setFont(LABEL_FONT);
2074 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
2076 JPanel annsettingsPanel = new JPanel();
2077 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
2078 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
2079 annsettingsPanel.setBorder(new EtchedBorder());
2080 visualTab.add(annsettingsPanel);
2081 Border jb = new EmptyBorder(1, 1, 4, 5);
2082 annotations.setBorder(jb);
2083 showOccupancy.setBorder(jb);
2084 quality.setBorder(jb);
2085 conservation.setBorder(jb);
2086 identity.setBorder(jb);
2087 showConsensbits.setBorder(jb);
2088 showGroupbits.setBorder(jb);
2089 showGroupConsensus.setBorder(jb);
2090 showGroupConservation.setBorder(jb);
2091 showConsensHistogram.setBorder(jb);
2092 showConsensLogo.setBorder(jb);
2094 JPanel autoAnnotSettings = new JPanel();
2095 annsettingsPanel.add(autoAnnotSettings);
2096 autoAnnotSettings.setLayout(new GridLayout(0, 2));
2097 autoAnnotSettings.add(annotations);
2098 autoAnnotSettings.add(quality);
2099 // second row of autoannotation box
2100 autoAnnotSettings = new JPanel();
2101 annsettingsPanel.add(autoAnnotSettings);
2103 autoAnnotSettings.setLayout(new GridLayout(0, 3));
2104 autoAnnotSettings.add(conservation);
2105 autoAnnotSettings.add(identity);
2106 autoAnnotSettings.add(showOccupancy);
2107 autoAnnotSettings.add(showGroupbits);
2108 autoAnnotSettings.add(showGroupConservation);
2109 autoAnnotSettings.add(showGroupConsensus);
2110 autoAnnotSettings.add(showConsensbits);
2111 autoAnnotSettings.add(showConsensHistogram);
2112 autoAnnotSettings.add(showConsensLogo);
2114 JPanel tooltipSettings = new JPanel();
2115 tooltipSettings.setBorder(new TitledBorder(
2116 MessageManager.getString("label.sequence_id_tooltip")));
2117 tooltipSettings.setBounds(173, 140, 220, 62);
2118 tooltipSettings.setLayout(new GridLayout(2, 1));
2119 tooltipSettings.add(showDbRefTooltip);
2120 tooltipSettings.add(showNpTooltip);
2121 visualTab.add(tooltipSettings);
2123 wrap.setFont(LABEL_FONT);
2124 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
2125 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
2126 wrap.setText(MessageManager.getString("label.wrap_alignment"));
2127 rightAlign.setFont(LABEL_FONT);
2128 rightAlign.setForeground(Color.black);
2129 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
2130 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
2131 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
2132 idItalics.setFont(LABEL_FONT_ITALIC);
2133 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
2134 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
2136 MessageManager.getString("label.sequence_name_italics"));
2137 openoverv.setFont(LABEL_FONT);
2138 openoverv.setActionCommand(
2139 MessageManager.getString("label.open_overview"));
2140 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
2141 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
2142 openoverv.setText(MessageManager.getString("label.open_overview"));
2143 JPanel jPanel2 = new JPanel();
2144 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
2145 jPanel2.setLayout(new GridLayout(14, 1));
2146 jPanel2.add(fullScreen);
2147 jPanel2.add(openoverv);
2148 jPanel2.add(seqLimit);
2149 jPanel2.add(rightAlign);
2150 jPanel2.add(fontLabel);
2151 jPanel2.add(showUnconserved);
2152 jPanel2.add(idItalics);
2153 jPanel2.add(smoothFont);
2154 jPanel2.add(scaleProteinToCdna);
2155 jPanel2.add(gapLabel);
2157 jPanel2.add(sortLabel);
2158 jPanel2.add(sortAnnLabel);
2159 jPanel2.add(startupCheckbox);
2160 visualTab.add(jPanel2);
2161 visualTab.add(startupFileTextfield);
2162 visualTab.add(sortby);
2163 visualTab.add(sortAnnBy);
2164 visualTab.add(sortAutocalc);
2165 visualTab.add(gapSymbolCB);
2166 visualTab.add(fontNameCB);
2167 visualTab.add(fontSizeCB);
2168 visualTab.add(fontStyleCB);
2170 if (Platform.isJS())
2172 startupCheckbox.setVisible(false);
2173 startupFileTextfield.setVisible(false);
2180 * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
2183 protected void loadLastSavedBackupsOptions()
2185 BackupFilesPresetEntry savedPreset = BackupFilesPresetEntry
2186 .getSavedBackupEntry();
2187 enableBackupFiles.setSelected(
2188 Cache.getDefault(BackupFiles.ENABLED, !Platform.isJS()));
2190 BackupFilesPresetEntry backupfilesCustomEntry = BackupFilesPresetEntry
2191 .createBackupFilesPresetEntry(Cache
2192 .getDefault(BackupFilesPresetEntry.CUSTOMCONFIG, null));
2193 if (backupfilesCustomEntry == null)
2195 backupfilesCustomEntry = BackupFilesPresetEntry.backupfilesPresetEntriesValues
2196 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT);
2198 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
2199 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM,
2200 backupfilesCustomEntry);
2202 setComboIntStringKey(backupfilesPresetsCombo,
2203 Cache.getDefault(BackupFiles.NS + "_PRESET",
2204 BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT));
2206 backupsSetOptions(savedPreset);
2208 backupsOptionsSetEnabled();
2209 updateBackupFilesExampleLabel();
2212 private boolean warnAboutSuffixReverseChange()
2214 BackupFilesPresetEntry bfpe = BackupFilesPresetEntry
2215 .getSavedBackupEntry();
2216 boolean savedSuffixReverse = bfpe.reverse;
2217 int savedSuffixDigits = bfpe.digits;
2218 String savedSuffixTemplate = bfpe.suffix;
2220 boolean nowSuffixReverse = suffixReverse.isSelected();
2221 int nowSuffixDigits = getSpinnerInt(suffixDigitsSpinner, 3);
2222 String nowSuffixTemplate = suffixTemplate.getText();
2223 return nowSuffixReverse != savedSuffixReverse
2224 && nowSuffixDigits == savedSuffixDigits
2225 && nowSuffixTemplate != null
2226 && nowSuffixTemplate.equals(savedSuffixTemplate);
2230 * Initialises the Backups tabbed panel.
2234 private JPanel initBackupsTab()
2236 JPanel backupsTab = new JPanel();
2237 backupsTab.setBorder(new TitledBorder(
2238 MessageManager.getString("label.backup_files")));
2239 backupsTab.setLayout(new GridBagLayout());
2241 GridBagConstraints gbc = new GridBagConstraints();
2244 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2245 gbc.fill = GridBagConstraints.NONE;
2247 initBackupsTabPresetsPanel();
2248 initBackupsTabSuffixPanel();
2249 initBackupsTabKeepFilesPanel();
2250 initBackupsTabFilenameExamplesPanel();
2252 enableBackupFiles.setFont(LABEL_FONT_BOLD);
2254 .setText(MessageManager.getString("label.enable_backupfiles"));
2255 enableBackupFiles.addActionListener(new ActionListener()
2258 public void actionPerformed(ActionEvent e)
2260 // enable other options only when the first is checked
2261 backupsOptionsSetEnabled();
2265 // enable checkbox 1 col
2269 gbc.gridy = 0; // row 0
2270 backupsTab.add(enableBackupFiles, gbc);
2272 // summary of scheme box (over two rows)
2276 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
2277 gbc.fill = GridBagConstraints.BOTH;
2278 backupsTab.add(exampleFilesPanel, gbc);
2280 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2281 gbc.fill = GridBagConstraints.NONE;
2283 // fill empty space on right
2286 backupsTab.add(new JPanel(), gbc);
2291 gbc.gridy++; // row 1
2292 backupsTab.add(presetsPanel, gbc);
2294 // now using whole row
2299 gbc.gridy++; // row 2
2300 backupsTab.add(keepfilesPanel, gbc);
2302 // filename strategy box
2303 gbc.gridy++; // row 3
2304 backupsTab.add(suffixPanel, gbc);
2307 gbc.gridy++; // row 4
2309 backupsTab.add(new JPanel(), gbc);
2311 backupsOptionsSetEnabled();
2315 private JPanel initBackupsTabPresetsPanel()
2318 String title = MessageManager.getString("label.schemes");
2320 presetsPanel.setLayout(new GridBagLayout());
2322 GridBagConstraints gbc = new GridBagConstraints();
2325 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
2326 gbc.fill = GridBagConstraints.NONE;
2334 presetsComboLabel = new JLabel(title + ":");
2335 presetsPanel.add(presetsComboLabel, gbc);
2337 List<Object> entries = Arrays.asList(
2338 (Object[]) BackupFilesPresetEntry.backupfilesPresetEntries);
2339 List<String> tooltips = Arrays.asList(
2340 BackupFilesPresetEntry.backupfilesPresetEntryDescriptions);
2341 backupfilesPresetsCombo = JvSwingUtils.buildComboWithTooltips(entries,
2344 for (int i = 0; i < BackupFilesPresetEntry.backupfilesPresetEntries.length; i++)
2346 backupfilesPresetsCombo
2347 .addItem(BackupFilesPresetEntry.backupfilesPresetEntries[i]);
2351 backupfilesPresetsCombo.addActionListener(new ActionListener()
2354 public void actionPerformed(ActionEvent e)
2356 int key = getComboIntStringKey(backupfilesPresetsCombo);
2357 if (!customiseCheckbox.isSelected())
2359 backupfilesPresetsComboLastSelected = key;
2361 if (key == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
2363 if (customiseCheckbox.isSelected())
2365 // got here by clicking on customiseCheckbox so don't change the
2367 backupfilesCustomOptionsSetEnabled();
2371 backupsTabUpdatePresets();
2372 backupfilesCustomOptionsSetEnabled();
2377 customiseCheckbox.setSelected(false);
2378 backupsTabUpdatePresets();
2379 backupfilesCustomOptionsSetEnabled();
2384 // dropdown list of preset schemes
2386 presetsPanel.add(backupfilesPresetsCombo, gbc);
2388 revertButton.setText(MessageManager.getString("label.cancel_changes"));
2389 revertButton.setToolTipText(
2390 MessageManager.getString("label.cancel_changes_description"));
2391 revertButton.addActionListener(new ActionListener()
2394 public void actionPerformed(ActionEvent e)
2397 BackupFilesPresetEntry.backupfilesPresetEntriesValues.get(
2398 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM));
2399 backupfilesCustomOptionsSetEnabled();
2403 revertButton.setFont(LABEL_FONT);
2405 customiseCheckbox.setFont(LABEL_FONT);
2406 customiseCheckbox.setText(MessageManager.getString("label.customise"));
2407 customiseCheckbox.addActionListener(new ActionListener()
2410 public void actionPerformed(ActionEvent e)
2412 int currently = getComboIntStringKey(backupfilesPresetsCombo);
2413 if (customiseCheckbox.isSelected())
2415 backupfilesPresetsComboLastSelected = currently;
2416 setComboIntStringKey(backupfilesPresetsCombo,
2417 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2421 setComboIntStringKey(backupfilesPresetsCombo,
2422 backupfilesPresetsComboLastSelected);
2425 backupfilesCustomOptionsSetEnabled();
2428 customiseCheckbox.setToolTipText(
2429 MessageManager.getString("label.customise_description"));
2431 // customise checkbox
2434 presetsPanel.add(customiseCheckbox, gbc);
2436 // "Cancel changes" button (aligned with combo box above)
2438 presetsPanel.add(revertButton, gbc);
2440 return presetsPanel;
2443 private JPanel initBackupsTabFilenameExamplesPanel()
2445 String title = MessageManager.getString("label.scheme_examples");
2446 TitledBorder tb = new TitledBorder(title);
2447 exampleFilesPanel.setBorder(tb);
2448 exampleFilesPanel.setLayout(new GridBagLayout());
2450 backupfilesExampleLabel.setEditable(false);
2451 backupfilesExampleLabel
2452 .setBackground(exampleFilesPanel.getBackground());
2454 updateBackupFilesExampleLabel();
2456 GridBagConstraints gbc = new GridBagConstraints();
2459 gbc.fill = GridBagConstraints.NONE;
2460 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2462 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
2463 return exampleFilesPanel;
2466 private void backupsTabUpdatePresets()
2468 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
2471 String value = entry.v;
2473 if (BackupFilesPresetEntry.backupfilesPresetEntriesValues
2477 BackupFilesPresetEntry.backupfilesPresetEntriesValues
2483 "Preset '" + value + "' [key:" + key + "] not implemented");
2486 // Custom options will now be enabled when the customiseCheckbox is checked
2487 // (performed above)
2488 // backupfilesCustomOptionsSetEnabled();
2489 updateBackupFilesExampleLabel();
2492 protected int getComboIntStringKey(
2493 JComboBox<Object> backupfilesPresetsCombo2)
2495 IntKeyStringValueEntry e;
2498 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2
2500 } catch (Exception ex)
2503 "Problem casting Combo entry to IntKeyStringValueEntry.");
2506 return e != null ? e.k : 0;
2509 protected void setComboIntStringKey(
2510 JComboBox<Object> backupfilesPresetsCombo2, int key)
2512 for (int i = 0; i < backupfilesPresetsCombo2.getItemCount(); i++)
2514 IntKeyStringValueEntry e;
2517 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2.getItemAt(i);
2518 } catch (Exception ex)
2521 "Problem casting Combo entry to IntKeyStringValueEntry. Skipping item. ");
2526 backupfilesPresetsCombo2.setSelectedIndex(i);
2530 // backupsTabUpdatePresets();
2533 private JPanel initBackupsTabSuffixPanel()
2535 suffixPanel.setBorder(new TitledBorder(
2536 MessageManager.getString("label.backup_filename_strategy")));
2537 suffixPanel.setLayout(new GridBagLayout());
2540 .setText(MessageManager.getString("label.append_to_filename"));
2541 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
2542 suffixTemplateLabel.setFont(LABEL_FONT);
2544 final String tooltip = JvSwingUtils.wrapTooltip(true,
2545 MessageManager.getString("label.append_to_filename_tooltip"));
2546 suffixTemplate.setToolTipText(tooltip);
2547 suffixTemplate.addActionListener(new ActionListener()
2550 public void actionPerformed(ActionEvent e)
2552 updateBackupFilesExampleLabel();
2553 backupfilesCustomOptionsSetEnabled();
2554 backupfilesRevertButtonSetEnabled(true);
2558 suffixTemplate.addKeyListener(new KeyListener()
2561 public void keyReleased(KeyEvent e)
2563 updateBackupFilesExampleLabel();
2564 backupfilesCustomOptionsSetEnabled();
2565 backupfilesRevertButtonSetEnabled(true);
2569 public void keyPressed(KeyEvent e)
2573 // disable use of ':' or '/' or '\'
2575 public void keyTyped(KeyEvent e)
2577 char c = e.getKeyChar();
2578 if (c == ':' || c == '/' || c == '\\')
2580 // don't process ':' or '/' or '\'
2589 .setText(MessageManager.getString("label.index_digits"));
2590 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
2591 suffixDigitsLabel.setFont(LABEL_FONT);
2592 ChangeListener c = new ChangeListener()
2595 public void stateChanged(ChangeEvent e)
2597 backupfilesRevertButtonSetEnabled(true);
2598 updateBackupFilesExampleLabel();
2602 setIntegerSpinner(suffixDigitsSpinner, BackupFilesPresetEntry.DIGITSMIN,
2603 BackupFilesPresetEntry.DIGITSMAX, 3, c);
2605 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
2606 MessageManager.getString("label.increment_index"));
2607 suffixReverse.addActionListener(new ActionListener()
2610 public void actionPerformed(ActionEvent e)
2612 boolean okay = true;
2613 if (warnAboutSuffixReverseChange())
2616 okay = confirmSuffixReverseChange();
2620 backupfilesRevertButtonSetEnabled(true);
2621 updateBackupFilesExampleLabel();
2625 boolean savedSuffixReverse = BackupFilesPresetEntry
2626 .getSavedBackupEntry().reverse;
2627 suffixReverse.setSelected(savedSuffixReverse);
2632 GridBagConstraints sgbc = new GridBagConstraints();
2634 // first row (template text box)
2635 sgbc.anchor = GridBagConstraints.WEST;
2639 sgbc.gridheight = 1;
2642 sgbc.fill = GridBagConstraints.NONE;
2643 suffixPanel.add(suffixTemplateLabel, sgbc);
2646 sgbc.fill = GridBagConstraints.HORIZONTAL;
2647 suffixPanel.add(suffixTemplate, sgbc);
2649 // second row (number of digits spinner)
2653 sgbc.fill = GridBagConstraints.NONE;
2654 suffixPanel.add(suffixDigitsLabel, sgbc);
2657 sgbc.fill = GridBagConstraints.HORIZONTAL;
2658 suffixPanel.add(suffixDigitsSpinner, sgbc);
2660 // third row (forward order radio selection)
2663 sgbc.gridwidth = GridBagConstraints.REMAINDER;
2664 sgbc.fill = GridBagConstraints.HORIZONTAL;
2665 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
2667 // fourth row (reverse order radio selection)
2669 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
2673 private boolean confirmSuffixReverseChange()
2675 boolean ret = false;
2676 String warningMessage = MessageManager
2677 .getString("label.warning_confirm_change_reverse");
2678 int confirm = JvOptionPane.showConfirmDialog(Desktop.desktop,
2680 MessageManager.getString("label.change_increment_decrement"),
2681 JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE);
2683 ret = (confirm == JvOptionPane.YES_OPTION);
2687 private JPanel initBackupsTabKeepFilesPanel()
2689 keepfilesPanel.setBorder(
2690 new TitledBorder(MessageManager.getString("label.keep_files")));
2691 keepfilesPanel.setLayout(new GridBagLayout());
2693 backupfilesKeepAll.setLabels(
2694 MessageManager.getString("label.keep_all_backup_files"),
2695 MessageManager.getString(
2696 "label.keep_only_this_number_of_backup_files"));
2697 backupfilesKeepAll.addTrueActionListener(new ActionListener()
2700 public void actionPerformed(ActionEvent e)
2702 backupfilesRevertButtonSetEnabled(true);
2703 updateBackupFilesExampleLabel();
2706 backupfilesKeepAll.addActionListener(new ActionListener()
2709 public void actionPerformed(ActionEvent e)
2711 backupfilesRevertButtonSetEnabled(true);
2712 keepRollMaxOptionsEnabled();
2713 updateBackupFilesExampleLabel();
2717 ChangeListener c = new ChangeListener()
2720 public void stateChanged(ChangeEvent e)
2722 backupfilesRevertButtonSetEnabled(true);
2723 updateBackupFilesExampleLabel();
2727 setIntegerSpinner(backupfilesRollMaxSpinner,
2728 BackupFilesPresetEntry.ROLLMAXMIN,
2729 BackupFilesPresetEntry.ROLLMAXMAX, 4, true, c);
2731 backupfilesConfirmDelete.setLabels(
2732 MessageManager.getString("label.always_ask"),
2733 MessageManager.getString("label.auto_delete"));
2734 backupfilesConfirmDelete.addActionListener(new ActionListener()
2737 public void actionPerformed(ActionEvent e)
2739 backupfilesRevertButtonSetEnabled(true);
2742 // update the enabled section
2743 keepRollMaxOptionsEnabled();
2745 GridBagConstraints kgbc = new GridBagConstraints();
2747 // first row (template text box)
2748 kgbc.anchor = GridBagConstraints.WEST;
2751 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2752 kgbc.gridheight = 1;
2755 kgbc.fill = GridBagConstraints.HORIZONTAL;
2756 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
2762 kgbc.gridwidth = GridBagConstraints.RELATIVE;
2763 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
2766 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2767 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
2769 // third row (indented)
2771 kgbc.insets = new Insets(0, 20, 0, 0);
2774 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2775 kgbc.fill = GridBagConstraints.HORIZONTAL;
2778 JPanel jp = new JPanel();
2779 jp.setLayout(new FlowLayout());
2780 oldBackupFilesLabel.setText(
2781 MessageManager.getString("label.autodelete_old_backup_files"));
2782 oldBackupFilesLabel.setFont(LABEL_FONT);
2783 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
2784 jp.add(oldBackupFilesLabel);
2785 jp.add(backupfilesConfirmDelete.getTrueButton());
2786 jp.add(backupfilesConfirmDelete.getFalseButton());
2787 keepfilesPanel.add(jp, kgbc);
2789 return keepfilesPanel;
2792 protected void updateBackupFilesExampleLabel()
2794 int exampleindex = 12;
2795 String base = MessageManager.getString("label.filename") + ".fa";
2796 if (base == null || base.length() == 0)
2798 base = "file_name.fa";
2801 boolean reverse = suffixReverse.isSelected();
2802 boolean keepAll = backupfilesKeepAll.isSelected();
2804 String suffix = suffixTemplate.getText();
2807 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
2808 if (suffix == null || suffix.length() == 0)
2810 backupfilesExampleLabel
2811 .setText(MessageManager.getString("label.no_backup_files"));
2812 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
2816 rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 4);
2817 rollMax = rollMax < 1 ? 1 : rollMax;
2819 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
2824 digits = getSpinnerInt(suffixDigitsSpinner, 3);
2825 digits = digits < 1 ? 1 : digits;
2827 int lowersurround = 2;
2828 int uppersurround = 0;
2829 StringBuilder exampleSB = new StringBuilder();
2830 boolean firstLine = true;
2836 int max = keepAll ? exampleindex : rollMax;
2837 for (int index = min; index <= max; index++)
2839 if (index == min + lowersurround && index < max - uppersurround - 1)
2841 exampleSB.append("\n...");
2844 else if (index > min + lowersurround && index < max - uppersurround)
2856 exampleSB.append("\n");
2859 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2860 base, suffix, digits));
2863 // no extra text needed
2865 else if (index == min)
2867 String newest = MessageManager.getString("label.braced_newest");
2868 if (newest != null && newest.length() > 0)
2870 exampleSB.append(" " + newest);
2873 else if (index == max)
2875 String oldest = MessageManager.getString("label.braced_oldest");
2876 if (oldest != null && oldest.length() > 0)
2878 exampleSB.append(" " + oldest);
2887 int min = (keepAll || exampleindex - rollMax < 0) ? 1
2888 : exampleindex - rollMax + 1;
2889 int max = exampleindex;
2891 for (int index = min; index <= max; index++)
2894 if (index == min + lowersurround && index < max - uppersurround - 1)
2896 exampleSB.append("\n...");
2899 else if (index > min + lowersurround && index < max - uppersurround)
2911 exampleSB.append("\n");
2914 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2915 base, suffix, digits));
2918 // no extra text needed
2920 else if (index == min)
2922 String oldest = MessageManager.getString("label.braced_oldest");
2923 if (oldest != null && oldest.length() > 0)
2925 exampleSB.append(" " + oldest);
2928 else if (index == max)
2930 String newest = MessageManager.getString("label.braced_newest");
2931 if (newest != null && newest.length() > 0)
2933 exampleSB.append(" " + newest);
2941 // add some extra empty lines to pad out the example files box. ugh, please
2943 // me how to do this better
2944 int remainingLines = lowersurround + uppersurround + 1 - lineNumber;
2945 if (remainingLines > 0)
2947 for (int i = 0; i < remainingLines; i++)
2949 exampleSB.append("\n ");
2954 backupfilesExampleLabel.setText(exampleSB.toString());
2957 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2958 boolean useExistingVal, ChangeListener c)
2965 i = ((Integer) s.getValue()).intValue();
2966 } catch (Exception e)
2969 "Exception casting the initial value of s.getValue()");
2973 setIntegerSpinner(s, min, max, i, c);
2976 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2979 // integer spinner for number of digits
2988 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
2991 s.addChangeListener(c);
2995 protected static int getSpinnerInt(JSpinner s, int def)
3001 i = (Integer) s.getValue();
3002 } catch (Exception e)
3004 Cache.log.error("Failed casting (Integer) JSpinner s.getValue()");
3009 private void keepRollMaxOptionsEnabled()
3011 boolean enabled = backupfilesKeepAll.isEnabled()
3012 && !backupfilesKeepAll.isSelected();
3013 oldBackupFilesLabel.setEnabled(enabled);
3014 backupfilesRollMaxSpinner.setEnabled(enabled);
3015 backupfilesConfirmDelete.setEnabled(enabled);
3018 private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
3020 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3021 && customiseCheckbox.isSelected() && suffixTemplate.getText()
3022 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
3023 keepfilesPanel.setEnabled(enabled);
3024 backupfilesKeepAll.setEnabled(enabled);
3025 oldBackupFilesLabel.setEnabled(enabled);
3026 keepRollMaxOptionsEnabled();
3029 private void backupfilesSuffixTemplateDigitsSetEnabled()
3031 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
3032 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
3033 suffixDigitsLabel.setEnabled(enabled);
3034 suffixDigitsSpinner.setEnabled(enabled);
3035 suffixReverse.setEnabled(enabled);
3038 private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
3040 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3041 && customiseCheckbox.isSelected();
3042 suffixPanel.setEnabled(enabled);
3043 suffixTemplateLabel.setEnabled(enabled);
3044 suffixTemplate.setEnabled(enabled);
3045 backupfilesSuffixTemplateDigitsSetEnabled();
3048 private void backupfilesRevertButtonSetEnabled(boolean tryEnabled)
3050 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3051 && customiseCheckbox.isSelected() && backupfilesCustomChanged();
3052 revertButton.setEnabled(enabled);
3055 private boolean backupfilesCustomChanged()
3057 BackupFilesPresetEntry custom = BackupFilesPresetEntry.backupfilesPresetEntriesValues
3058 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
3059 BackupFilesPresetEntry current = getBackupfilesCurrentEntry();
3060 return !custom.equals(current);
3063 protected BackupFilesPresetEntry getBackupfilesCurrentEntry()
3065 String suffix = suffixTemplate.getText();
3066 int digits = getSpinnerInt(suffixDigitsSpinner, 3);
3067 boolean reverse = suffixReverse.isSelected();
3068 boolean keepAll = backupfilesKeepAll.isSelected();
3069 int rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 3);
3070 boolean confirmDelete = backupfilesConfirmDelete.isSelected();
3072 BackupFilesPresetEntry bfpe = new BackupFilesPresetEntry(suffix, digits,
3073 reverse, keepAll, rollMax, confirmDelete);
3078 protected void backupfilesCustomOptionsSetEnabled()
3080 boolean enabled = customiseCheckbox.isSelected();
3082 backupfilesRevertButtonSetEnabled(enabled);
3083 backupfilesSuffixTemplateSetEnabled(enabled);
3084 backupfilesKeepAllSetEnabled(enabled);
3087 private void backupfilesSummarySetEnabled()
3089 boolean enabled = enableBackupFiles.isSelected();
3090 backupfilesExampleLabel.setEnabled(enabled);
3091 exampleFilesPanel.setEnabled(enabled);
3094 private void backupfilesPresetsSetEnabled()
3096 boolean enabled = enableBackupFiles.isSelected();
3097 presetsPanel.setEnabled(enabled);
3098 presetsComboLabel.setEnabled(enabled);
3099 backupfilesPresetsCombo.setEnabled(enabled);
3100 customiseCheckbox.setEnabled(enabled);
3101 revertButton.setEnabled(enabled);
3104 protected void backupsOptionsSetEnabled()
3106 backupfilesPresetsSetEnabled();
3107 backupfilesSummarySetEnabled();
3108 backupfilesCustomOptionsSetEnabled();
3111 protected void backupsSetOptions(String suffix, int digits,
3112 boolean reverse, boolean keepAll, int rollMax,
3113 boolean confirmDelete)
3115 suffixTemplate.setText(suffix);
3116 suffixDigitsSpinner.setValue(digits);
3117 suffixReverse.setSelected(reverse);
3118 backupfilesKeepAll.setSelected(keepAll);
3119 backupfilesRollMaxSpinner.setValue(rollMax);
3120 backupfilesConfirmDelete.setSelected(confirmDelete);
3123 protected void backupsSetOptions(BackupFilesPresetEntry p)
3125 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
3129 protected void autoIdWidth_actionPerformed()
3131 // TODO Auto-generated method stub
3135 protected void userIdWidth_actionPerformed()
3137 // TODO Auto-generated method stub
3141 protected void maxColour_actionPerformed(JPanel panel)
3145 protected void minColour_actionPerformed(JPanel panel)
3149 protected void gapColour_actionPerformed(JPanel panel)
3153 protected void hiddenColour_actionPerformed(JPanel panel)
3157 protected void showunconserved_actionPerformed(ActionEvent e)
3159 // TODO Auto-generated method stub
3163 protected void useLegacyGaps_actionPerformed(ActionEvent e)
3167 protected void resetOvDefaults_actionPerformed(ActionEvent e)
3177 public void ok_actionPerformed(ActionEvent e)
3187 public void cancel_actionPerformed(ActionEvent e)
3197 public void annotations_actionPerformed(ActionEvent e)
3204 public void startupFileTextfield_mouseClicked()
3208 public void newLink_actionPerformed(ActionEvent e)
3213 public void editLink_actionPerformed(ActionEvent e)
3218 public void deleteLink_actionPerformed(ActionEvent e)
3223 public void defaultBrowser_mouseClicked(MouseEvent e)
3228 public void linkURLList_keyTyped(KeyEvent e)
3233 public void setProxyAuthEnabled()
3235 boolean enabled = proxyAuth.isSelected() && proxyAuth.isEnabled();
3236 proxyAuthUsernameLabel.setEnabled(enabled);
3237 proxyAuthPasswordLabel.setEnabled(enabled);
3238 passwordNotStoredLabel.setEnabled(enabled);
3239 proxyAuthUsernameTB.setEnabled(enabled);
3240 proxyAuthPasswordPB.setEnabled(enabled);
3243 public void setCustomProxyEnabled()
3245 boolean enabled = customProxy.isSelected();
3246 portLabel.setEnabled(enabled);
3247 serverLabel.setEnabled(enabled);
3248 portLabel2.setEnabled(enabled);
3249 serverLabel2.setEnabled(enabled);
3250 httpLabel.setEnabled(enabled);
3251 httpsLabel.setEnabled(enabled);
3252 proxyServerHttpTB.setEnabled(enabled);
3253 proxyPortHttpTB.setEnabled(enabled);
3254 proxyServerHttpsTB.setEnabled(enabled);
3255 proxyPortHttpsTB.setEnabled(enabled);
3256 proxyAuth.setEnabled(enabled);
3257 setProxyAuthEnabled();
3260 public void proxyType_actionPerformed()
3262 setCustomProxyEnabled();
3263 proxyAuthPasswordCheckHighlight(true);
3264 applyProxyButtonEnabled(true);
3267 public void proxyAuth_actionPerformed()
3269 setProxyAuthEnabled();
3270 proxyAuthPasswordCheckHighlight(true);
3271 applyProxyButtonEnabled(true);
3275 * Customer renderer for JTable: supports column of radio buttons
3277 public class RadioButtonRenderer extends JRadioButton
3278 implements TableCellRenderer
3280 public RadioButtonRenderer()
3282 setHorizontalAlignment(CENTER);
3283 setToolTipText(MessageManager.getString("label.urltooltip"));
3287 public Component getTableCellRendererComponent(JTable table,
3288 Object value, boolean isSelected, boolean hasFocus, int row,
3291 setSelected((boolean) value);
3293 // set colours to match rest of table
3296 setBackground(table.getSelectionBackground());
3297 setForeground(table.getSelectionForeground());
3301 setBackground(table.getBackground());
3302 setForeground(table.getForeground());
3309 * Customer cell editor for JTable: supports column of radio buttons in
3310 * conjunction with renderer
3312 public class RadioButtonEditor extends AbstractCellEditor
3313 implements TableCellEditor
3315 private JRadioButton button = new JRadioButton();
3317 public RadioButtonEditor()
3319 button.setHorizontalAlignment(SwingConstants.CENTER);
3320 this.button.addActionListener(new ActionListener()
3323 public void actionPerformed(ActionEvent e)
3325 fireEditingStopped();
3331 public Component getTableCellEditorComponent(JTable table, Object value,
3332 boolean isSelected, int row, int column)
3334 button.setSelected((boolean) value);
3339 public Object getCellEditorValue()
3341 return button.isSelected();