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 final static int CONNECTIONS_TAB = 5;
515 public void selectTab(int selectTab)
517 // select a given tab - currently only for Connections
520 case CONNECTIONS_TAB:
521 tabbedPane.setSelectedComponent(connectTab);
528 * Initialises the Editing tabbed panel.
532 private JPanel initEditingTab()
534 JPanel editingTab = new JPanel();
535 editingTab.setLayout(null);
536 autoCalculateConsCheck.setFont(LABEL_FONT);
537 autoCalculateConsCheck.setText(
538 MessageManager.getString("label.autocalculate_consensus"));
539 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
540 padGaps.setFont(LABEL_FONT);
542 MessageManager.getString("label.pad_gaps_when_editing"));
543 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
544 sortByTree.setFont(LABEL_FONT);
546 .setText(MessageManager.getString("label.sort_with_new_tree"));
547 sortByTree.setToolTipText(MessageManager.getString(
548 "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
549 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
550 editingTab.add(autoCalculateConsCheck);
551 editingTab.add(padGaps);
552 editingTab.add(sortByTree);
557 * Initialises the Output tab
561 private JPanel initOutputTab()
563 JPanel outputTab = new JPanel();
564 outputTab.setLayout(null);
566 JLabel epsLabel = new JLabel(
567 MessageManager.formatMessage("label.rendering_style", "EPS"));
568 epsLabel.setFont(LABEL_FONT);
569 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
570 epsLabel.setBounds(new Rectangle(9, 31, 160, 24));
571 epsRendering.setFont(LABEL_FONT);
572 epsRendering.setBounds(new Rectangle(174, 34, 187, 21));
573 JLabel htmlLabel = new JLabel(
574 MessageManager.formatMessage("label.rendering_style", "HTML"));
575 htmlLabel.setFont(LABEL_FONT);
576 htmlLabel.setHorizontalAlignment(SwingConstants.RIGHT);
577 htmlLabel.setBounds(new Rectangle(9, 55, 160, 24));
578 htmlRendering.setFont(LABEL_FONT);
579 htmlRendering.setBounds(new Rectangle(174, 58, 187, 21));
580 JLabel svgLabel = new JLabel(
581 MessageManager.formatMessage("label.rendering_style", "SVG"));
582 svgLabel.setFont(LABEL_FONT);
583 svgLabel.setHorizontalAlignment(SwingConstants.RIGHT);
584 svgLabel.setBounds(new Rectangle(9, 79, 160, 24));
585 svgRendering.setFont(LABEL_FONT);
586 svgRendering.setBounds(new Rectangle(174, 82, 187, 21));
588 JLabel jLabel1 = new JLabel();
589 jLabel1.setFont(LABEL_FONT);
590 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
591 jLabel1.setText(MessageManager.getString("label.append_start_end"));
592 jLabel1.setFont(LABEL_FONT);
594 fastajv.setFont(LABEL_FONT);
595 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
596 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
597 blcjv.setText(MessageManager.getString("label.blc") + " ");
598 fastajv.setText(MessageManager.getString("label.fasta") + " ");
599 msfjv.setText(MessageManager.getString("label.msf") + " ");
600 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
601 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
602 msfjv.setFont(LABEL_FONT);
603 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
604 pirjv.setText(MessageManager.getString("label.pir") + " ");
605 JPanel jPanel11 = new JPanel();
606 jPanel11.setFont(LABEL_FONT);
607 TitledBorder titledBorder2 = new TitledBorder(
608 MessageManager.getString("label.file_output"));
609 jPanel11.setBorder(titledBorder2);
610 jPanel11.setBounds(new Rectangle(30, 120, 196, 182));
611 GridLayout gridLayout3 = new GridLayout();
612 jPanel11.setLayout(gridLayout3);
613 gridLayout3.setRows(8);
614 blcjv.setFont(LABEL_FONT);
615 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
616 clustaljv.setFont(LABEL_FONT);
617 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
618 pfamjv.setFont(LABEL_FONT);
619 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
620 pileupjv.setFont(LABEL_FONT);
621 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
622 pirjv.setFont(LABEL_FONT);
623 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
624 autoIdWidth.setFont(LABEL_FONT);
626 MessageManager.getString("label.automatically_set_id_width"));
627 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
628 .getString("label.adjusts_width_generated_eps_png")));
629 autoIdWidth.setBounds(new Rectangle(228, 144, 320, 23));
630 autoIdWidth.addActionListener(new ActionListener()
634 public void actionPerformed(ActionEvent e)
636 autoIdWidth_actionPerformed();
639 userIdWidthlabel.setFont(LABEL_FONT);
640 userIdWidthlabel.setText(
641 MessageManager.getString("label.figure_id_column_width"));
642 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
643 .getString("label.manually_specify_width_left_column")));
644 userIdWidthlabel.setToolTipText(
645 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
646 "label.manually_specify_width_left_column")));
647 userIdWidthlabel.setBounds(new Rectangle(236, 168, 320, 23));
648 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
649 userIdWidth.setText("");
650 userIdWidth.setBounds(new Rectangle(232, 192, 84, 23));
651 userIdWidth.addActionListener(new ActionListener()
655 public void actionPerformed(ActionEvent e)
657 userIdWidth_actionPerformed();
660 modellerOutput.setFont(LABEL_FONT);
662 .setText(MessageManager.getString("label.use_modeller_output"));
663 modellerOutput.setBounds(new Rectangle(228, 274, 320, 23));
664 embbedBioJSON.setFont(LABEL_FONT);
665 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
666 embbedBioJSON.setBounds(new Rectangle(228, 248, 250, 23));
668 jPanel11.add(jLabel1);
670 jPanel11.add(clustaljv);
671 jPanel11.add(fastajv);
673 jPanel11.add(pfamjv);
674 jPanel11.add(pileupjv);
676 outputTab.add(autoIdWidth);
677 outputTab.add(userIdWidth);
678 outputTab.add(userIdWidthlabel);
679 outputTab.add(modellerOutput);
680 if (!Platform.isJS())
683 * JalviewJS doesn't support Lineart option or SVG output
685 outputTab.add(embbedBioJSON);
686 outputTab.add(epsLabel);
687 outputTab.add(epsRendering);
688 outputTab.add(htmlLabel);
689 outputTab.add(htmlRendering);
690 outputTab.add(svgLabel);
691 outputTab.add(svgRendering);
693 outputTab.add(jPanel11);
698 * Initialises the Connections tabbed panel.
702 private JPanel initConnectionsTab()
704 connectTab = new JPanel();
705 connectTab.setLayout(new GridBagLayout());
707 // Label for browser text box
708 JLabel browserLabel = new JLabel();
709 browserLabel.setFont(LABEL_FONT);
710 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
711 browserLabel.setText(
712 MessageManager.getString("label.default_browser_unix"));
713 defaultBrowser.setFont(LABEL_FONT);
714 defaultBrowser.setText("");
715 final String tooltip = JvSwingUtils.wrapTooltip(true,
716 MessageManager.getString("label.double_click_to_browse"));
717 defaultBrowser.setToolTipText(tooltip);
718 defaultBrowser.addMouseListener(new MouseAdapter()
721 public void mouseClicked(MouseEvent e)
723 if (e.getClickCount() > 1)
725 defaultBrowser_mouseClicked(e);
730 JPanel proxyPanel = initConnTabProxyPanel();
731 initConnTabCheckboxes();
733 // Add default Browser text box
734 connectTab.add(browserLabel,
735 new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
736 GridBagConstraints.WEST, GridBagConstraints.NONE,
737 new Insets(10, 0, 5, 5), 5, 1));
738 defaultBrowser.setFont(LABEL_FONT);
739 defaultBrowser.setText("");
741 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
742 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
743 new Insets(10, 0, 5, 10), 30, 1));
745 // Add proxy server panel
746 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
747 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
748 new Insets(10, 0, 5, 12), 4, 10));
750 // Add usage stats, version check and questionnaire checkboxes
751 connectTab.add(usagestats,
752 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
753 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
754 new Insets(0, 2, 5, 5), 70, 1));
755 connectTab.add(questionnaire,
756 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
757 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
758 new Insets(0, 2, 5, 10), 70, 1));
759 connectTab.add(versioncheck,
760 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
761 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
762 new Insets(0, 2, 5, 5), 70, 1));
764 versioncheck.setVisible(false);
766 // Add padding so the panel doesn't look ridiculous
767 JPanel spacePanel = new JPanel();
768 connectTab.add(spacePanel,
769 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
770 GridBagConstraints.WEST, GridBagConstraints.BOTH,
771 new Insets(0, 0, 0, 5), 70, 1));
777 * Initialises the Links tabbed panel.
781 private JPanel initLinksTab()
783 JPanel linkTab = new JPanel();
784 linkTab.setLayout(new GridBagLayout());
786 // Set up table for Url links
787 linkUrlTable.getTableHeader().setReorderingAllowed(false);
788 linkUrlTable.setFillsViewportHeight(true);
789 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
790 linkUrlTable.setAutoCreateRowSorter(true);
791 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
793 // adjust row height so radio buttons actually fit
794 // don't do this in the renderer, it causes the awt thread to activate
796 JRadioButton temp = new JRadioButton();
797 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
799 // Table in scrollpane so that the table is given a scrollbar
800 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
801 linkScrollPane.setBorder(null);
803 // Panel for links functionality
804 JPanel linkPanel = new JPanel(new GridBagLayout());
805 linkPanel.setBorder(new TitledBorder(
806 MessageManager.getString("label.url_linkfrom_sequence_id")));
808 // Put the Url links panel together
810 // Buttons go at top right, resizing only resizes the blank space vertically
811 JPanel buttonPanel = initLinkTabUrlButtons();
812 GridBagConstraints linkConstraints1 = new GridBagConstraints();
813 linkConstraints1.insets = new Insets(0, 0, 5, 0);
814 linkConstraints1.gridx = 0;
815 linkConstraints1.gridy = 0;
816 linkConstraints1.weightx = 1.0;
817 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
818 linkTab.add(buttonPanel, linkConstraints1);
820 // Links table goes at top left, resizing resizes the table
821 GridBagConstraints linkConstraints2 = new GridBagConstraints();
822 linkConstraints2.insets = new Insets(0, 0, 5, 5);
823 linkConstraints2.gridx = 0;
824 linkConstraints2.gridy = 1;
825 linkConstraints2.weightx = 1.0;
826 linkConstraints2.weighty = 1.0;
827 linkConstraints2.fill = GridBagConstraints.BOTH;
828 linkTab.add(linkScrollPane, linkConstraints2);
830 // Filter box and buttons goes at bottom left, resizing resizes the text box
831 JPanel filterPanel = initLinkTabFilterPanel();
832 GridBagConstraints linkConstraints3 = new GridBagConstraints();
833 linkConstraints3.insets = new Insets(0, 0, 0, 5);
834 linkConstraints3.gridx = 0;
835 linkConstraints3.gridy = 2;
836 linkConstraints3.weightx = 1.0;
837 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
838 linkTab.add(filterPanel, linkConstraints3);
843 private JPanel initLinkTabFilterPanel()
845 // Filter textbox and reset button
846 JLabel filterLabel = new JLabel(
847 MessageManager.getString("label.filter"));
848 filterLabel.setFont(LABEL_FONT);
849 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
850 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
852 filterTB.setFont(LABEL_FONT);
853 filterTB.setText("");
855 doReset.setText(MessageManager.getString("action.showall"));
856 userOnly.setText(MessageManager.getString("action.customfilter"));
858 // Panel for filter functionality
859 JPanel filterPanel = new JPanel(new GridBagLayout());
860 filterPanel.setBorder(new TitledBorder("Filter"));
861 GridBagConstraints gbc = new GridBagConstraints();
864 gbc.fill = GridBagConstraints.NONE;
865 gbc.anchor = GridBagConstraints.WEST;
867 filterPanel.add(filterLabel, gbc);
869 GridBagConstraints gbc1 = new GridBagConstraints();
872 gbc1.fill = GridBagConstraints.HORIZONTAL;
873 gbc1.anchor = GridBagConstraints.WEST;
875 filterPanel.add(filterTB, gbc1);
877 GridBagConstraints gbc2 = new GridBagConstraints();
879 gbc2.fill = GridBagConstraints.NONE;
880 gbc2.anchor = GridBagConstraints.WEST;
881 filterPanel.add(doReset, gbc2);
883 GridBagConstraints gbc3 = new GridBagConstraints();
885 gbc3.fill = GridBagConstraints.NONE;
886 gbc3.anchor = GridBagConstraints.WEST;
887 filterPanel.add(userOnly, gbc3);
892 private JPanel initLinkTabUrlButtons()
894 // Buttons for new / edit / delete Url links
895 JButton newLink = new JButton();
896 newLink.setText(MessageManager.getString("action.new"));
898 editLink.setText(MessageManager.getString("action.edit"));
900 deleteLink.setText(MessageManager.getString("action.delete"));
902 // no current selection, so initially disable delete/edit buttons
903 editLink.setEnabled(false);
904 deleteLink.setEnabled(false);
906 newLink.addActionListener(new java.awt.event.ActionListener()
909 public void actionPerformed(ActionEvent e)
911 newLink_actionPerformed(e);
915 editLink.setText(MessageManager.getString("action.edit"));
916 editLink.addActionListener(new java.awt.event.ActionListener()
919 public void actionPerformed(ActionEvent e)
921 editLink_actionPerformed(e);
925 deleteLink.setText(MessageManager.getString("action.delete"));
926 deleteLink.addActionListener(new java.awt.event.ActionListener()
929 public void actionPerformed(ActionEvent e)
931 deleteLink_actionPerformed(e);
935 JPanel buttonPanel = new JPanel(new GridBagLayout());
936 buttonPanel.setBorder(new TitledBorder("Edit links"));
937 GridBagConstraints gbc = new GridBagConstraints();
940 gbc.fill = GridBagConstraints.NONE;
941 buttonPanel.add(newLink, gbc);
943 GridBagConstraints gbc1 = new GridBagConstraints();
946 gbc1.fill = GridBagConstraints.NONE;
947 buttonPanel.add(editLink, gbc1);
949 GridBagConstraints gbc2 = new GridBagConstraints();
952 gbc2.fill = GridBagConstraints.NONE;
953 buttonPanel.add(deleteLink, gbc2);
955 GridBagConstraints gbc3 = new GridBagConstraints();
958 gbc3.fill = GridBagConstraints.HORIZONTAL;
960 JPanel spacePanel = new JPanel();
961 spacePanel.setBorder(null);
962 buttonPanel.add(spacePanel, gbc3);
968 * Initialises the proxy server panel in the Connections tab
970 * @return the proxy server panel
972 private JPanel initConnTabProxyPanel()
974 // Label for server text box
975 serverLabel.setText(MessageManager.getString("label.host") + ": ");
976 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
977 serverLabel.setFont(LABEL_FONT);
978 serverLabel2.setText(MessageManager.getString("label.host") + ": ");
979 serverLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
980 serverLabel2.setFont(LABEL_FONT);
982 // Proxy server and port text boxes
983 proxyServerHttpTB.setFont(LABEL_FONT);
984 proxyServerHttpTB.setColumns(40);
985 proxyPortHttpTB.setFont(LABEL_FONT);
986 proxyPortHttpTB.setColumns(4);
987 proxyServerHttpsTB.setFont(LABEL_FONT);
988 proxyServerHttpsTB.setColumns(40);
989 proxyPortHttpsTB.setFont(LABEL_FONT);
990 proxyPortHttpsTB.setColumns(4);
991 proxyAuthUsernameTB.setFont(LABEL_FONT);
992 proxyAuthUsernameTB.setColumns(30);
994 // check for any change to enable applyProxyButton
995 DocumentListener d = new DocumentListener()
998 public void changedUpdate(DocumentEvent e)
1000 applyProxyButtonEnabled(true);
1004 public void insertUpdate(DocumentEvent e)
1006 applyProxyButtonEnabled(true);
1010 public void removeUpdate(DocumentEvent e)
1012 applyProxyButtonEnabled(true);
1015 proxyServerHttpTB.getDocument().addDocumentListener(d);
1016 proxyPortHttpTB.getDocument().addDocumentListener(d);
1017 proxyServerHttpsTB.getDocument().addDocumentListener(d);
1018 proxyPortHttpsTB.getDocument().addDocumentListener(d);
1019 proxyAuthUsernameTB.getDocument().addDocumentListener(d);
1020 proxyAuthPasswordPB.setFont(LABEL_FONT);
1021 proxyAuthPasswordPB.setColumns(30);
1022 proxyAuthPasswordPB.getDocument()
1023 .addDocumentListener(new DocumentListener()
1026 public void changedUpdate(DocumentEvent e)
1028 proxyAuthPasswordCheckHighlight(true);
1029 applyProxyButtonEnabled(true);
1033 public void insertUpdate(DocumentEvent e)
1035 proxyAuthPasswordCheckHighlight(true);
1036 applyProxyButtonEnabled(true);
1040 public void removeUpdate(DocumentEvent e)
1042 proxyAuthPasswordCheckHighlight(true);
1043 applyProxyButtonEnabled(true);
1048 // Label for Port text box
1049 portLabel.setFont(LABEL_FONT);
1050 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1051 portLabel.setText(MessageManager.getString("label.port") + ": ");
1052 portLabel2.setFont(LABEL_FONT);
1053 portLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
1054 portLabel2.setText(MessageManager.getString("label.port") + ": ");
1056 httpLabel.setText("HTTP");
1057 httpLabel.setFont(LABEL_FONT_BOLD);
1058 httpLabel.setHorizontalAlignment(SwingConstants.LEFT);
1059 httpsLabel.setText("HTTPS");
1060 httpsLabel.setFont(LABEL_FONT_BOLD);
1061 httpsLabel.setHorizontalAlignment(SwingConstants.LEFT);
1063 proxyAuthUsernameLabel
1064 .setText(MessageManager.getString("label.username") + ": ");
1065 proxyAuthUsernameLabel.setFont(LABEL_FONT);
1066 proxyAuthUsernameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1067 proxyAuthPasswordLabel
1068 .setText(MessageManager.getString("label.password") + ": ");
1069 proxyAuthPasswordLabel.setFont(LABEL_FONT);
1070 proxyAuthPasswordLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1071 passwordNotStoredLabel.setText(
1072 "(" + MessageManager.getString("label.not_stored") + ")");
1073 passwordNotStoredLabel.setFont(LABEL_FONT_ITALIC);
1074 passwordNotStoredLabel.setHorizontalAlignment(SwingConstants.LEFT);
1076 // Proxy type radio buttons
1077 noProxy.setFont(LABEL_FONT);
1078 noProxy.setHorizontalAlignment(SwingConstants.LEFT);
1079 noProxy.setText(MessageManager.getString("label.no_proxy"));
1080 systemProxy.setFont(LABEL_FONT);
1081 systemProxy.setHorizontalAlignment(SwingConstants.LEFT);
1082 systemProxy.setText(MessageManager.formatMessage("label.system_proxy",
1083 displayUserHostPort(Cache.startupProxyProperties[4],
1084 Cache.startupProxyProperties[0],
1085 Cache.startupProxyProperties[1]),
1086 displayUserHostPort(Cache.startupProxyProperties[6],
1087 Cache.startupProxyProperties[2],
1088 Cache.startupProxyProperties[3])));
1089 customProxy.setFont(LABEL_FONT);
1090 customProxy.setHorizontalAlignment(SwingConstants.LEFT);
1091 customProxy.setText(
1092 MessageManager.getString("label.use_proxy_server") + ":");
1093 ActionListener al = new ActionListener()
1096 public void actionPerformed(ActionEvent e)
1098 proxyType_actionPerformed();
1101 noProxy.addActionListener(al);
1102 systemProxy.addActionListener(al);
1103 customProxy.addActionListener(al);
1104 proxyType.add(noProxy);
1105 proxyType.add(systemProxy);
1106 proxyType.add(customProxy);
1108 proxyAuth.setFont(LABEL_FONT);
1109 proxyAuth.setHorizontalAlignment(SwingConstants.LEFT);
1110 proxyAuth.setText(MessageManager.getString("label.auth_required"));
1111 proxyAuth.addActionListener(new ActionListener()
1114 public void actionPerformed(ActionEvent e)
1116 proxyAuth_actionPerformed();
1120 setCustomProxyEnabled();
1122 // Make proxy server panel
1123 JPanel proxyPanel = new JPanel();
1124 TitledBorder titledBorder1 = new TitledBorder(
1125 MessageManager.getString("label.proxy_servers"));
1126 proxyPanel.setBorder(titledBorder1);
1127 proxyPanel.setLayout(new GridBagLayout());
1128 GridBagConstraints gbc = new GridBagConstraints();
1129 gbc.fill = GridBagConstraints.HORIZONTAL;
1132 GridBagConstraints c = new GridBagConstraints();
1133 // Proxy type radio buttons (3)
1134 JPanel ptPanel = new JPanel();
1135 ptPanel.setLayout(new GridBagLayout());
1140 c.fill = GridBagConstraints.HORIZONTAL;
1141 ptPanel.add(noProxy, c);
1143 ptPanel.add(systemProxy, c);
1145 ptPanel.add(customProxy, c);
1148 proxyPanel.add(ptPanel, gbc);
1150 // host and port text boxes
1151 JPanel hpPanel = new JPanel();
1152 hpPanel.setLayout(new GridBagLayout());
1153 // HTTP host port row
1158 c.anchor = GridBagConstraints.LINE_START;
1159 hpPanel.add(httpLabel, c);
1163 c.anchor = GridBagConstraints.LINE_END;
1164 hpPanel.add(serverLabel, c);
1168 c.anchor = GridBagConstraints.LINE_START;
1169 hpPanel.add(proxyServerHttpTB, c);
1173 c.anchor = GridBagConstraints.LINE_END;
1174 hpPanel.add(portLabel, c);
1178 c.anchor = GridBagConstraints.LINE_START;
1179 hpPanel.add(proxyPortHttpTB, c);
1181 // HTTPS host port row
1186 c.anchor = GridBagConstraints.LINE_START;
1187 hpPanel.add(httpsLabel, c);
1190 c.anchor = GridBagConstraints.LINE_END;
1191 hpPanel.add(serverLabel2, c);
1194 c.anchor = GridBagConstraints.LINE_START;
1195 hpPanel.add(proxyServerHttpsTB, c);
1198 c.anchor = GridBagConstraints.LINE_END;
1199 hpPanel.add(portLabel2, c);
1202 c.anchor = GridBagConstraints.LINE_START;
1203 hpPanel.add(proxyPortHttpsTB, c);
1206 proxyPanel.add(hpPanel, gbc);
1208 // Require authentication checkbox
1210 proxyPanel.add(proxyAuth, gbc);
1212 // username and password
1213 JPanel upPanel = new JPanel();
1214 upPanel.setLayout(new GridBagLayout());
1220 c.anchor = GridBagConstraints.LINE_END;
1221 upPanel.add(proxyAuthUsernameLabel, c);
1225 c.anchor = GridBagConstraints.LINE_START;
1226 upPanel.add(proxyAuthUsernameTB, c);
1232 c.anchor = GridBagConstraints.LINE_END;
1233 upPanel.add(proxyAuthPasswordLabel, c);
1237 c.anchor = GridBagConstraints.LINE_START;
1238 upPanel.add(proxyAuthPasswordPB, c);
1242 c.anchor = GridBagConstraints.LINE_START;
1243 upPanel.add(passwordNotStoredLabel, c);
1246 proxyPanel.add(upPanel, gbc);
1248 applyProxyButton.setText(MessageManager.getString("action.apply"));
1249 applyProxyButton.addActionListener(new ActionListener()
1252 public void actionPerformed(ActionEvent e)
1254 saveProxySettings();
1255 applyProxyButton.setEnabled(false);
1259 gbc.fill = GridBagConstraints.NONE;
1260 gbc.anchor = GridBagConstraints.LINE_END;
1261 proxyPanel.add(applyProxyButton, gbc);
1266 public void proxyAuthPasswordCheckHighlight(boolean enabled)
1268 proxyAuthPasswordCheckHighlight(enabled, false);
1271 public void proxyAuthPasswordCheckHighlight(boolean enabled,
1274 if (enabled && proxyType.isSelected(customProxy.getModel())
1275 && proxyAuth.isSelected()
1276 && !proxyAuthUsernameTB.getText().isEmpty()
1277 && proxyAuthPasswordPB.getDocument().getLength() == 0)
1280 proxyAuthPasswordPB.grabFocus();
1281 proxyAuthPasswordPB.setBackground(Color.PINK);
1285 proxyAuthPasswordPB.setBackground(Color.WHITE);
1289 public void applyProxyButtonEnabled(boolean enabled)
1291 applyProxyButton.setEnabled(enabled);
1294 public void saveProxySettings()
1296 // overridden in Preferences
1299 private String displayUserHostPort(String user, String host, String port)
1301 boolean hostBlank = (host == null || host.isEmpty());
1302 boolean portBlank = (port == null || port.isEmpty());
1303 if (hostBlank && portBlank)
1305 return MessageManager.getString("label.none");
1308 StringBuilder sb = new StringBuilder();
1311 sb.append(user.isEmpty() || user.indexOf(" ") > -1 ? '"' + user + '"'
1315 sb.append(hostBlank ? "" : host);
1321 return sb.toString();
1325 * Initialises the checkboxes in the Connections tab
1327 private void initConnTabCheckboxes()
1329 // Usage stats checkbox label
1331 MessageManager.getString("label.send_usage_statistics"));
1332 usagestats.setFont(LABEL_FONT);
1333 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
1334 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
1336 // Questionnaire checkbox label
1337 questionnaire.setText(
1338 MessageManager.getString("label.check_for_questionnaires"));
1339 questionnaire.setFont(LABEL_FONT);
1340 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
1341 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
1343 // Check for latest version checkbox label
1344 versioncheck.setText(
1345 MessageManager.getString("label.check_for_latest_version"));
1346 versioncheck.setFont(LABEL_FONT);
1347 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
1348 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
1352 * Initialises the parent panel which contains the tabbed sections.
1356 private JPanel initOkCancelPanel()
1358 JButton ok = new JButton();
1359 ok.setText(MessageManager.getString("action.ok"));
1360 ok.addActionListener(new ActionListener()
1363 public void actionPerformed(ActionEvent e)
1365 ok_actionPerformed(e);
1368 JButton cancel = new JButton();
1369 cancel.setText(MessageManager.getString("action.cancel"));
1370 cancel.addActionListener(new ActionListener()
1373 public void actionPerformed(ActionEvent e)
1375 cancel_actionPerformed(e);
1378 JPanel okCancelPanel = new JPanel();
1379 okCancelPanel.add(ok);
1380 okCancelPanel.add(cancel);
1381 return okCancelPanel;
1385 * Initialises the Colours tabbed panel.
1389 private JPanel initColoursTab()
1391 JPanel coloursTab = new JPanel();
1392 coloursTab.setBorder(new TitledBorder(
1393 MessageManager.getString("action.open_new_alignment")));
1394 coloursTab.setLayout(new FlowLayout());
1395 JLabel mincolourLabel = new JLabel();
1396 mincolourLabel.setFont(LABEL_FONT);
1397 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1398 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
1399 minColour.setFont(LABEL_FONT);
1400 minColour.setBorder(BorderFactory.createEtchedBorder());
1401 minColour.setPreferredSize(new Dimension(40, 20));
1402 minColour.addMouseListener(new MouseAdapter()
1405 public void mousePressed(MouseEvent e)
1407 minColour_actionPerformed(minColour);
1410 JLabel maxcolourLabel = new JLabel();
1411 maxcolourLabel.setFont(LABEL_FONT);
1412 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1413 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
1414 maxColour.setFont(LABEL_FONT);
1415 maxColour.setBorder(BorderFactory.createEtchedBorder());
1416 maxColour.setPreferredSize(new Dimension(40, 20));
1417 maxColour.addMouseListener(new MouseAdapter()
1420 public void mousePressed(MouseEvent e)
1422 maxColour_actionPerformed(maxColour);
1426 protColour.setFont(LABEL_FONT);
1427 protColour.setBounds(new Rectangle(172, 225, 155, 21));
1428 JLabel protColourLabel = new JLabel();
1429 protColourLabel.setFont(LABEL_FONT);
1430 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1431 protColourLabel.setText(
1432 MessageManager.getString("label.prot_alignment_colour") + " ");
1433 JvSwingUtils.addtoLayout(coloursTab,
1435 .getString("label.default_colour_scheme_for_alignment"),
1436 protColourLabel, protColour);
1438 nucColour.setFont(LABEL_FONT);
1439 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1440 JLabel nucColourLabel = new JLabel();
1441 nucColourLabel.setFont(LABEL_FONT);
1442 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1443 nucColourLabel.setText(
1444 MessageManager.getString("label.nuc_alignment_colour") + " ");
1445 JvSwingUtils.addtoLayout(coloursTab,
1447 .getString("label.default_colour_scheme_for_alignment"),
1448 nucColourLabel, nucColour);
1450 JPanel annotationShding = new JPanel();
1451 annotationShding.setBorder(new TitledBorder(
1452 MessageManager.getString("label.annotation_shading_default")));
1453 annotationShding.setLayout(new GridLayout(1, 2));
1454 JvSwingUtils.addtoLayout(annotationShding,
1455 MessageManager.getString(
1456 "label.default_minimum_colour_annotation_shading"),
1457 mincolourLabel, minColour);
1458 JvSwingUtils.addtoLayout(annotationShding,
1459 MessageManager.getString(
1460 "label.default_maximum_colour_annotation_shading"),
1461 maxcolourLabel, maxColour);
1462 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1467 * Initialises the Overview tabbed panel.
1471 private JPanel initOverviewTab()
1473 JPanel overviewPanel = new JPanel();
1474 overviewPanel.setBorder(new TitledBorder(
1475 MessageManager.getString("label.overview_settings")));
1477 gapColour.setFont(LABEL_FONT);
1478 // fixing the border colours stops apparent colour bleed from the panel
1479 gapColour.setBorder(
1480 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1481 gapColour.setPreferredSize(new Dimension(40, 20));
1482 gapColour.addMouseListener(new MouseAdapter()
1485 public void mousePressed(MouseEvent e)
1487 gapColour_actionPerformed(gapColour);
1491 hiddenColour.setFont(LABEL_FONT);
1492 // fixing the border colours stops apparent colour bleed from the panel
1493 hiddenColour.setBorder(
1494 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1495 hiddenColour.setPreferredSize(new Dimension(40, 20));
1496 hiddenColour.addMouseListener(new MouseAdapter()
1499 public void mousePressed(MouseEvent e)
1501 hiddenColour_actionPerformed(hiddenColour);
1505 useLegacyGap = new JCheckBox(
1506 MessageManager.getString("label.ov_legacy_gap"));
1507 useLegacyGap.setFont(LABEL_FONT);
1508 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1509 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1510 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1511 gapLabel.setFont(LABEL_FONT);
1512 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1513 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1514 showHiddenAtStart = new JCheckBox(
1515 MessageManager.getString("label.ov_show_hide_default"));
1516 showHiddenAtStart.setFont(LABEL_FONT);
1517 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1518 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1519 JLabel hiddenLabel = new JLabel(
1520 MessageManager.getString("label.hidden_colour"));
1521 hiddenLabel.setFont(LABEL_FONT);
1522 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1523 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1525 useLegacyGap.addActionListener(new ActionListener()
1528 public void actionPerformed(ActionEvent e)
1530 useLegacyGaps_actionPerformed(e);
1534 overviewPanel.setLayout(new GridBagLayout());
1535 GridBagConstraints c1 = new GridBagConstraints();
1537 c1.fill = GridBagConstraints.HORIZONTAL;
1542 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1543 overviewPanel.add(useLegacyGap, c1);
1545 GridBagConstraints c2 = new GridBagConstraints();
1546 c2.fill = GridBagConstraints.HORIZONTAL;
1549 c2.insets = new Insets(0, 15, 0, 10);
1550 overviewPanel.add(gapLabel, c2);
1552 GridBagConstraints c3 = new GridBagConstraints();
1553 c3.fill = GridBagConstraints.HORIZONTAL;
1556 c3.insets = new Insets(0, 0, 0, 15);
1557 overviewPanel.add(gapColour, c3);
1559 GridBagConstraints c4 = new GridBagConstraints();
1560 c4.fill = GridBagConstraints.HORIZONTAL;
1564 overviewPanel.add(showHiddenAtStart, c4);
1566 GridBagConstraints c5 = new GridBagConstraints();
1567 c5.fill = GridBagConstraints.HORIZONTAL;
1570 c5.insets = new Insets(0, 15, 0, 10);
1571 overviewPanel.add(hiddenLabel, c5);
1573 GridBagConstraints c6 = new GridBagConstraints();
1574 c6.fill = GridBagConstraints.HORIZONTAL;
1577 c6.insets = new Insets(0, 0, 0, 15);
1578 overviewPanel.add(hiddenColour, c6);
1580 JButton resetButton = new JButton(
1581 MessageManager.getString("label.reset_to_defaults"));
1583 resetButton.addActionListener(new ActionListener()
1586 public void actionPerformed(ActionEvent e)
1588 resetOvDefaults_actionPerformed(e);
1592 GridBagConstraints c7 = new GridBagConstraints();
1593 c7.fill = GridBagConstraints.NONE;
1596 c7.insets = new Insets(10, 0, 0, 0);
1597 c7.anchor = GridBagConstraints.WEST;
1598 overviewPanel.add(resetButton, c7);
1600 // Add padding so the panel doesn't look ridiculous
1601 JPanel spacePanel = new JPanel();
1602 overviewPanel.add(spacePanel,
1603 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1604 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1605 new Insets(0, 0, 0, 5), 0, 0));
1607 return overviewPanel;
1611 * Initialises the Structure tabbed panel.
1615 private JPanel initStructureTab()
1617 structureTab = new JPanel();
1619 structureTab.setBorder(new TitledBorder(
1620 MessageManager.getString("label.structure_options")));
1621 structureTab.setLayout(null);
1622 final int width = 420;
1623 final int height = 22;
1624 final int lineSpacing = 25;
1627 structFromPdb.setFont(LABEL_FONT);
1629 .setText(MessageManager.getString("label.struct_from_pdb"));
1630 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1631 structFromPdb.addActionListener(new ActionListener()
1634 public void actionPerformed(ActionEvent e)
1636 boolean selected = structFromPdb.isSelected();
1637 // enable other options only when the first is checked
1638 useRnaView.setEnabled(selected);
1639 addSecondaryStructure.setEnabled(selected);
1640 addTempFactor.setEnabled(selected);
1643 structureTab.add(structFromPdb);
1645 // indent checkboxes that are conditional on the first one
1646 ypos += lineSpacing;
1647 useRnaView.setFont(LABEL_FONT);
1648 useRnaView.setText(MessageManager.getString("label.use_rnaview"));
1649 useRnaView.setBounds(new Rectangle(25, ypos, width, height));
1650 structureTab.add(useRnaView);
1652 ypos += lineSpacing;
1653 addSecondaryStructure.setFont(LABEL_FONT);
1654 addSecondaryStructure
1655 .setText(MessageManager.getString("label.autoadd_secstr"));
1656 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1657 structureTab.add(addSecondaryStructure);
1659 ypos += lineSpacing;
1660 addTempFactor.setFont(LABEL_FONT);
1661 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1662 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1663 structureTab.add(addTempFactor);
1665 ypos += lineSpacing;
1666 JLabel viewerLabel = new JLabel();
1667 viewerLabel.setFont(LABEL_FONT);
1668 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1669 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1670 viewerLabel.setBounds(new Rectangle(10, ypos, 220, height));
1671 structureTab.add(viewerLabel);
1674 * add all external viewers as options here - check
1675 * when selected whether the program is installed
1677 structViewer.setFont(LABEL_FONT);
1678 structViewer.setBounds(new Rectangle(190, ypos, 120, height));
1679 structViewer.addItem(ViewerType.JMOL.name());
1680 structViewer.addItem(ViewerType.CHIMERA.name());
1681 structViewer.addItem(ViewerType.CHIMERAX.name());
1682 structViewer.addItem(ViewerType.PYMOL.name());
1683 structViewer.addActionListener(new ActionListener()
1686 public void actionPerformed(ActionEvent e)
1688 structureViewer_actionPerformed(
1689 (String) structViewer.getSelectedItem());
1692 structureTab.add(structViewer);
1694 ypos += lineSpacing;
1695 structureViewerPathLabel = new JLabel();
1696 structureViewerPathLabel.setFont(LABEL_FONT);// new Font("SansSerif", 0,
1698 structureViewerPathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1699 structureViewerPathLabel.setText(MessageManager
1700 .formatMessage("label.viewer_path", "Chimera(X)"));
1701 structureViewerPathLabel
1702 .setBounds(new Rectangle(10, ypos, 170, height));
1703 structureViewerPathLabel.setEnabled(false);
1704 structureTab.add(structureViewerPathLabel);
1706 structureViewerPath.setFont(LABEL_FONT);
1707 structureViewerPath.setText("");
1708 structureViewerPath.setEnabled(false);
1709 final String tooltip = JvSwingUtils.wrapTooltip(true,
1710 MessageManager.getString("label.viewer_path_tip"));
1711 structureViewerPath.setToolTipText(tooltip);
1712 structureViewerPath.setBounds(new Rectangle(190, ypos, 290, height));
1713 structureViewerPath.addMouseListener(new MouseAdapter()
1716 public void mouseClicked(MouseEvent e)
1718 if (structureViewerPath.isEnabled() && e.getClickCount() == 2)
1720 String chosen = openFileChooser();
1723 structureViewerPath.setText(chosen);
1728 structureTab.add(structureViewerPath);
1730 ypos += lineSpacing;
1731 nwMapping.setFont(LABEL_FONT);
1732 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1733 siftsMapping.setFont(LABEL_FONT);
1734 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1735 mappingMethod.add(nwMapping);
1736 mappingMethod.add(siftsMapping);
1737 JPanel mappingPanel = new JPanel();
1738 mappingPanel.setFont(LABEL_FONT);
1739 TitledBorder mmTitledBorder = new TitledBorder(
1740 MessageManager.getString("label.mapping_method"));
1741 mmTitledBorder.setTitleFont(LABEL_FONT);
1742 mappingPanel.setBorder(mmTitledBorder);
1743 mappingPanel.setBounds(new Rectangle(10, ypos, 472, 45));
1744 // GridLayout mappingLayout = new GridLayout();
1745 mappingPanel.setLayout(new GridLayout());
1746 mappingPanel.add(nwMapping);
1747 mappingPanel.add(siftsMapping);
1748 structureTab.add(mappingPanel);
1750 ypos += lineSpacing;
1751 ypos += lineSpacing;
1752 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1753 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1754 docFieldPref.setBounds(new Rectangle(10, ypos, 470, 120));
1755 structureTab.add(docFieldPref);
1758 * hide Chimera options in JalviewJS
1760 if (Platform.isJS())
1762 structureViewerPathLabel.setVisible(false);
1763 structureViewerPath.setVisible(false);
1764 viewerLabel.setVisible(false);
1765 structViewer.setVisible(false);
1768 return structureTab;
1772 * Action on choosing a structure viewer from combobox options.
1774 * @param selectedItem
1776 protected void structureViewer_actionPerformed(String selectedItem)
1781 * Show a dialog for the user to choose a file. Returns the chosen path, or
1786 protected String openFileChooser()
1788 String choice = null;
1789 JFileChooser chooser = new JFileChooser();
1791 // chooser.setFileView(new JalviewFileView());
1792 chooser.setDialogTitle(
1793 MessageManager.getString("label.open_local_file"));
1794 chooser.setToolTipText(MessageManager.getString("action.open"));
1796 int value = chooser.showOpenDialog(this);
1798 if (value == JFileChooser.APPROVE_OPTION)
1800 choice = chooser.getSelectedFile().getPath();
1806 * Validate the structure tab preferences; if invalid, set focus on this tab.
1810 protected boolean validateStructure(FocusEvent e)
1812 if (!validateStructure())
1814 e.getComponent().requestFocusInWindow();
1820 protected boolean validateStructure()
1826 * Initialises the Visual tabbed panel.
1830 private JPanel initVisualTab()
1832 JPanel visualTab = new JPanel();
1833 visualTab.setBorder(new TitledBorder(
1834 MessageManager.getString("action.open_new_alignment")));
1835 visualTab.setLayout(null);
1836 fullScreen.setFont(LABEL_FONT);
1837 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1838 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1839 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1840 quality.setEnabled(false);
1841 quality.setFont(LABEL_FONT);
1842 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1843 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1844 quality.setSelected(true);
1845 quality.setText(MessageManager.getString("label.quality"));
1846 conservation.setEnabled(false);
1847 conservation.setFont(LABEL_FONT);
1848 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1849 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1850 conservation.setSelected(true);
1851 conservation.setText(MessageManager.getString("label.conservation"));
1852 identity.setEnabled(false);
1853 identity.setFont(LABEL_FONT);
1854 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1855 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1856 identity.setSelected(true);
1857 identity.setText(MessageManager.getString("label.consensus"));
1858 showOccupancy.setFont(LABEL_FONT);
1859 showOccupancy.setEnabled(false);
1860 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1861 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1862 showOccupancy.setSelected(true);
1863 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1865 JLabel showGroupbits = new JLabel();
1866 showGroupbits.setFont(LABEL_FONT);
1867 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1868 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1870 .setText(MessageManager.getString("action.show_group") + ":");
1871 JLabel showConsensbits = new JLabel();
1872 showConsensbits.setFont(LABEL_FONT);
1873 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1874 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1876 .setText(MessageManager.getString("label.consensus") + ":");
1877 showConsensHistogram.setEnabled(false);
1878 showConsensHistogram.setFont(LABEL_FONT);
1879 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1880 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1881 showConsensHistogram.setSelected(true);
1882 showConsensHistogram
1883 .setText(MessageManager.getString("label.histogram"));
1884 showConsensLogo.setEnabled(false);
1885 showConsensLogo.setFont(LABEL_FONT);
1886 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1887 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1888 showConsensLogo.setSelected(true);
1889 showConsensLogo.setText(MessageManager.getString("label.logo"));
1890 showGroupConsensus.setEnabled(false);
1891 showGroupConsensus.setFont(LABEL_FONT);
1892 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1893 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1894 showGroupConsensus.setSelected(true);
1895 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1896 showGroupConservation.setEnabled(false);
1897 showGroupConservation.setFont(LABEL_FONT);
1898 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1899 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1900 showGroupConservation.setSelected(true);
1901 showGroupConservation
1902 .setText(MessageManager.getString("label.conservation"));
1903 showNpTooltip.setEnabled(true);
1904 showNpTooltip.setFont(LABEL_FONT);
1905 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1906 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1907 showNpTooltip.setSelected(true);
1908 showNpTooltip.setText(
1909 MessageManager.getString("label.non_positional_features"));
1910 showDbRefTooltip.setEnabled(true);
1911 showDbRefTooltip.setFont(LABEL_FONT);
1912 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1913 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1914 showDbRefTooltip.setSelected(true);
1916 .setText(MessageManager.getString("label.database_references"));
1917 annotations.setFont(LABEL_FONT);
1918 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1919 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1920 annotations.setSelected(true);
1921 annotations.setText(MessageManager.getString("label.show_annotations"));
1922 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1923 annotations.addActionListener(new ActionListener()
1926 public void actionPerformed(ActionEvent e)
1928 annotations_actionPerformed(e);
1931 identity.addActionListener(new ActionListener()
1934 public void actionPerformed(ActionEvent e)
1936 annotations_actionPerformed(e);
1939 showGroupConsensus.addActionListener(new ActionListener()
1942 public void actionPerformed(ActionEvent e)
1944 annotations_actionPerformed(e);
1947 showUnconserved.setFont(LABEL_FONT);
1948 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1949 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1950 showUnconserved.setSelected(true);
1952 .setText(MessageManager.getString("action.show_unconserved"));
1953 showUnconserved.addActionListener(new ActionListener()
1956 public void actionPerformed(ActionEvent e)
1958 showunconserved_actionPerformed(e);
1962 // TODO these are not yet added to / action from Preferences
1963 // JCheckBox shareSelections = new JCheckBox();
1964 // shareSelections.setFont(verdana11);
1965 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1966 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1967 // shareSelections.setSelected(true);
1968 // shareSelections.setText(MessageManager
1969 // .getString("label.share_selection_across_views"));
1970 // JCheckBox followHighlight = new JCheckBox();
1971 // followHighlight.setFont(verdana11);
1972 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1973 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1974 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1975 // followHighlight.setSelected(true);
1976 // followHighlight.setText(MessageManager
1977 // .getString("label.scroll_highlighted_regions"));
1979 seqLimit.setFont(LABEL_FONT);
1980 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1981 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1982 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1983 smoothFont.setFont(LABEL_FONT);
1984 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1985 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1986 smoothFont.setText(MessageManager.getString("label.smooth_font"));
1987 scaleProteinToCdna.setFont(LABEL_FONT);
1988 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1989 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1990 scaleProteinToCdna.setText(
1991 MessageManager.getString("label.scale_protein_to_cdna"));
1992 scaleProteinToCdna.setToolTipText(
1993 MessageManager.getString("label.scale_protein_to_cdna_tip"));
1994 JLabel gapLabel = new JLabel();
1995 gapLabel.setFont(LABEL_FONT);
1996 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1997 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1998 JLabel fontLabel = new JLabel();
1999 fontLabel.setFont(LABEL_FONT);
2000 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2001 fontLabel.setText(MessageManager.getString("label.font"));
2002 fontSizeCB.setFont(LABEL_FONT);
2003 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
2004 fontStyleCB.setFont(LABEL_FONT);
2005 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
2006 fontNameCB.setFont(LABEL_FONT);
2007 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
2008 gapSymbolCB.setFont(LABEL_FONT);
2009 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
2010 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
2011 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
2012 gapSymbolCB.setRenderer(dlcr);
2014 startupCheckbox.setText(MessageManager.getString("action.open_file"));
2015 startupCheckbox.setFont(LABEL_FONT);
2016 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
2017 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
2018 startupCheckbox.setSelected(true);
2019 startupFileTextfield.setFont(LABEL_FONT);
2020 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
2021 final String tooltip = JvSwingUtils.wrapTooltip(true,
2022 MessageManager.getString("label.double_click_to_browse"));
2023 startupFileTextfield.setToolTipText(tooltip);
2024 startupFileTextfield.addMouseListener(new MouseAdapter()
2027 public void mouseClicked(MouseEvent e)
2029 if (e.getClickCount() > 1)
2031 startupFileTextfield_mouseClicked();
2036 sortby.setFont(LABEL_FONT);
2037 sortby.setBounds(new Rectangle(172, 260, 155, 21));
2038 JLabel sortLabel = new JLabel();
2039 sortLabel.setFont(LABEL_FONT);
2040 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2041 sortLabel.setText(MessageManager.getString("label.sort_by"));
2042 sortAnnBy.setFont(LABEL_FONT);
2043 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
2044 JLabel sortAnnLabel = new JLabel();
2045 sortAnnLabel.setFont(LABEL_FONT);
2046 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2047 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
2048 sortAutocalc.setFont(LABEL_FONT);
2049 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
2051 JPanel annsettingsPanel = new JPanel();
2052 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
2053 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
2054 annsettingsPanel.setBorder(new EtchedBorder());
2055 visualTab.add(annsettingsPanel);
2056 Border jb = new EmptyBorder(1, 1, 4, 5);
2057 annotations.setBorder(jb);
2058 showOccupancy.setBorder(jb);
2059 quality.setBorder(jb);
2060 conservation.setBorder(jb);
2061 identity.setBorder(jb);
2062 showConsensbits.setBorder(jb);
2063 showGroupbits.setBorder(jb);
2064 showGroupConsensus.setBorder(jb);
2065 showGroupConservation.setBorder(jb);
2066 showConsensHistogram.setBorder(jb);
2067 showConsensLogo.setBorder(jb);
2069 JPanel autoAnnotSettings = new JPanel();
2070 annsettingsPanel.add(autoAnnotSettings);
2071 autoAnnotSettings.setLayout(new GridLayout(0, 2));
2072 autoAnnotSettings.add(annotations);
2073 autoAnnotSettings.add(quality);
2074 // second row of autoannotation box
2075 autoAnnotSettings = new JPanel();
2076 annsettingsPanel.add(autoAnnotSettings);
2078 autoAnnotSettings.setLayout(new GridLayout(0, 3));
2079 autoAnnotSettings.add(conservation);
2080 autoAnnotSettings.add(identity);
2081 autoAnnotSettings.add(showOccupancy);
2082 autoAnnotSettings.add(showGroupbits);
2083 autoAnnotSettings.add(showGroupConservation);
2084 autoAnnotSettings.add(showGroupConsensus);
2085 autoAnnotSettings.add(showConsensbits);
2086 autoAnnotSettings.add(showConsensHistogram);
2087 autoAnnotSettings.add(showConsensLogo);
2089 JPanel tooltipSettings = new JPanel();
2090 tooltipSettings.setBorder(new TitledBorder(
2091 MessageManager.getString("label.sequence_id_tooltip")));
2092 tooltipSettings.setBounds(173, 140, 220, 62);
2093 tooltipSettings.setLayout(new GridLayout(2, 1));
2094 tooltipSettings.add(showDbRefTooltip);
2095 tooltipSettings.add(showNpTooltip);
2096 visualTab.add(tooltipSettings);
2098 wrap.setFont(LABEL_FONT);
2099 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
2100 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
2101 wrap.setText(MessageManager.getString("label.wrap_alignment"));
2102 rightAlign.setFont(LABEL_FONT);
2103 rightAlign.setForeground(Color.black);
2104 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
2105 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
2106 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
2107 idItalics.setFont(LABEL_FONT_ITALIC);
2108 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
2109 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
2111 MessageManager.getString("label.sequence_name_italics"));
2112 openoverv.setFont(LABEL_FONT);
2113 openoverv.setActionCommand(
2114 MessageManager.getString("label.open_overview"));
2115 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
2116 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
2117 openoverv.setText(MessageManager.getString("label.open_overview"));
2118 JPanel jPanel2 = new JPanel();
2119 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
2120 jPanel2.setLayout(new GridLayout(14, 1));
2121 jPanel2.add(fullScreen);
2122 jPanel2.add(openoverv);
2123 jPanel2.add(seqLimit);
2124 jPanel2.add(rightAlign);
2125 jPanel2.add(fontLabel);
2126 jPanel2.add(showUnconserved);
2127 jPanel2.add(idItalics);
2128 jPanel2.add(smoothFont);
2129 jPanel2.add(scaleProteinToCdna);
2130 jPanel2.add(gapLabel);
2132 jPanel2.add(sortLabel);
2133 jPanel2.add(sortAnnLabel);
2134 jPanel2.add(startupCheckbox);
2135 visualTab.add(jPanel2);
2136 visualTab.add(startupFileTextfield);
2137 visualTab.add(sortby);
2138 visualTab.add(sortAnnBy);
2139 visualTab.add(sortAutocalc);
2140 visualTab.add(gapSymbolCB);
2141 visualTab.add(fontNameCB);
2142 visualTab.add(fontSizeCB);
2143 visualTab.add(fontStyleCB);
2145 if (Platform.isJS())
2147 startupCheckbox.setVisible(false);
2148 startupFileTextfield.setVisible(false);
2155 * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
2158 protected void loadLastSavedBackupsOptions()
2160 BackupFilesPresetEntry savedPreset = BackupFilesPresetEntry
2161 .getSavedBackupEntry();
2162 enableBackupFiles.setSelected(
2163 Cache.getDefault(BackupFiles.ENABLED, !Platform.isJS()));
2165 BackupFilesPresetEntry backupfilesCustomEntry = BackupFilesPresetEntry
2166 .createBackupFilesPresetEntry(Cache
2167 .getDefault(BackupFilesPresetEntry.CUSTOMCONFIG, null));
2168 if (backupfilesCustomEntry == null)
2170 backupfilesCustomEntry = BackupFilesPresetEntry.backupfilesPresetEntriesValues
2171 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT);
2173 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
2174 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM,
2175 backupfilesCustomEntry);
2177 setComboIntStringKey(backupfilesPresetsCombo,
2178 Cache.getDefault(BackupFiles.NS + "_PRESET",
2179 BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT));
2181 backupsSetOptions(savedPreset);
2183 backupsOptionsSetEnabled();
2184 updateBackupFilesExampleLabel();
2187 private boolean warnAboutSuffixReverseChange()
2189 BackupFilesPresetEntry bfpe = BackupFilesPresetEntry
2190 .getSavedBackupEntry();
2191 boolean savedSuffixReverse = bfpe.reverse;
2192 int savedSuffixDigits = bfpe.digits;
2193 String savedSuffixTemplate = bfpe.suffix;
2195 boolean nowSuffixReverse = suffixReverse.isSelected();
2196 int nowSuffixDigits = getSpinnerInt(suffixDigitsSpinner, 3);
2197 String nowSuffixTemplate = suffixTemplate.getText();
2198 return nowSuffixReverse != savedSuffixReverse
2199 && nowSuffixDigits == savedSuffixDigits
2200 && nowSuffixTemplate != null
2201 && nowSuffixTemplate.equals(savedSuffixTemplate);
2205 * Initialises the Backups tabbed panel.
2209 private JPanel initBackupsTab()
2211 JPanel backupsTab = new JPanel();
2212 backupsTab.setBorder(new TitledBorder(
2213 MessageManager.getString("label.backup_files")));
2214 backupsTab.setLayout(new GridBagLayout());
2216 GridBagConstraints gbc = new GridBagConstraints();
2219 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2220 gbc.fill = GridBagConstraints.NONE;
2222 initBackupsTabPresetsPanel();
2223 initBackupsTabSuffixPanel();
2224 initBackupsTabKeepFilesPanel();
2225 initBackupsTabFilenameExamplesPanel();
2227 enableBackupFiles.setFont(LABEL_FONT_BOLD);
2229 .setText(MessageManager.getString("label.enable_backupfiles"));
2230 enableBackupFiles.addActionListener(new ActionListener()
2233 public void actionPerformed(ActionEvent e)
2235 // enable other options only when the first is checked
2236 backupsOptionsSetEnabled();
2240 // enable checkbox 1 col
2244 gbc.gridy = 0; // row 0
2245 backupsTab.add(enableBackupFiles, gbc);
2247 // summary of scheme box (over two rows)
2251 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
2252 gbc.fill = GridBagConstraints.BOTH;
2253 backupsTab.add(exampleFilesPanel, gbc);
2255 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2256 gbc.fill = GridBagConstraints.NONE;
2258 // fill empty space on right
2261 backupsTab.add(new JPanel(), gbc);
2266 gbc.gridy++; // row 1
2267 backupsTab.add(presetsPanel, gbc);
2269 // now using whole row
2274 gbc.gridy++; // row 2
2275 backupsTab.add(keepfilesPanel, gbc);
2277 // filename strategy box
2278 gbc.gridy++; // row 3
2279 backupsTab.add(suffixPanel, gbc);
2282 gbc.gridy++; // row 4
2284 backupsTab.add(new JPanel(), gbc);
2286 backupsOptionsSetEnabled();
2290 private JPanel initBackupsTabPresetsPanel()
2293 String title = MessageManager.getString("label.schemes");
2295 presetsPanel.setLayout(new GridBagLayout());
2297 GridBagConstraints gbc = new GridBagConstraints();
2300 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
2301 gbc.fill = GridBagConstraints.NONE;
2309 presetsComboLabel = new JLabel(title + ":");
2310 presetsPanel.add(presetsComboLabel, gbc);
2312 List<Object> entries = Arrays.asList(
2313 (Object[]) BackupFilesPresetEntry.backupfilesPresetEntries);
2314 List<String> tooltips = Arrays.asList(
2315 BackupFilesPresetEntry.backupfilesPresetEntryDescriptions);
2316 backupfilesPresetsCombo = JvSwingUtils.buildComboWithTooltips(entries,
2319 for (int i = 0; i < BackupFilesPresetEntry.backupfilesPresetEntries.length; i++)
2321 backupfilesPresetsCombo
2322 .addItem(BackupFilesPresetEntry.backupfilesPresetEntries[i]);
2326 backupfilesPresetsCombo.addActionListener(new ActionListener()
2329 public void actionPerformed(ActionEvent e)
2331 int key = getComboIntStringKey(backupfilesPresetsCombo);
2332 if (!customiseCheckbox.isSelected())
2334 backupfilesPresetsComboLastSelected = key;
2336 if (key == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
2338 if (customiseCheckbox.isSelected())
2340 // got here by clicking on customiseCheckbox so don't change the
2342 backupfilesCustomOptionsSetEnabled();
2346 backupsTabUpdatePresets();
2347 backupfilesCustomOptionsSetEnabled();
2352 customiseCheckbox.setSelected(false);
2353 backupsTabUpdatePresets();
2354 backupfilesCustomOptionsSetEnabled();
2359 // dropdown list of preset schemes
2361 presetsPanel.add(backupfilesPresetsCombo, gbc);
2363 revertButton.setText(MessageManager.getString("label.cancel_changes"));
2364 revertButton.setToolTipText(
2365 MessageManager.getString("label.cancel_changes_description"));
2366 revertButton.addActionListener(new ActionListener()
2369 public void actionPerformed(ActionEvent e)
2372 BackupFilesPresetEntry.backupfilesPresetEntriesValues.get(
2373 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM));
2374 backupfilesCustomOptionsSetEnabled();
2378 revertButton.setFont(LABEL_FONT);
2380 customiseCheckbox.setFont(LABEL_FONT);
2381 customiseCheckbox.setText(MessageManager.getString("label.customise"));
2382 customiseCheckbox.addActionListener(new ActionListener()
2385 public void actionPerformed(ActionEvent e)
2387 int currently = getComboIntStringKey(backupfilesPresetsCombo);
2388 if (customiseCheckbox.isSelected())
2390 backupfilesPresetsComboLastSelected = currently;
2391 setComboIntStringKey(backupfilesPresetsCombo,
2392 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2396 setComboIntStringKey(backupfilesPresetsCombo,
2397 backupfilesPresetsComboLastSelected);
2400 backupfilesCustomOptionsSetEnabled();
2403 customiseCheckbox.setToolTipText(
2404 MessageManager.getString("label.customise_description"));
2406 // customise checkbox
2409 presetsPanel.add(customiseCheckbox, gbc);
2411 // "Cancel changes" button (aligned with combo box above)
2413 presetsPanel.add(revertButton, gbc);
2415 return presetsPanel;
2418 private JPanel initBackupsTabFilenameExamplesPanel()
2420 String title = MessageManager.getString("label.scheme_examples");
2421 TitledBorder tb = new TitledBorder(title);
2422 exampleFilesPanel.setBorder(tb);
2423 exampleFilesPanel.setLayout(new GridBagLayout());
2425 backupfilesExampleLabel.setEditable(false);
2426 backupfilesExampleLabel
2427 .setBackground(exampleFilesPanel.getBackground());
2429 updateBackupFilesExampleLabel();
2431 GridBagConstraints gbc = new GridBagConstraints();
2434 gbc.fill = GridBagConstraints.NONE;
2435 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2437 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
2438 return exampleFilesPanel;
2441 private void backupsTabUpdatePresets()
2443 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
2446 String value = entry.v;
2448 if (BackupFilesPresetEntry.backupfilesPresetEntriesValues
2452 BackupFilesPresetEntry.backupfilesPresetEntriesValues
2458 "Preset '" + value + "' [key:" + key + "] not implemented");
2461 // Custom options will now be enabled when the customiseCheckbox is checked
2462 // (performed above)
2463 // backupfilesCustomOptionsSetEnabled();
2464 updateBackupFilesExampleLabel();
2467 protected int getComboIntStringKey(
2468 JComboBox<Object> backupfilesPresetsCombo2)
2470 IntKeyStringValueEntry e;
2473 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2
2475 } catch (Exception ex)
2478 "Problem casting Combo entry to IntKeyStringValueEntry.");
2481 return e != null ? e.k : 0;
2484 protected void setComboIntStringKey(
2485 JComboBox<Object> backupfilesPresetsCombo2, int key)
2487 for (int i = 0; i < backupfilesPresetsCombo2.getItemCount(); i++)
2489 IntKeyStringValueEntry e;
2492 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2.getItemAt(i);
2493 } catch (Exception ex)
2496 "Problem casting Combo entry to IntKeyStringValueEntry. Skipping item. ");
2501 backupfilesPresetsCombo2.setSelectedIndex(i);
2505 // backupsTabUpdatePresets();
2508 private JPanel initBackupsTabSuffixPanel()
2510 suffixPanel.setBorder(new TitledBorder(
2511 MessageManager.getString("label.backup_filename_strategy")));
2512 suffixPanel.setLayout(new GridBagLayout());
2515 .setText(MessageManager.getString("label.append_to_filename"));
2516 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
2517 suffixTemplateLabel.setFont(LABEL_FONT);
2519 final String tooltip = JvSwingUtils.wrapTooltip(true,
2520 MessageManager.getString("label.append_to_filename_tooltip"));
2521 suffixTemplate.setToolTipText(tooltip);
2522 suffixTemplate.addActionListener(new ActionListener()
2525 public void actionPerformed(ActionEvent e)
2527 updateBackupFilesExampleLabel();
2528 backupfilesCustomOptionsSetEnabled();
2529 backupfilesRevertButtonSetEnabled(true);
2533 suffixTemplate.addKeyListener(new KeyListener()
2536 public void keyReleased(KeyEvent e)
2538 updateBackupFilesExampleLabel();
2539 backupfilesCustomOptionsSetEnabled();
2540 backupfilesRevertButtonSetEnabled(true);
2544 public void keyPressed(KeyEvent e)
2548 // disable use of ':' or '/' or '\'
2550 public void keyTyped(KeyEvent e)
2552 char c = e.getKeyChar();
2553 if (c == ':' || c == '/' || c == '\\')
2555 // don't process ':' or '/' or '\'
2564 .setText(MessageManager.getString("label.index_digits"));
2565 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
2566 suffixDigitsLabel.setFont(LABEL_FONT);
2567 ChangeListener c = new ChangeListener()
2570 public void stateChanged(ChangeEvent e)
2572 backupfilesRevertButtonSetEnabled(true);
2573 updateBackupFilesExampleLabel();
2577 setIntegerSpinner(suffixDigitsSpinner, BackupFilesPresetEntry.DIGITSMIN,
2578 BackupFilesPresetEntry.DIGITSMAX, 3, c);
2580 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
2581 MessageManager.getString("label.increment_index"));
2582 suffixReverse.addActionListener(new ActionListener()
2585 public void actionPerformed(ActionEvent e)
2587 boolean okay = true;
2588 if (warnAboutSuffixReverseChange())
2591 okay = confirmSuffixReverseChange();
2595 backupfilesRevertButtonSetEnabled(true);
2596 updateBackupFilesExampleLabel();
2600 boolean savedSuffixReverse = BackupFilesPresetEntry
2601 .getSavedBackupEntry().reverse;
2602 suffixReverse.setSelected(savedSuffixReverse);
2607 GridBagConstraints sgbc = new GridBagConstraints();
2609 // first row (template text box)
2610 sgbc.anchor = GridBagConstraints.WEST;
2614 sgbc.gridheight = 1;
2617 sgbc.fill = GridBagConstraints.NONE;
2618 suffixPanel.add(suffixTemplateLabel, sgbc);
2621 sgbc.fill = GridBagConstraints.HORIZONTAL;
2622 suffixPanel.add(suffixTemplate, sgbc);
2624 // second row (number of digits spinner)
2628 sgbc.fill = GridBagConstraints.NONE;
2629 suffixPanel.add(suffixDigitsLabel, sgbc);
2632 sgbc.fill = GridBagConstraints.HORIZONTAL;
2633 suffixPanel.add(suffixDigitsSpinner, sgbc);
2635 // third row (forward order radio selection)
2638 sgbc.gridwidth = GridBagConstraints.REMAINDER;
2639 sgbc.fill = GridBagConstraints.HORIZONTAL;
2640 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
2642 // fourth row (reverse order radio selection)
2644 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
2648 private boolean confirmSuffixReverseChange()
2650 boolean ret = false;
2651 String warningMessage = MessageManager
2652 .getString("label.warning_confirm_change_reverse");
2653 int confirm = JvOptionPane.showConfirmDialog(Desktop.desktop,
2655 MessageManager.getString("label.change_increment_decrement"),
2656 JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE);
2658 ret = (confirm == JvOptionPane.YES_OPTION);
2662 private JPanel initBackupsTabKeepFilesPanel()
2664 keepfilesPanel.setBorder(
2665 new TitledBorder(MessageManager.getString("label.keep_files")));
2666 keepfilesPanel.setLayout(new GridBagLayout());
2668 backupfilesKeepAll.setLabels(
2669 MessageManager.getString("label.keep_all_backup_files"),
2670 MessageManager.getString(
2671 "label.keep_only_this_number_of_backup_files"));
2672 backupfilesKeepAll.addTrueActionListener(new ActionListener()
2675 public void actionPerformed(ActionEvent e)
2677 backupfilesRevertButtonSetEnabled(true);
2678 updateBackupFilesExampleLabel();
2681 backupfilesKeepAll.addActionListener(new ActionListener()
2684 public void actionPerformed(ActionEvent e)
2686 backupfilesRevertButtonSetEnabled(true);
2687 keepRollMaxOptionsEnabled();
2688 updateBackupFilesExampleLabel();
2692 ChangeListener c = new ChangeListener()
2695 public void stateChanged(ChangeEvent e)
2697 backupfilesRevertButtonSetEnabled(true);
2698 updateBackupFilesExampleLabel();
2702 setIntegerSpinner(backupfilesRollMaxSpinner,
2703 BackupFilesPresetEntry.ROLLMAXMIN,
2704 BackupFilesPresetEntry.ROLLMAXMAX, 4, true, c);
2706 backupfilesConfirmDelete.setLabels(
2707 MessageManager.getString("label.always_ask"),
2708 MessageManager.getString("label.auto_delete"));
2709 backupfilesConfirmDelete.addActionListener(new ActionListener()
2712 public void actionPerformed(ActionEvent e)
2714 backupfilesRevertButtonSetEnabled(true);
2717 // update the enabled section
2718 keepRollMaxOptionsEnabled();
2720 GridBagConstraints kgbc = new GridBagConstraints();
2722 // first row (template text box)
2723 kgbc.anchor = GridBagConstraints.WEST;
2726 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2727 kgbc.gridheight = 1;
2730 kgbc.fill = GridBagConstraints.HORIZONTAL;
2731 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
2737 kgbc.gridwidth = GridBagConstraints.RELATIVE;
2738 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
2741 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2742 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
2744 // third row (indented)
2746 kgbc.insets = new Insets(0, 20, 0, 0);
2749 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2750 kgbc.fill = GridBagConstraints.HORIZONTAL;
2753 JPanel jp = new JPanel();
2754 jp.setLayout(new FlowLayout());
2755 oldBackupFilesLabel.setText(
2756 MessageManager.getString("label.autodelete_old_backup_files"));
2757 oldBackupFilesLabel.setFont(LABEL_FONT);
2758 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
2759 jp.add(oldBackupFilesLabel);
2760 jp.add(backupfilesConfirmDelete.getTrueButton());
2761 jp.add(backupfilesConfirmDelete.getFalseButton());
2762 keepfilesPanel.add(jp, kgbc);
2764 return keepfilesPanel;
2767 protected void updateBackupFilesExampleLabel()
2769 int exampleindex = 12;
2770 String base = MessageManager.getString("label.filename") + ".fa";
2771 if (base == null || base.length() == 0)
2773 base = "file_name.fa";
2776 boolean reverse = suffixReverse.isSelected();
2777 boolean keepAll = backupfilesKeepAll.isSelected();
2779 String suffix = suffixTemplate.getText();
2782 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
2783 if (suffix == null || suffix.length() == 0)
2785 backupfilesExampleLabel
2786 .setText(MessageManager.getString("label.no_backup_files"));
2787 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
2791 rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 4);
2792 rollMax = rollMax < 1 ? 1 : rollMax;
2794 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
2799 digits = getSpinnerInt(suffixDigitsSpinner, 3);
2800 digits = digits < 1 ? 1 : digits;
2802 int lowersurround = 2;
2803 int uppersurround = 0;
2804 StringBuilder exampleSB = new StringBuilder();
2805 boolean firstLine = true;
2811 int max = keepAll ? exampleindex : rollMax;
2812 for (int index = min; index <= max; index++)
2814 if (index == min + lowersurround && index < max - uppersurround - 1)
2816 exampleSB.append("\n...");
2819 else if (index > min + lowersurround && index < max - uppersurround)
2831 exampleSB.append("\n");
2834 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2835 base, suffix, digits));
2838 // no extra text needed
2840 else if (index == min)
2842 String newest = MessageManager.getString("label.braced_newest");
2843 if (newest != null && newest.length() > 0)
2845 exampleSB.append(" " + newest);
2848 else if (index == max)
2850 String oldest = MessageManager.getString("label.braced_oldest");
2851 if (oldest != null && oldest.length() > 0)
2853 exampleSB.append(" " + oldest);
2862 int min = (keepAll || exampleindex - rollMax < 0) ? 1
2863 : exampleindex - rollMax + 1;
2864 int max = exampleindex;
2866 for (int index = min; index <= max; index++)
2869 if (index == min + lowersurround && index < max - uppersurround - 1)
2871 exampleSB.append("\n...");
2874 else if (index > min + lowersurround && index < max - uppersurround)
2886 exampleSB.append("\n");
2889 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2890 base, suffix, digits));
2893 // no extra text needed
2895 else if (index == min)
2897 String oldest = MessageManager.getString("label.braced_oldest");
2898 if (oldest != null && oldest.length() > 0)
2900 exampleSB.append(" " + oldest);
2903 else if (index == max)
2905 String newest = MessageManager.getString("label.braced_newest");
2906 if (newest != null && newest.length() > 0)
2908 exampleSB.append(" " + newest);
2916 // add some extra empty lines to pad out the example files box. ugh, please
2918 // me how to do this better
2919 int remainingLines = lowersurround + uppersurround + 1 - lineNumber;
2920 if (remainingLines > 0)
2922 for (int i = 0; i < remainingLines; i++)
2924 exampleSB.append("\n ");
2929 backupfilesExampleLabel.setText(exampleSB.toString());
2932 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2933 boolean useExistingVal, ChangeListener c)
2940 i = ((Integer) s.getValue()).intValue();
2941 } catch (Exception e)
2944 "Exception casting the initial value of s.getValue()");
2948 setIntegerSpinner(s, min, max, i, c);
2951 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2954 // integer spinner for number of digits
2963 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
2966 s.addChangeListener(c);
2970 protected static int getSpinnerInt(JSpinner s, int def)
2976 i = (Integer) s.getValue();
2977 } catch (Exception e)
2979 Cache.log.error("Failed casting (Integer) JSpinner s.getValue()");
2984 private void keepRollMaxOptionsEnabled()
2986 boolean enabled = backupfilesKeepAll.isEnabled()
2987 && !backupfilesKeepAll.isSelected();
2988 oldBackupFilesLabel.setEnabled(enabled);
2989 backupfilesRollMaxSpinner.setEnabled(enabled);
2990 backupfilesConfirmDelete.setEnabled(enabled);
2993 private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
2995 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2996 && customiseCheckbox.isSelected() && suffixTemplate.getText()
2997 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2998 keepfilesPanel.setEnabled(enabled);
2999 backupfilesKeepAll.setEnabled(enabled);
3000 oldBackupFilesLabel.setEnabled(enabled);
3001 keepRollMaxOptionsEnabled();
3004 private void backupfilesSuffixTemplateDigitsSetEnabled()
3006 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
3007 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
3008 suffixDigitsLabel.setEnabled(enabled);
3009 suffixDigitsSpinner.setEnabled(enabled);
3010 suffixReverse.setEnabled(enabled);
3013 private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
3015 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3016 && customiseCheckbox.isSelected();
3017 suffixPanel.setEnabled(enabled);
3018 suffixTemplateLabel.setEnabled(enabled);
3019 suffixTemplate.setEnabled(enabled);
3020 backupfilesSuffixTemplateDigitsSetEnabled();
3023 private void backupfilesRevertButtonSetEnabled(boolean tryEnabled)
3025 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3026 && customiseCheckbox.isSelected() && backupfilesCustomChanged();
3027 revertButton.setEnabled(enabled);
3030 private boolean backupfilesCustomChanged()
3032 BackupFilesPresetEntry custom = BackupFilesPresetEntry.backupfilesPresetEntriesValues
3033 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
3034 BackupFilesPresetEntry current = getBackupfilesCurrentEntry();
3035 return !custom.equals(current);
3038 protected BackupFilesPresetEntry getBackupfilesCurrentEntry()
3040 String suffix = suffixTemplate.getText();
3041 int digits = getSpinnerInt(suffixDigitsSpinner, 3);
3042 boolean reverse = suffixReverse.isSelected();
3043 boolean keepAll = backupfilesKeepAll.isSelected();
3044 int rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 3);
3045 boolean confirmDelete = backupfilesConfirmDelete.isSelected();
3047 BackupFilesPresetEntry bfpe = new BackupFilesPresetEntry(suffix, digits,
3048 reverse, keepAll, rollMax, confirmDelete);
3053 protected void backupfilesCustomOptionsSetEnabled()
3055 boolean enabled = customiseCheckbox.isSelected();
3057 backupfilesRevertButtonSetEnabled(enabled);
3058 backupfilesSuffixTemplateSetEnabled(enabled);
3059 backupfilesKeepAllSetEnabled(enabled);
3062 private void backupfilesSummarySetEnabled()
3064 boolean enabled = enableBackupFiles.isSelected();
3065 backupfilesExampleLabel.setEnabled(enabled);
3066 exampleFilesPanel.setEnabled(enabled);
3069 private void backupfilesPresetsSetEnabled()
3071 boolean enabled = enableBackupFiles.isSelected();
3072 presetsPanel.setEnabled(enabled);
3073 presetsComboLabel.setEnabled(enabled);
3074 backupfilesPresetsCombo.setEnabled(enabled);
3075 customiseCheckbox.setEnabled(enabled);
3076 revertButton.setEnabled(enabled);
3079 protected void backupsOptionsSetEnabled()
3081 backupfilesPresetsSetEnabled();
3082 backupfilesSummarySetEnabled();
3083 backupfilesCustomOptionsSetEnabled();
3086 protected void backupsSetOptions(String suffix, int digits,
3087 boolean reverse, boolean keepAll, int rollMax,
3088 boolean confirmDelete)
3090 suffixTemplate.setText(suffix);
3091 suffixDigitsSpinner.setValue(digits);
3092 suffixReverse.setSelected(reverse);
3093 backupfilesKeepAll.setSelected(keepAll);
3094 backupfilesRollMaxSpinner.setValue(rollMax);
3095 backupfilesConfirmDelete.setSelected(confirmDelete);
3098 protected void backupsSetOptions(BackupFilesPresetEntry p)
3100 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
3104 protected void autoIdWidth_actionPerformed()
3106 // TODO Auto-generated method stub
3110 protected void userIdWidth_actionPerformed()
3112 // TODO Auto-generated method stub
3116 protected void maxColour_actionPerformed(JPanel panel)
3120 protected void minColour_actionPerformed(JPanel panel)
3124 protected void gapColour_actionPerformed(JPanel panel)
3128 protected void hiddenColour_actionPerformed(JPanel panel)
3132 protected void showunconserved_actionPerformed(ActionEvent e)
3134 // TODO Auto-generated method stub
3138 protected void useLegacyGaps_actionPerformed(ActionEvent e)
3142 protected void resetOvDefaults_actionPerformed(ActionEvent e)
3152 public void ok_actionPerformed(ActionEvent e)
3162 public void cancel_actionPerformed(ActionEvent e)
3172 public void annotations_actionPerformed(ActionEvent e)
3179 public void startupFileTextfield_mouseClicked()
3183 public void newLink_actionPerformed(ActionEvent e)
3188 public void editLink_actionPerformed(ActionEvent e)
3193 public void deleteLink_actionPerformed(ActionEvent e)
3198 public void defaultBrowser_mouseClicked(MouseEvent e)
3203 public void linkURLList_keyTyped(KeyEvent e)
3208 public void setProxyAuthEnabled()
3210 boolean enabled = proxyAuth.isSelected() && proxyAuth.isEnabled();
3211 proxyAuthUsernameLabel.setEnabled(enabled);
3212 proxyAuthPasswordLabel.setEnabled(enabled);
3213 passwordNotStoredLabel.setEnabled(enabled);
3214 proxyAuthUsernameTB.setEnabled(enabled);
3215 proxyAuthPasswordPB.setEnabled(enabled);
3218 public void setCustomProxyEnabled()
3220 boolean enabled = customProxy.isSelected();
3221 portLabel.setEnabled(enabled);
3222 serverLabel.setEnabled(enabled);
3223 portLabel2.setEnabled(enabled);
3224 serverLabel2.setEnabled(enabled);
3225 httpLabel.setEnabled(enabled);
3226 httpsLabel.setEnabled(enabled);
3227 proxyServerHttpTB.setEnabled(enabled);
3228 proxyPortHttpTB.setEnabled(enabled);
3229 proxyServerHttpsTB.setEnabled(enabled);
3230 proxyPortHttpsTB.setEnabled(enabled);
3231 proxyAuth.setEnabled(enabled);
3232 setProxyAuthEnabled();
3235 public void proxyType_actionPerformed()
3237 setCustomProxyEnabled();
3238 proxyAuthPasswordCheckHighlight(true);
3239 applyProxyButtonEnabled(true);
3242 public void proxyAuth_actionPerformed()
3244 setProxyAuthEnabled();
3245 proxyAuthPasswordCheckHighlight(true);
3246 applyProxyButtonEnabled(true);
3250 * Customer renderer for JTable: supports column of radio buttons
3252 public class RadioButtonRenderer extends JRadioButton
3253 implements TableCellRenderer
3255 public RadioButtonRenderer()
3257 setHorizontalAlignment(CENTER);
3258 setToolTipText(MessageManager.getString("label.urltooltip"));
3262 public Component getTableCellRendererComponent(JTable table,
3263 Object value, boolean isSelected, boolean hasFocus, int row,
3266 setSelected((boolean) value);
3268 // set colours to match rest of table
3271 setBackground(table.getSelectionBackground());
3272 setForeground(table.getSelectionForeground());
3276 setBackground(table.getBackground());
3277 setForeground(table.getForeground());
3284 * Customer cell editor for JTable: supports column of radio buttons in
3285 * conjunction with renderer
3287 public class RadioButtonEditor extends AbstractCellEditor
3288 implements TableCellEditor
3290 private JRadioButton button = new JRadioButton();
3292 public RadioButtonEditor()
3294 button.setHorizontalAlignment(SwingConstants.CENTER);
3295 this.button.addActionListener(new ActionListener()
3298 public void actionPerformed(ActionEvent e)
3300 fireEditingStopped();
3306 public Component getTableCellEditorComponent(JTable table, Object value,
3307 boolean isSelected, int row, int column)
3309 button.setSelected((boolean) value);
3314 public Object getCellEditorValue()
3316 return button.isSelected();