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 jalview.bin.Cache;
24 import jalview.bin.Console;
25 import jalview.bin.MemorySetting;
26 import jalview.fts.core.FTSDataColumnPreferences;
27 import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource;
28 import jalview.fts.service.pdb.PDBFTSRestClient;
29 import jalview.gui.Desktop;
30 import jalview.gui.JalviewBooleanRadioButtons;
31 import jalview.gui.JvOptionPane;
32 import jalview.gui.JvSwingUtils;
33 import jalview.gui.StructureViewer.ViewerType;
34 import jalview.io.BackupFilenameParts;
35 import jalview.io.BackupFiles;
36 import jalview.io.BackupFilesPresetEntry;
37 import jalview.io.IntKeyStringValueEntry;
38 import jalview.util.MessageManager;
39 import jalview.util.Platform;
40 import jalview.util.StringUtils;
42 import java.awt.BorderLayout;
43 import java.awt.Color;
44 import java.awt.Component;
45 import java.awt.Dimension;
46 import java.awt.FlowLayout;
48 import java.awt.GridBagConstraints;
49 import java.awt.GridBagLayout;
50 import java.awt.GridLayout;
51 import java.awt.Insets;
52 import java.awt.Rectangle;
53 import java.awt.event.ActionEvent;
54 import java.awt.event.ActionListener;
55 import java.awt.event.FocusEvent;
56 import java.awt.event.KeyEvent;
57 import java.awt.event.KeyListener;
58 import java.awt.event.MouseAdapter;
59 import java.awt.event.MouseEvent;
60 import java.util.Arrays;
61 import java.util.List;
63 import javax.swing.AbstractButton;
64 import javax.swing.AbstractCellEditor;
65 import javax.swing.BorderFactory;
66 import javax.swing.BoxLayout;
67 import javax.swing.ButtonGroup;
68 import javax.swing.DefaultListCellRenderer;
69 import javax.swing.JButton;
70 import javax.swing.JCheckBox;
71 import javax.swing.JComboBox;
72 import javax.swing.JComponent;
73 import javax.swing.JFileChooser;
74 import javax.swing.JLabel;
75 import javax.swing.JPanel;
76 import javax.swing.JPasswordField;
77 import javax.swing.JRadioButton;
78 import javax.swing.JScrollPane;
79 import javax.swing.JSlider;
80 import javax.swing.JSpinner;
81 import javax.swing.JTabbedPane;
82 import javax.swing.JTable;
83 import javax.swing.JTextArea;
84 import javax.swing.JTextField;
85 import javax.swing.ListSelectionModel;
86 import javax.swing.SpinnerModel;
87 import javax.swing.SpinnerNumberModel;
88 import javax.swing.SwingConstants;
89 import javax.swing.border.Border;
90 import javax.swing.border.EmptyBorder;
91 import javax.swing.border.EtchedBorder;
92 import javax.swing.border.TitledBorder;
93 import javax.swing.event.ChangeEvent;
94 import javax.swing.event.ChangeListener;
95 import javax.swing.event.DocumentEvent;
96 import javax.swing.event.DocumentListener;
97 import javax.swing.table.TableCellEditor;
98 import javax.swing.table.TableCellRenderer;
100 import net.miginfocom.swing.MigLayout;
103 * Base class for the Preferences panel.
106 * @version $Revision$
108 public class GPreferences extends JPanel
110 private static final Font LABEL_FONT = JvSwingUtils.getLabelFont();
112 private static final Font LABEL_FONT_ITALIC = JvSwingUtils
113 .getLabelFont(false, true);
115 private static final Font LABEL_FONT_BOLD = JvSwingUtils
116 .getLabelFont(true, false);
119 * Visual tab components
121 protected JCheckBox fullScreen = new JCheckBox();
123 protected JCheckBox openoverv = new JCheckBox();
125 protected JCheckBox seqLimit = new JCheckBox();
127 protected JCheckBox rightAlign = new JCheckBox();
129 protected JComboBox<String> fontSizeCB = new JComboBox<>();
131 protected JComboBox<String> fontStyleCB = new JComboBox<>();
133 protected JComboBox<String> fontNameCB = new JComboBox<>();
135 protected JCheckBox showOccupancy = new JCheckBox();
137 protected JCheckBox showUnconserved = new JCheckBox();
139 protected JCheckBox idItalics = new JCheckBox();
141 protected JCheckBox smoothFont = new JCheckBox();
143 protected JCheckBox scaleProteinToCdna = new JCheckBox();
145 protected JComboBox<String> gapSymbolCB = new JComboBox<>();
147 protected JCheckBox wrap = new JCheckBox();
149 protected JComboBox<String> sortby = new JComboBox<>();
151 protected JComboBox<String> sortAnnBy = new JComboBox<>();
153 protected JComboBox<String> sortAutocalc = new JComboBox<>();
155 protected JCheckBox startupCheckbox = new JCheckBox();
157 protected JTextField startupFileTextfield = new JTextField();
159 // below are in the 'second column'
160 protected JCheckBox annotations = new JCheckBox();
162 protected JCheckBox quality = new JCheckBox();
164 protected JCheckBox conservation = new JCheckBox();
166 protected JCheckBox identity = new JCheckBox();
168 protected JCheckBox showGroupConsensus = new JCheckBox();
170 protected JCheckBox showGroupConservation = new JCheckBox();
172 protected JCheckBox showConsensHistogram = new JCheckBox();
174 protected JCheckBox showConsensLogo = new JCheckBox();
176 protected JCheckBox showInformationHistogram = new JCheckBox();
178 protected JCheckBox showHMMLogo = new JCheckBox();
179 protected JCheckBox showDbRefTooltip = new JCheckBox();
181 protected JCheckBox showNpTooltip = new JCheckBox();
184 * Structure tab and components
186 protected JPanel structureTab;
188 protected JCheckBox structFromPdb = new JCheckBox();
190 protected JCheckBox addSecondaryStructure = new JCheckBox();
192 protected JCheckBox addTempFactor = new JCheckBox();
194 protected JComboBox<String> structViewer = new JComboBox<>();
196 protected JLabel structureViewerPathLabel;
198 protected JTextField structureViewerPath = new JTextField();
200 protected ButtonGroup mappingMethod = new ButtonGroup();
202 protected JRadioButton siftsMapping = new JRadioButton();
204 protected JRadioButton nwMapping = new JRadioButton();
207 * Colours tab components
209 protected JPanel minColour = new JPanel();
211 protected JPanel maxColour = new JPanel();
213 protected JComboBox<String> protColour = new JComboBox<>();
215 protected JComboBox<String> nucColour = new JComboBox<>();
218 * Overview tab components
220 protected JPanel gapColour = new JPanel();
222 protected JPanel hiddenColour = new JPanel();
224 protected JCheckBox useLegacyGap;
226 protected JCheckBox showHiddenAtStart;
228 protected JLabel gapLabel;
231 * Connections tab components
233 protected JPanel connectTab;
235 protected JTable linkUrlTable = new JTable();
237 protected JButton editLink = new JButton();
239 protected JButton deleteLink = new JButton();
241 protected JTextField filterTB = new JTextField();
243 protected JButton doReset = new JButton();
245 protected JButton userOnly = new JButton();
247 protected JLabel httpLabel = new JLabel();
249 protected JLabel httpsLabel = new JLabel();
251 protected JLabel portLabel = new JLabel();
253 protected JLabel serverLabel = new JLabel();
255 protected JLabel portLabel2 = new JLabel();
257 protected JLabel serverLabel2 = new JLabel();
259 protected JLabel proxyAuthUsernameLabel = new JLabel();
261 protected JLabel proxyAuthPasswordLabel = new JLabel();
263 protected JLabel passwordNotStoredLabel = new JLabel();
265 protected JTextField proxyServerHttpTB = new JTextField();
267 protected JTextField proxyPortHttpTB = new JTextField();
269 protected JTextField proxyServerHttpsTB = new JTextField();
271 protected JTextField proxyPortHttpsTB = new JTextField();
273 protected JCheckBox proxyAuth = new JCheckBox();
275 protected JTextField proxyAuthUsernameTB = new JTextField();
277 protected JPasswordField proxyAuthPasswordPB = new JPasswordField();
279 protected JTextField defaultBrowser = new JTextField();
281 protected ButtonGroup proxyType = new ButtonGroup();
283 protected JRadioButton noProxy = new JRadioButton();
285 protected JRadioButton systemProxy = new JRadioButton();
287 protected JRadioButton customProxy = new JRadioButton();
289 protected JButton applyProxyButton = new JButton();
291 protected JCheckBox usagestats = new JCheckBox();
293 protected JCheckBox questionnaire = new JCheckBox();
295 protected JCheckBox versioncheck = new JCheckBox();
298 * Output tab components
300 protected JComboBox<Object> epsRendering = new JComboBox<>();
302 protected JComboBox<Object> htmlRendering = new JComboBox<>();
304 protected JComboBox<Object> svgRendering = new JComboBox<>();
306 protected JLabel userIdWidthlabel = new JLabel();
308 protected JCheckBox autoIdWidth = new JCheckBox();
310 protected JTextField userIdWidth = new JTextField();
312 protected JCheckBox blcjv = new JCheckBox();
314 protected JCheckBox pileupjv = new JCheckBox();
316 protected JCheckBox clustaljv = new JCheckBox();
318 protected JCheckBox msfjv = new JCheckBox();
320 protected JCheckBox fastajv = new JCheckBox();
322 protected JCheckBox pfamjv = new JCheckBox();
324 protected JCheckBox pirjv = new JCheckBox();
326 protected JCheckBox modellerOutput = new JCheckBox();
328 protected JCheckBox embbedBioJSON = new JCheckBox();
331 * Editing tab components
333 protected JCheckBox autoCalculateConsCheck = new JCheckBox();
335 protected JCheckBox padGaps = new JCheckBox();
337 protected JCheckBox sortByTree = new JCheckBox();
340 * hmmer tab and components
342 protected JPanel hmmerTab;
344 protected JCheckBox hmmrTrimTermini;
346 protected AbstractButton hmmerBackgroundUniprot;
348 protected AbstractButton hmmerBackgroundAlignment;
350 protected JTextField hmmerSequenceCount;
352 protected JTextField hmmerPath;
354 protected JTextField cygwinPath;
359 protected JPanel wsTab = new JPanel();
361 protected JPanel slivkaTab = new JPanel();
363 * Backups tab components
364 * a lot of these are member variables instead of local variables only so that they
365 * can be enabled/disabled easily in one go
368 protected JCheckBox enableBackupFiles = new JCheckBox();
370 protected JPanel presetsPanel = new JPanel();
372 protected JLabel presetsComboLabel = new JLabel();
374 protected JCheckBox customiseCheckbox = new JCheckBox();
376 protected JButton revertButton = new JButton();
378 protected JComboBox<Object> backupfilesPresetsCombo = new JComboBox<>();
380 private int backupfilesPresetsComboLastSelected = 0;
382 protected JPanel suffixPanel = new JPanel();
384 protected JPanel keepfilesPanel = new JPanel();
386 protected JPanel exampleFilesPanel = new JPanel();
388 protected JTextField suffixTemplate = new JTextField(null, 8);
390 protected JLabel suffixTemplateLabel = new JLabel();
392 protected JLabel suffixDigitsLabel = new JLabel();
394 protected JSpinner suffixDigitsSpinner = new JSpinner();
396 protected JalviewBooleanRadioButtons suffixReverse = new JalviewBooleanRadioButtons();
398 protected JalviewBooleanRadioButtons backupfilesKeepAll = new JalviewBooleanRadioButtons();
400 public JSpinner backupfilesRollMaxSpinner = new JSpinner();
402 protected JLabel oldBackupFilesLabel = new JLabel();
404 protected JalviewBooleanRadioButtons backupfilesConfirmDelete = new JalviewBooleanRadioButtons();
406 protected JTextArea backupfilesExampleLabel = new JTextArea();
408 private final JTabbedPane tabbedPane = new JTabbedPane();
410 private JLabel messageLabel = new JLabel("", JLabel.CENTER);
413 * Startup tab components
416 protected JCheckBox customiseMemorySetting = new JCheckBox();
418 protected JLabel exampleMemoryLabel = new JLabel();
420 protected JTextArea exampleMemoryMessageTextArea = new JTextArea();
422 protected JLabel maxMemoryLabel = new JLabel();
424 protected JLabel jvmMemoryPercentLabel = new JLabel();
426 protected JSlider jvmMemoryPercentSlider = new JSlider();
428 protected JLabel jvmMemoryPercentDisplay = new JLabel();
430 protected JLabel jvmMemoryMaxLabel = new JLabel();
432 protected JTextField jvmMemoryMaxTextField = new JTextField(null, 8);
434 protected JComboBox<Object> lafCombo = new JComboBox<>();
436 * Creates a new GPreferences object.
438 public GPreferences()
443 } catch (Exception ex)
445 ex.printStackTrace();
450 * Construct the panel and its tabbed sub-panels.
454 private void jbInit() throws Exception
456 // final JTabbedPane tabbedPane = new JTabbedPane();
457 this.setLayout(new BorderLayout());
459 // message label at top
460 this.add(messageLabel, BorderLayout.NORTH);
462 JPanel okCancelPanel = initOkCancelPanel();
463 this.add(tabbedPane, BorderLayout.CENTER);
464 this.add(okCancelPanel, BorderLayout.SOUTH);
466 tabbedPane.add(initVisualTab(),
467 MessageManager.getString("label.visual"));
469 tabbedPane.add(initColoursTab(),
470 MessageManager.getString("label.colours"));
472 tabbedPane.add(initOverviewTab(),
473 MessageManager.getString("label.overview"));
475 tabbedPane.add(initStructureTab(),
476 MessageManager.getString("label.structure"));
478 tabbedPane.add(initConnectionsTab(),
479 MessageManager.getString("label.connections"));
481 if (!Platform.isJS())
483 tabbedPane.add(initBackupsTab(),
484 MessageManager.getString("label.backups"));
487 tabbedPane.add(initLinksTab(),
488 MessageManager.getString("label.urllinks"));
490 tabbedPane.add(initOutputTab(),
491 MessageManager.getString("label.output"));
493 tabbedPane.add(initEditingTab(),
494 MessageManager.getString("label.editing"));
497 * See WsPreferences for the real work of configuring this tab.
499 if (!Platform.isJS())
501 tabbedPane.add(initHMMERTab(), MessageManager.getString("label.hmmer"));
502 tabbedPane.add(initStartupTab(),
503 MessageManager.getString("label.startup"));
504 wsTab.setLayout(new BorderLayout());
505 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
508 slivkaTab.setLayout(new BorderLayout());
509 tabbedPane.add(slivkaTab, "Slivka Services");
512 * Handler to validate a tab before leaving it - currently only for
514 * Adding a clearMessage() so messages are cleared when changing tabs.
516 tabbedPane.addChangeListener(new ChangeListener()
518 private Component lastTab;
521 public void stateChanged(ChangeEvent e)
523 if (lastTab == structureTab
524 && tabbedPane.getSelectedComponent() != structureTab)
526 if (!validateStructure())
528 tabbedPane.setSelectedComponent(structureTab);
532 lastTab = tabbedPane.getSelectedComponent();
540 public void setMessage(String message)
544 messageLabel.setText(message);
545 messageLabel.setFont(LABEL_FONT_BOLD);
546 messageLabel.setForeground(Color.RED.darker());
547 messageLabel.revalidate();
548 messageLabel.repaint();
550 // note message not cleared if message is null. call clearMessage()
556 public void clearMessage()
558 // only repaint if message exists
559 if (messageLabel.getText() != null
560 && messageLabel.getText().length() > 0)
562 messageLabel.setText("");
563 messageLabel.revalidate();
564 messageLabel.repaint();
570 public static enum TabRef
572 CONNECTIONS_TAB, STRUCTURE_TAB
575 public void selectTab(TabRef selectTab)
577 // select a given tab - currently only for Connections
580 case CONNECTIONS_TAB:
581 tabbedPane.setSelectedComponent(connectTab);
584 tabbedPane.setSelectedComponent(structureTab);
591 * Initialises the Editing tabbed panel.
595 private JPanel initEditingTab()
597 JPanel editingTab = new JPanel();
598 editingTab.setLayout(null);
599 autoCalculateConsCheck.setFont(LABEL_FONT);
600 autoCalculateConsCheck.setText(
601 MessageManager.getString("label.autocalculate_consensus"));
602 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
603 padGaps.setFont(LABEL_FONT);
605 MessageManager.getString("label.pad_gaps_when_editing"));
606 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
607 sortByTree.setFont(LABEL_FONT);
609 .setText(MessageManager.getString("label.sort_with_new_tree"));
610 sortByTree.setToolTipText(MessageManager.getString(
611 "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
612 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
613 editingTab.add(autoCalculateConsCheck);
614 editingTab.add(padGaps);
615 editingTab.add(sortByTree);
620 * Initialises the hmmer tabbed panel
624 private JPanel initHMMERTab()
626 hmmerTab = new JPanel();
627 hmmerTab.setLayout(new BoxLayout(hmmerTab, BoxLayout.Y_AXIS));
628 hmmerTab.setLayout(new MigLayout("flowy"));
631 * path to hmmer binaries folder
633 JPanel installationPanel = new JPanel(new MigLayout("flowy"));
634 // new FlowLayout(FlowLayout.LEFT));
635 JvSwingUtils.createTitledBorder(installationPanel,
636 MessageManager.getString("label.installation"), true);
637 hmmerTab.add(installationPanel);
638 JLabel hmmerLocation = new JLabel(
639 MessageManager.getString("label.hmmer_location"));
640 hmmerLocation.setFont(LABEL_FONT);
641 final int pathFieldLength = 40;
642 hmmerPath = new JTextField(pathFieldLength);
643 hmmerPath.addMouseListener(new MouseAdapter()
646 public void mouseClicked(MouseEvent e)
648 if (e.getClickCount() == 2)
650 String chosen = openFileChooser(true);
653 hmmerPath.setText(chosen);
659 installationPanel.add(hmmerLocation);
660 installationPanel.add(hmmerPath);
663 * path to Cygwin binaries folder (for Windows)
665 if (Platform.isWindowsAndNotJS())
667 JLabel cygwinLocation = new JLabel(
668 MessageManager.getString("label.cygwin_location"));
669 cygwinLocation.setFont(LABEL_FONT);
670 cygwinPath = new JTextField(pathFieldLength);
671 cygwinPath.addMouseListener(new MouseAdapter()
674 public void mouseClicked(MouseEvent e)
676 if (e.getClickCount() == 2)
678 String chosen = openFileChooser(true);
681 cygwinPath.setText(chosen);
682 validateCygwinPath();
687 installationPanel.add(cygwinLocation);
688 installationPanel.add(cygwinPath);
692 * preferences for hmmalign
694 JPanel alignOptionsPanel = new JPanel(new MigLayout());
695 // new FlowLayout(FlowLayout.LEFT));
696 JvSwingUtils.createTitledBorder(alignOptionsPanel,
697 MessageManager.getString("label.hmmalign_options"), true);
698 hmmerTab.add(alignOptionsPanel);
699 hmmrTrimTermini = new JCheckBox();
700 hmmrTrimTermini.setFont(LABEL_FONT);
701 hmmrTrimTermini.setText(MessageManager.getString("label.trim_termini"));
702 alignOptionsPanel.add(hmmrTrimTermini);
705 * preferences for hmmsearch
707 JPanel searchOptions = new JPanel(new MigLayout());
708 // FlowLayout(FlowLayout.LEFT));
709 JvSwingUtils.createTitledBorder(searchOptions,
710 MessageManager.getString("label.hmmsearch_options"), true);
711 hmmerTab.add(searchOptions);
712 JLabel sequencesToKeep = new JLabel(
713 MessageManager.getString("label.no_of_sequences"));
714 sequencesToKeep.setFont(LABEL_FONT);
715 searchOptions.add(sequencesToKeep);
716 hmmerSequenceCount = new JTextField(5);
717 searchOptions.add(hmmerSequenceCount);
720 * preferences for Information Content annotation
722 // JPanel dummy = new JPanel(new FlowLayout(FlowLayout.LEFT));
723 JPanel annotationOptions = new JPanel(new MigLayout("left"));
724 JvSwingUtils.createTitledBorder(annotationOptions,
725 MessageManager.getString("label.information_annotation"), true);
726 // dummy.add(annotationOptions);
727 hmmerTab.add(annotationOptions);
728 ButtonGroup backgroundOptions = new ButtonGroup();
729 hmmerBackgroundUniprot = new JRadioButton(
730 MessageManager.getString("label.freq_uniprot"));
731 hmmerBackgroundUniprot.setFont(LABEL_FONT);
732 hmmerBackgroundAlignment = new JRadioButton(
733 MessageManager.getString("label.freq_alignment"));
734 hmmerBackgroundAlignment.setFont(LABEL_FONT);
735 backgroundOptions.add(hmmerBackgroundUniprot);
736 backgroundOptions.add(hmmerBackgroundAlignment);
737 backgroundOptions.setSelected(hmmerBackgroundUniprot.getModel(), true);
738 // disable buttons for now as annotation only uses Uniprot background
739 hmmerBackgroundAlignment.setEnabled(false);
740 hmmerBackgroundUniprot.setEnabled(false);
741 annotationOptions.add(hmmerBackgroundUniprot, "wrap");
742 annotationOptions.add(hmmerBackgroundAlignment);
748 * Initialises the Output tabbed panel.
752 private JPanel initOutputTab()
754 JPanel outputTab = new JPanel();
755 outputTab.setLayout(null);
757 JLabel epsLabel = new JLabel(
758 MessageManager.formatMessage("label.rendering_style", "EPS"));
759 epsLabel.setFont(LABEL_FONT);
760 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
761 epsLabel.setBounds(new Rectangle(9, 31, 160, 24));
762 epsRendering.setFont(LABEL_FONT);
763 epsRendering.setBounds(new Rectangle(174, 34, 187, 21));
764 JLabel htmlLabel = new JLabel(
765 MessageManager.formatMessage("label.rendering_style", "HTML"));
766 htmlLabel.setFont(LABEL_FONT);
767 htmlLabel.setHorizontalAlignment(SwingConstants.RIGHT);
768 htmlLabel.setBounds(new Rectangle(9, 55, 160, 24));
769 htmlRendering.setFont(LABEL_FONT);
770 htmlRendering.setBounds(new Rectangle(174, 58, 187, 21));
771 JLabel svgLabel = new JLabel(
772 MessageManager.formatMessage("label.rendering_style", "SVG"));
773 svgLabel.setFont(LABEL_FONT);
774 svgLabel.setHorizontalAlignment(SwingConstants.RIGHT);
775 svgLabel.setBounds(new Rectangle(9, 79, 160, 24));
776 svgRendering.setFont(LABEL_FONT);
777 svgRendering.setBounds(new Rectangle(174, 82, 187, 21));
779 JLabel jLabel1 = new JLabel();
780 jLabel1.setFont(LABEL_FONT);
781 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
782 jLabel1.setText(MessageManager.getString("label.append_start_end"));
783 jLabel1.setFont(LABEL_FONT);
785 fastajv.setFont(LABEL_FONT);
786 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
787 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
788 blcjv.setText(MessageManager.getString("label.blc") + " ");
789 fastajv.setText(MessageManager.getString("label.fasta") + " ");
790 msfjv.setText(MessageManager.getString("label.msf") + " ");
791 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
792 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
793 msfjv.setFont(LABEL_FONT);
794 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
795 pirjv.setText(MessageManager.getString("label.pir") + " ");
796 JPanel jPanel11 = new JPanel();
797 jPanel11.setFont(LABEL_FONT);
798 TitledBorder titledBorder2 = new TitledBorder(
799 MessageManager.getString("label.file_output"));
800 jPanel11.setBorder(titledBorder2);
801 jPanel11.setBounds(new Rectangle(30, 120, 196, 182));
802 GridLayout gridLayout3 = new GridLayout();
803 jPanel11.setLayout(gridLayout3);
804 gridLayout3.setRows(8);
805 blcjv.setFont(LABEL_FONT);
806 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
807 clustaljv.setFont(LABEL_FONT);
808 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
809 pfamjv.setFont(LABEL_FONT);
810 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
811 pileupjv.setFont(LABEL_FONT);
812 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
813 pirjv.setFont(LABEL_FONT);
814 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
815 autoIdWidth.setFont(LABEL_FONT);
817 MessageManager.getString("label.automatically_set_id_width"));
818 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
819 .getString("label.adjusts_width_generated_eps_png")));
820 autoIdWidth.setBounds(new Rectangle(228, 144, 320, 23));
821 autoIdWidth.addActionListener(new ActionListener()
825 public void actionPerformed(ActionEvent e)
827 autoIdWidth_actionPerformed();
830 userIdWidthlabel.setFont(LABEL_FONT);
831 userIdWidthlabel.setText(
832 MessageManager.getString("label.figure_id_column_width"));
833 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
834 .getString("label.manually_specify_width_left_column")));
835 userIdWidthlabel.setToolTipText(
836 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
837 "label.manually_specify_width_left_column")));
838 userIdWidthlabel.setBounds(new Rectangle(236, 168, 320, 23));
839 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
840 userIdWidth.setText("");
841 userIdWidth.setBounds(new Rectangle(232, 192, 84, 23));
842 userIdWidth.addActionListener(new ActionListener()
846 public void actionPerformed(ActionEvent e)
848 userIdWidth_actionPerformed();
851 modellerOutput.setFont(LABEL_FONT);
853 .setText(MessageManager.getString("label.use_modeller_output"));
854 modellerOutput.setBounds(new Rectangle(228, 274, 320, 23));
855 embbedBioJSON.setFont(LABEL_FONT);
856 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
857 embbedBioJSON.setBounds(new Rectangle(228, 248, 250, 23));
859 jPanel11.add(jLabel1);
861 jPanel11.add(clustaljv);
862 jPanel11.add(fastajv);
864 jPanel11.add(pfamjv);
865 jPanel11.add(pileupjv);
867 outputTab.add(autoIdWidth);
868 outputTab.add(userIdWidth);
869 outputTab.add(userIdWidthlabel);
870 outputTab.add(modellerOutput);
871 if (!Platform.isJS())
874 * JalviewJS doesn't support Lineart option or SVG output
876 outputTab.add(embbedBioJSON);
877 outputTab.add(epsLabel);
878 outputTab.add(epsRendering);
879 outputTab.add(htmlLabel);
880 outputTab.add(htmlRendering);
881 outputTab.add(svgLabel);
882 outputTab.add(svgRendering);
884 outputTab.add(jPanel11);
889 * Initialises the Connections tabbed panel.
893 private JPanel initConnectionsTab()
895 connectTab = new JPanel();
896 connectTab.setLayout(new GridBagLayout());
899 JPanel proxyPanel = initConnTabProxyPanel();
900 initConnTabCheckboxes();
902 // Add proxy server panel
903 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
904 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
905 new Insets(10, 0, 5, 12), 4, 10));
907 // Add usage stats, version check and questionnaire checkboxes
908 connectTab.add(usagestats,
909 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
910 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
911 new Insets(0, 2, 5, 5), 70, 1));
912 connectTab.add(questionnaire,
913 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
914 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
915 new Insets(0, 2, 5, 10), 70, 1));
916 connectTab.add(versioncheck,
917 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
918 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
919 new Insets(0, 2, 5, 5), 70, 1));
921 versioncheck.setVisible(false);
923 // Add padding so the panel doesn't look ridiculous
924 JPanel spacePanel = new JPanel();
925 connectTab.add(spacePanel,
926 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
927 GridBagConstraints.WEST, GridBagConstraints.BOTH,
928 new Insets(0, 0, 0, 5), 70, 1));
934 * Initialises the Links tabbed panel.
938 private JPanel initLinksTab()
940 JPanel linkTab = new JPanel();
941 linkTab.setLayout(new GridBagLayout());
943 // Set up table for Url links
944 linkUrlTable.getTableHeader().setReorderingAllowed(false);
945 linkUrlTable.setFillsViewportHeight(true);
946 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
947 linkUrlTable.setAutoCreateRowSorter(true);
948 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
950 // adjust row height so radio buttons actually fit
951 // don't do this in the renderer, it causes the awt thread to activate
953 JRadioButton temp = new JRadioButton();
954 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
956 // Table in scrollpane so that the table is given a scrollbar
957 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
958 linkScrollPane.setBorder(null);
960 // Panel for links functionality
961 JPanel linkPanel = new JPanel(new GridBagLayout());
962 linkPanel.setBorder(new TitledBorder(
963 MessageManager.getString("label.url_linkfrom_sequence_id")));
965 // Put the Url links panel together
967 // Buttons go at top right, resizing only resizes the blank space vertically
968 JPanel buttonPanel = initLinkTabUrlButtons();
969 GridBagConstraints linkConstraints1 = new GridBagConstraints();
970 linkConstraints1.insets = new Insets(0, 0, 5, 0);
971 linkConstraints1.gridx = 0;
972 linkConstraints1.gridy = 0;
973 linkConstraints1.weightx = 1.0;
974 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
975 linkTab.add(buttonPanel, linkConstraints1);
977 // Links table goes at top left, resizing resizes the table
978 GridBagConstraints linkConstraints2 = new GridBagConstraints();
979 linkConstraints2.insets = new Insets(0, 0, 5, 5);
980 linkConstraints2.gridx = 0;
981 linkConstraints2.gridy = 1;
982 linkConstraints2.weightx = 1.0;
983 linkConstraints2.weighty = 1.0;
984 linkConstraints2.fill = GridBagConstraints.BOTH;
985 linkTab.add(linkScrollPane, linkConstraints2);
987 // Filter box and buttons goes at bottom left, resizing resizes the text box
988 JPanel filterPanel = initLinkTabFilterPanel();
989 GridBagConstraints linkConstraints3 = new GridBagConstraints();
990 linkConstraints3.insets = new Insets(0, 0, 0, 5);
991 linkConstraints3.gridx = 0;
992 linkConstraints3.gridy = 2;
993 linkConstraints3.weightx = 1.0;
994 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
995 linkTab.add(filterPanel, linkConstraints3);
1000 private JPanel initLinkTabFilterPanel()
1002 // Filter textbox and reset button
1003 JLabel filterLabel = new JLabel(
1004 MessageManager.getString("label.filter"));
1005 filterLabel.setFont(LABEL_FONT);
1006 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1007 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
1009 filterTB.setFont(LABEL_FONT);
1010 filterTB.setText("");
1012 doReset.setText(MessageManager.getString("action.showall"));
1013 userOnly.setText(MessageManager.getString("action.customfilter"));
1015 // Panel for filter functionality
1016 JPanel filterPanel = new JPanel(new GridBagLayout());
1017 filterPanel.setBorder(new TitledBorder("Filter"));
1018 GridBagConstraints gbc = new GridBagConstraints();
1021 gbc.fill = GridBagConstraints.NONE;
1022 gbc.anchor = GridBagConstraints.WEST;
1024 filterPanel.add(filterLabel, gbc);
1026 GridBagConstraints gbc1 = new GridBagConstraints();
1029 gbc1.fill = GridBagConstraints.HORIZONTAL;
1030 gbc1.anchor = GridBagConstraints.WEST;
1032 filterPanel.add(filterTB, gbc1);
1034 GridBagConstraints gbc2 = new GridBagConstraints();
1036 gbc2.fill = GridBagConstraints.NONE;
1037 gbc2.anchor = GridBagConstraints.WEST;
1038 filterPanel.add(doReset, gbc2);
1040 GridBagConstraints gbc3 = new GridBagConstraints();
1042 gbc3.fill = GridBagConstraints.NONE;
1043 gbc3.anchor = GridBagConstraints.WEST;
1044 filterPanel.add(userOnly, gbc3);
1049 private JPanel initLinkTabUrlButtons()
1051 // Buttons for new / edit / delete Url links
1052 JButton newLink = new JButton();
1053 newLink.setText(MessageManager.getString("action.new"));
1055 editLink.setText(MessageManager.getString("action.edit"));
1057 deleteLink.setText(MessageManager.getString("action.delete"));
1059 // no current selection, so initially disable delete/edit buttons
1060 editLink.setEnabled(false);
1061 deleteLink.setEnabled(false);
1063 newLink.addActionListener(new java.awt.event.ActionListener()
1066 public void actionPerformed(ActionEvent e)
1068 newLink_actionPerformed(e);
1072 editLink.setText(MessageManager.getString("action.edit"));
1073 editLink.addActionListener(new java.awt.event.ActionListener()
1076 public void actionPerformed(ActionEvent e)
1078 editLink_actionPerformed(e);
1082 deleteLink.setText(MessageManager.getString("action.delete"));
1083 deleteLink.addActionListener(new java.awt.event.ActionListener()
1086 public void actionPerformed(ActionEvent e)
1088 deleteLink_actionPerformed(e);
1092 JPanel buttonPanel = new JPanel(new GridBagLayout());
1093 buttonPanel.setBorder(new TitledBorder("Edit links"));
1094 GridBagConstraints gbc = new GridBagConstraints();
1097 gbc.fill = GridBagConstraints.NONE;
1098 buttonPanel.add(newLink, gbc);
1100 GridBagConstraints gbc1 = new GridBagConstraints();
1103 gbc1.fill = GridBagConstraints.NONE;
1104 buttonPanel.add(editLink, gbc1);
1106 GridBagConstraints gbc2 = new GridBagConstraints();
1109 gbc2.fill = GridBagConstraints.NONE;
1110 buttonPanel.add(deleteLink, gbc2);
1112 GridBagConstraints gbc3 = new GridBagConstraints();
1115 gbc3.fill = GridBagConstraints.HORIZONTAL;
1117 JPanel spacePanel = new JPanel();
1118 spacePanel.setBorder(null);
1119 buttonPanel.add(spacePanel, gbc3);
1125 * Initialises the proxy server panel in the Connections tab
1127 * @return the proxy server panel
1129 private JPanel initConnTabProxyPanel()
1131 // Label for server text box
1132 serverLabel.setText(MessageManager.getString("label.host") + ": ");
1133 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1134 serverLabel.setFont(LABEL_FONT);
1135 serverLabel2.setText(MessageManager.getString("label.host") + ": ");
1136 serverLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
1137 serverLabel2.setFont(LABEL_FONT);
1139 // Proxy server and port text boxes
1140 proxyServerHttpTB.setFont(LABEL_FONT);
1141 proxyServerHttpTB.setColumns(40);
1142 proxyPortHttpTB.setFont(LABEL_FONT);
1143 proxyPortHttpTB.setColumns(4);
1144 proxyServerHttpsTB.setFont(LABEL_FONT);
1145 proxyServerHttpsTB.setColumns(40);
1146 proxyPortHttpsTB.setFont(LABEL_FONT);
1147 proxyPortHttpsTB.setColumns(4);
1148 proxyAuthUsernameTB.setFont(LABEL_FONT);
1149 proxyAuthUsernameTB.setColumns(30);
1151 // check for any change to enable applyProxyButton
1152 DocumentListener d = new DocumentListener()
1155 public void changedUpdate(DocumentEvent e)
1157 applyProxyButtonEnabled(true);
1161 public void insertUpdate(DocumentEvent e)
1163 applyProxyButtonEnabled(true);
1167 public void removeUpdate(DocumentEvent e)
1169 applyProxyButtonEnabled(true);
1172 proxyServerHttpTB.getDocument().addDocumentListener(d);
1173 proxyPortHttpTB.getDocument().addDocumentListener(d);
1174 proxyServerHttpsTB.getDocument().addDocumentListener(d);
1175 proxyPortHttpsTB.getDocument().addDocumentListener(d);
1176 proxyAuthUsernameTB.getDocument().addDocumentListener(d);
1177 proxyAuthPasswordPB.setFont(LABEL_FONT);
1178 proxyAuthPasswordPB.setColumns(30);
1179 proxyAuthPasswordPB.getDocument()
1180 .addDocumentListener(new DocumentListener()
1183 public void changedUpdate(DocumentEvent e)
1185 proxyAuthPasswordCheckHighlight(true);
1186 applyProxyButtonEnabled(true);
1190 public void insertUpdate(DocumentEvent e)
1192 proxyAuthPasswordCheckHighlight(true);
1193 applyProxyButtonEnabled(true);
1197 public void removeUpdate(DocumentEvent e)
1199 proxyAuthPasswordCheckHighlight(true);
1200 applyProxyButtonEnabled(true);
1205 // Label for Port text box
1206 portLabel.setFont(LABEL_FONT);
1207 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1208 portLabel.setText(MessageManager.getString("label.port") + ": ");
1209 portLabel2.setFont(LABEL_FONT);
1210 portLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
1211 portLabel2.setText(MessageManager.getString("label.port") + ": ");
1213 httpLabel.setText("HTTP");
1214 httpLabel.setFont(LABEL_FONT_BOLD);
1215 httpLabel.setHorizontalAlignment(SwingConstants.LEFT);
1216 httpsLabel.setText("HTTPS");
1217 httpsLabel.setFont(LABEL_FONT_BOLD);
1218 httpsLabel.setHorizontalAlignment(SwingConstants.LEFT);
1220 proxyAuthUsernameLabel
1221 .setText(MessageManager.getString("label.username") + ": ");
1222 proxyAuthUsernameLabel.setFont(LABEL_FONT);
1223 proxyAuthUsernameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1224 proxyAuthPasswordLabel
1225 .setText(MessageManager.getString("label.password") + ": ");
1226 proxyAuthPasswordLabel.setFont(LABEL_FONT);
1227 proxyAuthPasswordLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1228 passwordNotStoredLabel.setText(
1229 "(" + MessageManager.getString("label.not_stored") + ")");
1230 passwordNotStoredLabel.setFont(LABEL_FONT_ITALIC);
1231 passwordNotStoredLabel.setHorizontalAlignment(SwingConstants.LEFT);
1233 // Proxy type radio buttons
1234 noProxy.setFont(LABEL_FONT);
1235 noProxy.setHorizontalAlignment(SwingConstants.LEFT);
1236 noProxy.setText(MessageManager.getString("label.no_proxy"));
1237 systemProxy.setFont(LABEL_FONT);
1238 systemProxy.setHorizontalAlignment(SwingConstants.LEFT);
1239 systemProxy.setText(MessageManager.formatMessage("label.system_proxy",
1240 displayUserHostPort(Cache.startupProxyProperties[4],
1241 Cache.startupProxyProperties[0],
1242 Cache.startupProxyProperties[1]),
1243 displayUserHostPort(Cache.startupProxyProperties[6],
1244 Cache.startupProxyProperties[2],
1245 Cache.startupProxyProperties[3])));
1246 customProxy.setFont(LABEL_FONT);
1247 customProxy.setHorizontalAlignment(SwingConstants.LEFT);
1248 customProxy.setText(
1249 MessageManager.getString("label.use_proxy_server") + ":");
1250 ActionListener al = new ActionListener()
1253 public void actionPerformed(ActionEvent e)
1255 proxyType_actionPerformed();
1258 noProxy.addActionListener(al);
1259 systemProxy.addActionListener(al);
1260 customProxy.addActionListener(al);
1261 proxyType.add(noProxy);
1262 proxyType.add(systemProxy);
1263 proxyType.add(customProxy);
1265 proxyAuth.setFont(LABEL_FONT);
1266 proxyAuth.setHorizontalAlignment(SwingConstants.LEFT);
1267 proxyAuth.setText(MessageManager.getString("label.auth_required"));
1268 proxyAuth.addActionListener(new ActionListener()
1271 public void actionPerformed(ActionEvent e)
1273 proxyAuth_actionPerformed();
1277 setCustomProxyEnabled();
1279 // Make proxy server panel
1280 JPanel proxyPanel = new JPanel();
1281 TitledBorder titledBorder1 = new TitledBorder(
1282 MessageManager.getString("label.proxy_servers"));
1283 proxyPanel.setBorder(titledBorder1);
1284 proxyPanel.setLayout(new GridBagLayout());
1285 GridBagConstraints gbc = new GridBagConstraints();
1286 gbc.fill = GridBagConstraints.HORIZONTAL;
1289 GridBagConstraints c = new GridBagConstraints();
1290 // Proxy type radio buttons (3)
1291 JPanel ptPanel = new JPanel();
1292 ptPanel.setLayout(new GridBagLayout());
1297 c.fill = GridBagConstraints.HORIZONTAL;
1298 ptPanel.add(noProxy, c);
1300 ptPanel.add(systemProxy, c);
1302 ptPanel.add(customProxy, c);
1305 proxyPanel.add(ptPanel, gbc);
1307 // host and port text boxes
1308 JPanel hpPanel = new JPanel();
1309 hpPanel.setLayout(new GridBagLayout());
1310 // HTTP host port row
1315 c.anchor = GridBagConstraints.LINE_START;
1316 hpPanel.add(httpLabel, c);
1320 c.anchor = GridBagConstraints.LINE_END;
1321 hpPanel.add(serverLabel, c);
1325 c.anchor = GridBagConstraints.LINE_START;
1326 hpPanel.add(proxyServerHttpTB, c);
1330 c.anchor = GridBagConstraints.LINE_END;
1331 hpPanel.add(portLabel, c);
1335 c.anchor = GridBagConstraints.LINE_START;
1336 hpPanel.add(proxyPortHttpTB, c);
1338 // HTTPS host port row
1343 c.anchor = GridBagConstraints.LINE_START;
1344 hpPanel.add(httpsLabel, c);
1347 c.anchor = GridBagConstraints.LINE_END;
1348 hpPanel.add(serverLabel2, c);
1351 c.anchor = GridBagConstraints.LINE_START;
1352 hpPanel.add(proxyServerHttpsTB, c);
1355 c.anchor = GridBagConstraints.LINE_END;
1356 hpPanel.add(portLabel2, c);
1359 c.anchor = GridBagConstraints.LINE_START;
1360 hpPanel.add(proxyPortHttpsTB, c);
1363 proxyPanel.add(hpPanel, gbc);
1365 if (!Platform.isJS())
1367 * java.net.Authenticator is not implemented in SwingJS. Not displaying the
1368 * Authentication options in Preferences.
1374 // Require authentication checkbox
1376 proxyPanel.add(proxyAuth, gbc);
1378 // username and password
1379 JPanel upPanel = new JPanel();
1380 upPanel.setLayout(new GridBagLayout());
1386 c.anchor = GridBagConstraints.LINE_END;
1387 upPanel.add(proxyAuthUsernameLabel, c);
1391 c.anchor = GridBagConstraints.LINE_START;
1392 upPanel.add(proxyAuthUsernameTB, c);
1398 c.anchor = GridBagConstraints.LINE_END;
1399 upPanel.add(proxyAuthPasswordLabel, c);
1403 c.anchor = GridBagConstraints.LINE_START;
1404 upPanel.add(proxyAuthPasswordPB, c);
1408 c.anchor = GridBagConstraints.LINE_START;
1409 upPanel.add(passwordNotStoredLabel, c);
1412 proxyPanel.add(upPanel, gbc);
1416 applyProxyButton.setText(MessageManager.getString("action.apply"));
1417 applyProxyButton.addActionListener(new ActionListener()
1420 public void actionPerformed(ActionEvent e)
1422 saveProxySettings();
1423 applyProxyButton.setEnabled(false);
1427 gbc.fill = GridBagConstraints.NONE;
1428 gbc.anchor = GridBagConstraints.LINE_END;
1429 proxyPanel.add(applyProxyButton, gbc);
1434 public void proxyAuthPasswordCheckHighlight(boolean enabled)
1436 proxyAuthPasswordCheckHighlight(enabled, false);
1439 public void proxyAuthPasswordCheckHighlight(boolean enabled,
1442 if (enabled && proxyType.isSelected(customProxy.getModel())
1443 && proxyAuth.isSelected()
1444 && !proxyAuthUsernameTB.getText().isEmpty()
1445 && proxyAuthPasswordPB.getDocument().getLength() == 0)
1448 proxyAuthPasswordPB.grabFocus();
1449 proxyAuthPasswordPB.setBackground(Color.PINK);
1453 proxyAuthPasswordPB.setBackground(Color.WHITE);
1457 public void applyProxyButtonEnabled(boolean enabled)
1459 applyProxyButton.setEnabled(enabled);
1462 public void saveProxySettings()
1464 // overridden in Preferences
1467 private String displayUserHostPort(String user, String host, String port)
1469 boolean hostBlank = (host == null || host.isEmpty());
1470 boolean portBlank = (port == null || port.isEmpty());
1471 if (hostBlank && portBlank)
1473 return MessageManager.getString("label.none");
1476 StringBuilder sb = new StringBuilder();
1479 sb.append(user.isEmpty() || user.indexOf(" ") > -1 ? '"' + user + '"'
1483 sb.append(hostBlank ? "" : host);
1489 return sb.toString();
1493 * Initialises the checkboxes in the Connections tab
1495 private void initConnTabCheckboxes()
1497 // Usage stats checkbox label
1499 MessageManager.getString("label.send_usage_statistics"));
1500 usagestats.setFont(LABEL_FONT);
1501 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
1502 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
1504 // Questionnaire checkbox label
1505 questionnaire.setText(
1506 MessageManager.getString("label.check_for_questionnaires"));
1507 questionnaire.setFont(LABEL_FONT);
1508 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
1509 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
1511 // Check for latest version checkbox label
1512 versioncheck.setText(
1513 MessageManager.getString("label.check_for_latest_version"));
1514 versioncheck.setFont(LABEL_FONT);
1515 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
1516 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
1520 * Initialises the parent panel which contains the tabbed sections.
1524 private JPanel initOkCancelPanel()
1526 JButton ok = new JButton();
1527 ok.setText(MessageManager.getString("action.ok"));
1528 ok.addActionListener(new ActionListener()
1531 public void actionPerformed(ActionEvent e)
1533 ok_actionPerformed(e);
1536 JButton cancel = new JButton();
1537 cancel.setText(MessageManager.getString("action.cancel"));
1538 cancel.addActionListener(new ActionListener()
1541 public void actionPerformed(ActionEvent e)
1543 cancel_actionPerformed(e);
1546 JPanel okCancelPanel = new JPanel();
1547 okCancelPanel.add(ok);
1548 okCancelPanel.add(cancel);
1549 return okCancelPanel;
1553 * Initialises the Colours tabbed panel.
1557 private JPanel initColoursTab()
1559 JPanel coloursTab = new JPanel();
1560 coloursTab.setBorder(new TitledBorder(
1561 MessageManager.getString("action.open_new_alignment")));
1562 coloursTab.setLayout(new FlowLayout());
1563 JLabel mincolourLabel = new JLabel();
1564 mincolourLabel.setFont(LABEL_FONT);
1565 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1566 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
1567 minColour.setFont(LABEL_FONT);
1568 minColour.setBorder(BorderFactory.createEtchedBorder());
1569 minColour.setPreferredSize(new Dimension(40, 20));
1570 minColour.addMouseListener(new MouseAdapter()
1573 public void mousePressed(MouseEvent e)
1575 minColour_actionPerformed(minColour);
1578 JLabel maxcolourLabel = new JLabel();
1579 maxcolourLabel.setFont(LABEL_FONT);
1580 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1581 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
1582 maxColour.setFont(LABEL_FONT);
1583 maxColour.setBorder(BorderFactory.createEtchedBorder());
1584 maxColour.setPreferredSize(new Dimension(40, 20));
1585 maxColour.addMouseListener(new MouseAdapter()
1588 public void mousePressed(MouseEvent e)
1590 maxColour_actionPerformed(maxColour);
1594 protColour.setFont(LABEL_FONT);
1595 protColour.setBounds(new Rectangle(172, 225, 155, 21));
1596 JLabel protColourLabel = new JLabel();
1597 protColourLabel.setFont(LABEL_FONT);
1598 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1599 protColourLabel.setText(
1600 MessageManager.getString("label.prot_alignment_colour") + " ");
1601 GPreferences.addtoLayout(coloursTab,
1603 .getString("label.default_colour_scheme_for_alignment"),
1604 protColourLabel, protColour);
1606 nucColour.setFont(LABEL_FONT);
1607 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1608 JLabel nucColourLabel = new JLabel();
1609 nucColourLabel.setFont(LABEL_FONT);
1610 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1611 nucColourLabel.setText(
1612 MessageManager.getString("label.nuc_alignment_colour") + " ");
1613 GPreferences.addtoLayout(coloursTab,
1615 .getString("label.default_colour_scheme_for_alignment"),
1616 nucColourLabel, nucColour);
1618 JPanel annotationShding = new JPanel();
1619 annotationShding.setBorder(new TitledBorder(
1620 MessageManager.getString("label.annotation_shading_default")));
1621 annotationShding.setLayout(new GridLayout(1, 2));
1622 GPreferences.addtoLayout(annotationShding,
1623 MessageManager.getString(
1624 "label.default_minimum_colour_annotation_shading"),
1625 mincolourLabel, minColour);
1626 GPreferences.addtoLayout(annotationShding,
1627 MessageManager.getString(
1628 "label.default_maximum_colour_annotation_shading"),
1629 maxcolourLabel, maxColour);
1630 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1635 * Initialises the Overview tabbed panel.
1639 private JPanel initOverviewTab()
1641 JPanel overviewPanel = new JPanel();
1642 overviewPanel.setBorder(new TitledBorder(
1643 MessageManager.getString("label.overview_settings")));
1645 gapColour.setFont(LABEL_FONT);
1646 // fixing the border colours stops apparent colour bleed from the panel
1647 gapColour.setBorder(
1648 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1649 gapColour.setPreferredSize(new Dimension(40, 20));
1650 gapColour.addMouseListener(new MouseAdapter()
1653 public void mousePressed(MouseEvent e)
1655 gapColour_actionPerformed(gapColour);
1659 hiddenColour.setFont(LABEL_FONT);
1660 // fixing the border colours stops apparent colour bleed from the panel
1661 hiddenColour.setBorder(
1662 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1663 hiddenColour.setPreferredSize(new Dimension(40, 20));
1664 hiddenColour.addMouseListener(new MouseAdapter()
1667 public void mousePressed(MouseEvent e)
1669 hiddenColour_actionPerformed(hiddenColour);
1673 useLegacyGap = new JCheckBox(
1674 MessageManager.getString("label.ov_legacy_gap"));
1675 useLegacyGap.setFont(LABEL_FONT);
1676 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1677 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1678 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1679 gapLabel.setFont(LABEL_FONT);
1680 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1681 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1682 showHiddenAtStart = new JCheckBox(
1683 MessageManager.getString("label.ov_show_hide_default"));
1684 showHiddenAtStart.setFont(LABEL_FONT);
1685 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1686 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1687 JLabel hiddenLabel = new JLabel(
1688 MessageManager.getString("label.hidden_colour"));
1689 hiddenLabel.setFont(LABEL_FONT);
1690 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1691 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1693 useLegacyGap.addActionListener(new ActionListener()
1696 public void actionPerformed(ActionEvent e)
1698 useLegacyGaps_actionPerformed(e);
1702 overviewPanel.setLayout(new GridBagLayout());
1703 GridBagConstraints c1 = new GridBagConstraints();
1705 c1.fill = GridBagConstraints.HORIZONTAL;
1710 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1711 overviewPanel.add(useLegacyGap, c1);
1713 GridBagConstraints c2 = new GridBagConstraints();
1714 c2.fill = GridBagConstraints.HORIZONTAL;
1717 c2.insets = new Insets(0, 15, 0, 10);
1718 overviewPanel.add(gapLabel, c2);
1720 GridBagConstraints c3 = new GridBagConstraints();
1721 c3.fill = GridBagConstraints.HORIZONTAL;
1724 c3.insets = new Insets(0, 0, 0, 15);
1725 overviewPanel.add(gapColour, c3);
1727 GridBagConstraints c4 = new GridBagConstraints();
1728 c4.fill = GridBagConstraints.HORIZONTAL;
1732 overviewPanel.add(showHiddenAtStart, c4);
1734 GridBagConstraints c5 = new GridBagConstraints();
1735 c5.fill = GridBagConstraints.HORIZONTAL;
1738 c5.insets = new Insets(0, 15, 0, 10);
1739 overviewPanel.add(hiddenLabel, c5);
1741 GridBagConstraints c6 = new GridBagConstraints();
1742 c6.fill = GridBagConstraints.HORIZONTAL;
1745 c6.insets = new Insets(0, 0, 0, 15);
1746 overviewPanel.add(hiddenColour, c6);
1748 JButton resetButton = new JButton(
1749 MessageManager.getString("label.reset_to_defaults"));
1751 resetButton.addActionListener(new ActionListener()
1754 public void actionPerformed(ActionEvent e)
1756 resetOvDefaults_actionPerformed(e);
1760 GridBagConstraints c7 = new GridBagConstraints();
1761 c7.fill = GridBagConstraints.NONE;
1764 c7.insets = new Insets(10, 0, 0, 0);
1765 c7.anchor = GridBagConstraints.WEST;
1766 overviewPanel.add(resetButton, c7);
1768 // Add padding so the panel doesn't look ridiculous
1769 JPanel spacePanel = new JPanel();
1770 overviewPanel.add(spacePanel,
1771 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1772 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1773 new Insets(0, 0, 0, 5), 0, 0));
1775 return overviewPanel;
1779 * Initialises the Structure tabbed panel.
1783 private JPanel initStructureTab()
1785 structureTab = new JPanel();
1787 structureTab.setBorder(new TitledBorder(
1788 MessageManager.getString("label.structure_options")));
1789 structureTab.setLayout(null);
1790 final int width = 420;
1791 final int height = 22;
1792 final int lineSpacing = 25;
1795 structFromPdb.setFont(LABEL_FONT);
1797 .setText(MessageManager.getString("label.struct_from_pdb"));
1798 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1799 structFromPdb.addActionListener(new ActionListener()
1802 public void actionPerformed(ActionEvent e)
1804 boolean selected = structFromPdb.isSelected();
1805 // enable other options only when the first is checked
1806 addSecondaryStructure.setEnabled(selected);
1807 addTempFactor.setEnabled(selected);
1810 structureTab.add(structFromPdb);
1812 // indent checkboxes that are conditional on the first one
1813 ypos += lineSpacing;
1814 addSecondaryStructure.setFont(LABEL_FONT);
1815 addSecondaryStructure
1816 .setText(MessageManager.getString("label.autoadd_secstr"));
1817 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1818 structureTab.add(addSecondaryStructure);
1820 ypos += lineSpacing;
1821 addTempFactor.setFont(LABEL_FONT);
1822 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1823 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1824 structureTab.add(addTempFactor);
1826 ypos += lineSpacing;
1827 JLabel viewerLabel = new JLabel();
1828 viewerLabel.setFont(LABEL_FONT);
1829 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1830 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1831 viewerLabel.setBounds(new Rectangle(10, ypos, 220, height));
1832 structureTab.add(viewerLabel);
1835 * add all external viewers as options here - check
1836 * when selected whether the program is installed
1838 structViewer.setFont(LABEL_FONT);
1839 structViewer.setBounds(new Rectangle(190, ypos, 120, height));
1840 structViewer.addItem(ViewerType.JMOL.name());
1841 structViewer.addItem(ViewerType.CHIMERA.name());
1842 structViewer.addItem(ViewerType.CHIMERAX.name());
1843 structViewer.addItem(ViewerType.PYMOL.name());
1844 structViewer.addActionListener(new ActionListener()
1847 public void actionPerformed(ActionEvent e)
1849 structureViewer_actionPerformed(
1850 (String) structViewer.getSelectedItem());
1853 structureTab.add(structViewer);
1855 ypos += lineSpacing;
1856 structureViewerPathLabel = new JLabel();
1857 structureViewerPathLabel.setFont(LABEL_FONT);// new Font("SansSerif", 0,
1859 structureViewerPathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1860 structureViewerPathLabel.setText(MessageManager
1861 .formatMessage("label.viewer_path", "Chimera(X)"));
1862 structureViewerPathLabel
1863 .setBounds(new Rectangle(10, ypos, 170, height));
1864 structureViewerPathLabel.setEnabled(false);
1865 structureTab.add(structureViewerPathLabel);
1867 structureViewerPath.setFont(LABEL_FONT);
1868 structureViewerPath.setText("");
1869 structureViewerPath.setEnabled(false);
1870 final String tooltip = JvSwingUtils.wrapTooltip(true,
1871 MessageManager.getString("label.viewer_path_tip"));
1872 structureViewerPath.setToolTipText(tooltip);
1873 structureViewerPath.setBounds(new Rectangle(190, ypos, 290, height));
1874 structureViewerPath.addMouseListener(new MouseAdapter()
1877 public void mouseClicked(MouseEvent e)
1879 if (structureViewerPath.isEnabled() && e.getClickCount() == 2)
1881 String chosen = openFileChooser(false);
1884 structureViewerPath.setText(chosen);
1889 structureTab.add(structureViewerPath);
1891 ypos += lineSpacing;
1892 nwMapping.setFont(LABEL_FONT);
1893 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1894 siftsMapping.setFont(LABEL_FONT);
1895 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1896 mappingMethod.add(nwMapping);
1897 mappingMethod.add(siftsMapping);
1898 JPanel mappingPanel = new JPanel();
1899 mappingPanel.setFont(LABEL_FONT);
1900 TitledBorder mmTitledBorder = new TitledBorder(
1901 MessageManager.getString("label.mapping_method"));
1902 mmTitledBorder.setTitleFont(LABEL_FONT);
1903 mappingPanel.setBorder(mmTitledBorder);
1904 mappingPanel.setBounds(new Rectangle(10, ypos, 472, 45));
1905 // GridLayout mappingLayout = new GridLayout();
1906 mappingPanel.setLayout(new GridLayout());
1907 mappingPanel.add(nwMapping);
1908 mappingPanel.add(siftsMapping);
1909 structureTab.add(mappingPanel);
1911 ypos += lineSpacing;
1912 ypos += lineSpacing;
1913 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1914 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1915 docFieldPref.setBounds(new Rectangle(10, ypos, 470, 120));
1916 structureTab.add(docFieldPref);
1919 * hide Chimera options in JalviewJS
1921 if (Platform.isJS())
1923 structureViewerPathLabel.setVisible(false);
1924 structureViewerPath.setVisible(false);
1925 viewerLabel.setVisible(false);
1926 structViewer.setVisible(false);
1929 return structureTab;
1933 * Action on choosing a structure viewer from combobox options.
1935 * @param selectedItem
1937 protected void structureViewer_actionPerformed(String selectedItem)
1942 * Show a dialog for the user to choose a file. Returns the chosen path, or null
1947 protected String openFileChooser(boolean forFolder)
1949 String choice = null;
1950 JFileChooser chooser = new JFileChooser();
1952 // Enable appBundleIsTraversable in macOS FileChooser to allow selecting
1953 // hidden executables within .app dirs
1954 if (Platform.isMac())
1956 chooser.putClientProperty("JFileChooser.appBundleIsTraversable",
1962 chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
1964 // chooser.setFileView(new JalviewFileView());
1965 chooser.setDialogTitle(
1966 MessageManager.getString("label.open_local_file"));
1967 chooser.setToolTipText(MessageManager.getString("action.open"));
1969 int value = chooser.showOpenDialog(this);
1971 if (value == JFileChooser.APPROVE_OPTION)
1973 choice = chooser.getSelectedFile().getPath();
1979 * Validate the structure tab preferences; if invalid, set focus on this tab.
1983 protected boolean validateStructure(FocusEvent e)
1985 if (!validateStructure())
1987 e.getComponent().requestFocusInWindow();
1993 protected boolean validateStructure()
1999 * Initialises the Visual tabbed panel.
2003 private JPanel initVisualTab()
2005 JPanel visualTab = new JPanel();
2006 visualTab.setBorder(new TitledBorder(
2007 MessageManager.getString("action.open_new_alignment")));
2008 visualTab.setLayout(null);
2009 fullScreen.setFont(LABEL_FONT);
2010 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
2011 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
2012 fullScreen.setText(MessageManager.getString("label.maximize_window"));
2013 quality.setEnabled(false);
2014 quality.setFont(LABEL_FONT);
2015 quality.setHorizontalAlignment(SwingConstants.RIGHT);
2016 quality.setHorizontalTextPosition(SwingConstants.LEFT);
2017 quality.setSelected(true);
2018 quality.setText(MessageManager.getString("label.quality"));
2019 conservation.setEnabled(false);
2020 conservation.setFont(LABEL_FONT);
2021 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
2022 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
2023 conservation.setSelected(true);
2024 conservation.setText(MessageManager.getString("label.conservation"));
2025 identity.setEnabled(false);
2026 identity.setFont(LABEL_FONT);
2027 identity.setHorizontalAlignment(SwingConstants.RIGHT);
2028 identity.setHorizontalTextPosition(SwingConstants.LEFT);
2029 identity.setSelected(true);
2030 identity.setText(MessageManager.getString("label.consensus"));
2031 showOccupancy.setFont(LABEL_FONT);
2032 showOccupancy.setEnabled(false);
2033 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
2034 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
2035 showOccupancy.setSelected(true);
2036 showOccupancy.setText(MessageManager.getString("label.occupancy"));
2038 JLabel showGroupbits = new JLabel();
2039 showGroupbits.setFont(LABEL_FONT);
2040 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
2041 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
2043 .setText(MessageManager.getString("action.show_group") + ":");
2044 JLabel showConsensbits = new JLabel();
2045 showConsensbits.setFont(LABEL_FONT);
2046 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
2047 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
2049 .setText(MessageManager.getString("label.consensus") + ":");
2050 showConsensHistogram.setEnabled(false);
2051 showConsensHistogram.setFont(LABEL_FONT);
2052 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
2053 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
2054 showConsensHistogram.setSelected(true);
2055 showConsensHistogram
2056 .setText(MessageManager.getString("label.histogram"));
2057 showConsensLogo.setEnabled(false);
2058 showConsensLogo.setFont(LABEL_FONT);
2059 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
2060 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
2061 showConsensLogo.setSelected(true);
2062 showConsensLogo.setText(MessageManager.getString("label.logo"));
2063 showGroupConsensus.setEnabled(false);
2064 showGroupConsensus.setFont(LABEL_FONT);
2065 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
2066 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
2067 showGroupConsensus.setSelected(true);
2068 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
2069 showGroupConservation.setEnabled(false);
2070 showGroupConservation.setFont(LABEL_FONT);
2071 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
2072 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
2073 showGroupConservation.setSelected(true);
2074 showGroupConservation
2075 .setText(MessageManager.getString("label.conservation"));
2076 showNpTooltip.setEnabled(true);
2077 showNpTooltip.setFont(LABEL_FONT);
2078 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
2079 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
2080 showNpTooltip.setSelected(true);
2081 showNpTooltip.setText(
2082 MessageManager.getString("label.non_positional_features"));
2083 showDbRefTooltip.setEnabled(true);
2084 showDbRefTooltip.setFont(LABEL_FONT);
2085 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
2086 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
2087 showDbRefTooltip.setSelected(true);
2089 .setText(MessageManager.getString("label.database_references"));
2090 annotations.setFont(LABEL_FONT);
2091 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
2092 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
2093 annotations.setSelected(true);
2094 annotations.setText(MessageManager.getString("label.show_annotations"));
2095 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
2096 annotations.addActionListener(new ActionListener()
2099 public void actionPerformed(ActionEvent e)
2101 annotations_actionPerformed(e);
2104 identity.addActionListener(new ActionListener()
2107 public void actionPerformed(ActionEvent e)
2109 annotations_actionPerformed(e);
2112 showGroupConsensus.addActionListener(new ActionListener()
2115 public void actionPerformed(ActionEvent e)
2117 annotations_actionPerformed(e);
2120 showUnconserved.setFont(LABEL_FONT);
2121 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
2122 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
2123 showUnconserved.setSelected(true);
2125 .setText(MessageManager.getString("action.show_unconserved"));
2126 showUnconserved.addActionListener(new ActionListener()
2129 public void actionPerformed(ActionEvent e)
2131 showunconserved_actionPerformed(e);
2135 // TODO these are not yet added to / action from Preferences
2136 // JCheckBox shareSelections = new JCheckBox();
2137 // shareSelections.setFont(verdana11);
2138 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
2139 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
2140 // shareSelections.setSelected(true);
2141 // shareSelections.setText(MessageManager
2142 // .getString("label.share_selection_across_views"));
2143 // JCheckBox followHighlight = new JCheckBox();
2144 // followHighlight.setFont(verdana11);
2145 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
2146 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
2147 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
2148 // followHighlight.setSelected(true);
2149 // followHighlight.setText(MessageManager
2150 // .getString("label.scroll_highlighted_regions"));
2152 seqLimit.setFont(LABEL_FONT);
2153 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
2154 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
2155 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
2156 smoothFont.setFont(LABEL_FONT);
2157 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
2158 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
2159 smoothFont.setText(MessageManager.getString("label.smooth_font"));
2160 scaleProteinToCdna.setFont(LABEL_FONT);
2161 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
2162 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
2163 scaleProteinToCdna.setText(
2164 MessageManager.getString("label.scale_protein_to_cdna"));
2165 scaleProteinToCdna.setToolTipText(
2166 MessageManager.getString("label.scale_protein_to_cdna_tip"));
2167 JLabel gapLabel = new JLabel();
2168 gapLabel.setFont(LABEL_FONT);
2169 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2170 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
2171 JLabel fontLabel = new JLabel();
2172 fontLabel.setFont(LABEL_FONT);
2173 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2174 fontLabel.setText(MessageManager.getString("label.font"));
2175 fontSizeCB.setFont(LABEL_FONT);
2176 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
2177 fontStyleCB.setFont(LABEL_FONT);
2178 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
2179 fontNameCB.setFont(LABEL_FONT);
2180 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
2181 gapSymbolCB.setFont(LABEL_FONT);
2182 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
2183 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
2184 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
2185 gapSymbolCB.setRenderer(dlcr);
2187 startupCheckbox.setText(MessageManager.getString("action.open_file"));
2188 startupCheckbox.setFont(LABEL_FONT);
2189 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
2190 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
2191 startupCheckbox.setSelected(true);
2192 startupFileTextfield.setFont(LABEL_FONT);
2193 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
2194 final String tooltip = JvSwingUtils.wrapTooltip(true,
2195 MessageManager.getString("label.double_click_to_browse"));
2196 startupFileTextfield.setToolTipText(tooltip);
2197 startupFileTextfield.addMouseListener(new MouseAdapter()
2200 public void mouseClicked(MouseEvent e)
2202 if (e.getClickCount() > 1)
2204 startupFileTextfield_mouseClicked();
2209 sortby.setFont(LABEL_FONT);
2210 sortby.setBounds(new Rectangle(172, 260, 155, 21));
2211 JLabel sortLabel = new JLabel();
2212 sortLabel.setFont(LABEL_FONT);
2213 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2214 sortLabel.setText(MessageManager.getString("label.sort_by"));
2215 sortAnnBy.setFont(LABEL_FONT);
2216 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
2217 JLabel sortAnnLabel = new JLabel();
2218 sortAnnLabel.setFont(LABEL_FONT);
2219 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
2220 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
2221 sortAutocalc.setFont(LABEL_FONT);
2222 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
2224 JPanel annsettingsPanel = new JPanel();
2225 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
2226 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
2227 annsettingsPanel.setBorder(new EtchedBorder());
2228 visualTab.add(annsettingsPanel);
2229 Border jb = new EmptyBorder(1, 1, 4, 5);
2230 annotations.setBorder(jb);
2231 showOccupancy.setBorder(jb);
2232 quality.setBorder(jb);
2233 conservation.setBorder(jb);
2234 identity.setBorder(jb);
2235 showConsensbits.setBorder(jb);
2236 showGroupbits.setBorder(jb);
2237 showGroupConsensus.setBorder(jb);
2238 showGroupConservation.setBorder(jb);
2239 showConsensHistogram.setBorder(jb);
2240 showConsensLogo.setBorder(jb);
2242 JPanel autoAnnotSettings = new JPanel();
2243 annsettingsPanel.add(autoAnnotSettings);
2244 autoAnnotSettings.setLayout(new GridLayout(0, 2));
2245 autoAnnotSettings.add(annotations);
2246 autoAnnotSettings.add(quality);
2247 // second row of autoannotation box
2248 autoAnnotSettings = new JPanel();
2249 annsettingsPanel.add(autoAnnotSettings);
2251 autoAnnotSettings.setLayout(new GridLayout(0, 3));
2252 autoAnnotSettings.add(conservation);
2253 autoAnnotSettings.add(identity);
2254 autoAnnotSettings.add(showOccupancy);
2255 autoAnnotSettings.add(showGroupbits);
2256 autoAnnotSettings.add(showGroupConservation);
2257 autoAnnotSettings.add(showGroupConsensus);
2258 autoAnnotSettings.add(showConsensbits);
2259 autoAnnotSettings.add(showConsensHistogram);
2260 autoAnnotSettings.add(showConsensLogo);
2262 JPanel tooltipSettings = new JPanel();
2263 tooltipSettings.setBorder(new TitledBorder(
2264 MessageManager.getString("label.sequence_id_tooltip")));
2265 tooltipSettings.setBounds(173, 140, 220, 62);
2266 tooltipSettings.setLayout(new GridLayout(2, 1));
2267 tooltipSettings.add(showDbRefTooltip);
2268 tooltipSettings.add(showNpTooltip);
2269 visualTab.add(tooltipSettings);
2271 wrap.setFont(LABEL_FONT);
2272 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
2273 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
2274 wrap.setText(MessageManager.getString("label.wrap_alignment"));
2275 rightAlign.setFont(LABEL_FONT);
2276 rightAlign.setForeground(Color.black);
2277 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
2278 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
2279 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
2280 idItalics.setFont(LABEL_FONT_ITALIC);
2281 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
2282 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
2284 MessageManager.getString("label.sequence_name_italics"));
2285 openoverv.setFont(LABEL_FONT);
2286 openoverv.setActionCommand(
2287 MessageManager.getString("label.open_overview"));
2288 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
2289 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
2290 openoverv.setText(MessageManager.getString("label.open_overview"));
2291 JPanel jPanel2 = new JPanel();
2292 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
2293 jPanel2.setLayout(new GridLayout(14, 1));
2294 jPanel2.add(fullScreen);
2295 jPanel2.add(openoverv);
2296 jPanel2.add(seqLimit);
2297 jPanel2.add(rightAlign);
2298 jPanel2.add(fontLabel);
2299 jPanel2.add(showUnconserved);
2300 jPanel2.add(idItalics);
2301 jPanel2.add(smoothFont);
2302 jPanel2.add(scaleProteinToCdna);
2303 jPanel2.add(gapLabel);
2305 jPanel2.add(sortLabel);
2306 jPanel2.add(sortAnnLabel);
2307 jPanel2.add(startupCheckbox);
2308 visualTab.add(jPanel2);
2309 visualTab.add(startupFileTextfield);
2310 visualTab.add(sortby);
2311 visualTab.add(sortAnnBy);
2312 visualTab.add(sortAutocalc);
2313 visualTab.add(gapSymbolCB);
2314 visualTab.add(fontNameCB);
2315 visualTab.add(fontSizeCB);
2316 visualTab.add(fontStyleCB);
2319 if (Platform.isJS())
2321 startupCheckbox.setVisible(false);
2322 startupFileTextfield.setVisible(false);
2330 * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
2333 protected void loadLastSavedBackupsOptions()
2335 BackupFilesPresetEntry savedPreset = BackupFilesPresetEntry
2336 .getSavedBackupEntry();
2338 .setSelected(Cache.getDefault(BackupFiles.ENABLED, !Platform.isJS()));
2340 BackupFilesPresetEntry backupfilesCustomEntry = BackupFilesPresetEntry
2341 .createBackupFilesPresetEntry(Cache
2342 .getDefault(BackupFilesPresetEntry.CUSTOMCONFIG, null));
2343 if (backupfilesCustomEntry == null)
2345 backupfilesCustomEntry = BackupFilesPresetEntry.backupfilesPresetEntriesValues
2346 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT);
2348 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
2349 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM,
2350 backupfilesCustomEntry);
2352 setComboIntStringKey(backupfilesPresetsCombo,
2353 Cache.getDefault(BackupFiles.NS + "_PRESET",
2354 BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT));
2356 backupsSetOptions(savedPreset);
2358 backupsOptionsSetEnabled();
2359 updateBackupFilesExampleLabel();
2363 * Load the saved Memory settings
2365 protected void loadLastSavedMemorySettings()
2367 customiseMemorySetting.setSelected(
2368 Cache.getDefault(MemorySetting.CUSTOMISED_SETTINGS, false));
2369 jvmMemoryPercentSlider
2370 .setValue(Cache.getDefault(MemorySetting.MEMORY_JVMMEMPC, 90));
2371 jvmMemoryMaxTextField.setText(
2372 Cache.getDefault(MemorySetting.MEMORY_JVMMEMMAX, "32g"));
2374 private boolean warnAboutSuffixReverseChange()
2376 BackupFilesPresetEntry bfpe = BackupFilesPresetEntry
2377 .getSavedBackupEntry();
2378 boolean savedSuffixReverse = bfpe.reverse;
2379 int savedSuffixDigits = bfpe.digits;
2380 String savedSuffixTemplate = bfpe.suffix;
2382 boolean nowSuffixReverse = suffixReverse.isSelected();
2383 int nowSuffixDigits = getSpinnerInt(suffixDigitsSpinner, 3);
2384 String nowSuffixTemplate = suffixTemplate.getText();
2385 return nowSuffixReverse != savedSuffixReverse
2386 && nowSuffixDigits == savedSuffixDigits
2387 && nowSuffixTemplate != null
2388 && nowSuffixTemplate.equals(savedSuffixTemplate);
2391 /* Initialises the Startup tabbed panel.
2396 private JPanel initStartupTab()
2398 JPanel startupTab = new JPanel();
2399 startupTab.setBorder(
2400 new TitledBorder(MessageManager.getString("label.memory")));
2401 startupTab.setLayout(new GridBagLayout());
2403 GridBagConstraints gbc = new GridBagConstraints();
2406 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2407 gbc.fill = GridBagConstraints.NONE;
2414 gbc.gridy = 0; // row 1
2416 JLabel memoryText = new JLabel();
2417 memoryText.setFont(LABEL_FONT_ITALIC);
2419 .setText(MessageManager.getString("label.memory_setting_text"));
2420 startupTab.add(memoryText, gbc);
2422 gbc.gridy++; // row 2
2424 JPanel exampleMemoryPanel = new JPanel();
2426 .setLayout(new BoxLayout(exampleMemoryPanel, BoxLayout.Y_AXIS));
2427 exampleMemoryPanel.setToolTipText(JvSwingUtils.wrapTooltip(true,
2428 MessageManager.getString("label.memory_example_tooltip")));
2429 JLabel exampleTextLabel = new JLabel();
2431 .setText(MessageManager.getString("label.memory_example_text"));
2432 exampleTextLabel.setForeground(Color.GRAY);
2433 exampleTextLabel.setFont(LABEL_FONT);
2434 exampleMemoryPanel.add(exampleTextLabel);
2435 exampleMemoryPanel.add(exampleMemoryLabel);
2436 exampleMemoryPanel.setBackground(Color.WHITE);
2437 exampleMemoryPanel.setBorder(BorderFactory.createEtchedBorder());
2438 startupTab.add(exampleMemoryPanel, gbc);
2440 gbc.gridy++; // row 3
2442 startupTab.add(customiseMemorySetting, gbc);
2444 gbc.gridy += 2; // row 4 with a gap
2446 startupTab.add(maxMemoryLabel, gbc);
2448 gbc.gridy += 2; // row 5
2451 startupTab.add(jvmMemoryPercentLabel, gbc);
2453 startupTab.add(jvmMemoryPercentSlider, gbc);
2455 // gbc.weightx = 0.1;
2456 startupTab.add(jvmMemoryPercentDisplay, gbc);
2457 // gbc.weightx = 1.0;
2460 gbc.gridy++; // row 6
2462 startupTab.add(jvmMemoryMaxLabel, gbc);
2464 startupTab.add(jvmMemoryMaxTextField, gbc);
2466 gbc.gridy++; // row 7
2469 exampleMemoryMessageTextArea.setBackground(startupTab.getBackground());
2470 JScrollPane sp = new JScrollPane(exampleMemoryMessageTextArea);
2471 sp.setBorder(BorderFactory.createEmptyBorder());
2472 sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
2473 sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
2474 startupTab.add(sp, gbc);
2476 // fill empty space to push widget to top left
2482 startupTab.add(new JPanel(), gbc);
2484 setMemoryPercentDisplay();
2485 memoryOptionsSetEnabled();
2489 private void initMemoryPanel()
2491 // Enable memory settings checkbox
2492 customiseMemorySetting.setFont(LABEL_FONT_BOLD);
2493 customiseMemorySetting.setText(
2494 MessageManager.getString("label.customise_memory_settings"));
2495 customiseMemorySetting.addActionListener(new ActionListener()
2498 public void actionPerformed(ActionEvent e)
2500 memoryOptionsSetEnabled();
2504 loadLastSavedMemorySettings();
2506 exampleMemoryLabel.setFont(LABEL_FONT_BOLD);
2507 exampleMemoryLabel.setBackground(Color.WHITE);
2509 maxMemoryLabel = new JLabel(
2510 MessageManager.getString("label.maximum_memory_used"));
2511 maxMemoryLabel.setFont(LABEL_FONT_BOLD);
2513 // Maximum memory percentage slider
2514 jvmMemoryPercentLabel.setFont(LABEL_FONT);
2515 jvmMemoryPercentLabel.setText(
2516 MessageManager.getString("label.percent_of_physical_memory"));
2517 jvmMemoryPercentSlider.setPaintLabels(true);
2518 jvmMemoryPercentSlider.setPaintTicks(true);
2519 jvmMemoryPercentSlider.setPaintTrack(true);
2520 jvmMemoryPercentSlider.setMajorTickSpacing(50);
2521 jvmMemoryPercentSlider.setMinorTickSpacing(10);
2522 jvmMemoryPercentSlider.addChangeListener(new ChangeListener()
2525 public void stateChanged(ChangeEvent e)
2527 setMemoryPercentDisplay();
2530 jvmMemoryPercentDisplay.setFont(LABEL_FONT);
2531 setMemoryPercentDisplay();
2533 // Maximum memory cap textbox
2534 jvmMemoryMaxLabel.setFont(LABEL_FONT);
2536 .setText(MessageManager.getString("label.maximum_memory"));
2537 initMemoryMaxTextField();
2539 exampleMemoryMessageTextArea.setFont(LABEL_FONT_ITALIC);
2540 exampleMemoryMessageTextArea.setForeground(Color.GRAY);
2541 exampleMemoryMessageTextArea.setEditable(false);
2542 exampleMemoryMessageTextArea.setLineWrap(true);
2543 exampleMemoryMessageTextArea.setWrapStyleWord(true);
2544 exampleMemoryMessageTextArea.setText(" ");
2545 exampleMemoryMessageTextArea.setRows(2);
2546 exampleMemoryMessageTextArea.setColumns(40);
2548 setExampleMemoryLabel();
2551 private void initMemoryMaxTextField()
2553 jvmMemoryMaxTextField.setToolTipText(
2554 MessageManager.getString("label.maximum_memory_tooltip"));
2555 jvmMemoryMaxTextField.addActionListener(new ActionListener()
2558 public void actionPerformed(ActionEvent arg0)
2560 validateMemoryMaxTextField();
2561 setExampleMemoryLabel();
2565 jvmMemoryMaxTextField.addKeyListener(new KeyListener()
2568 public void keyReleased(KeyEvent e)
2570 validateMemoryMaxTextField();
2571 setExampleMemoryLabel();
2575 public void keyPressed(KeyEvent e)
2579 // try and stop invalid typing
2581 public void keyTyped(KeyEvent e)
2583 char c = Character.toLowerCase(e.getKeyChar());
2584 String text = jvmMemoryMaxTextField.getText();
2585 String suffixes = "tgmkb";
2586 int pos = jvmMemoryMaxTextField.getCaretPosition();
2587 int suffixPos = StringUtils.firstCharPosIgnoreCase(text, suffixes);
2588 if (!((('0' <= c && c <= '9')
2589 && (suffixPos == -1 || pos <= suffixPos)) // digits only allowed
2591 || (suffixes.indexOf(Character.toLowerCase(c)) >= 0 // valid
2593 && pos == text.length() // at end of text and
2594 && suffixPos == -1) // there isn't already one
2604 private boolean isMemoryMaxTextFieldValid()
2606 return MemorySetting
2607 .isValidMemoryString(jvmMemoryMaxTextField.getText());
2610 private void validateMemoryMaxTextField()
2612 if (isMemoryMaxTextFieldValid())
2614 jvmMemoryMaxTextField.setBackground(Color.WHITE);
2618 jvmMemoryMaxTextField.setBackground(Color.PINK);
2622 private void setMemoryPercentDisplay()
2624 jvmMemoryPercentDisplay
2625 .setText(jvmMemoryPercentSlider.getValue() + "%");
2626 setExampleMemoryLabel();
2629 private void setExampleMemoryLabel()
2631 boolean selected = customiseMemorySetting.isSelected();
2632 int jvmmempc = jvmMemoryPercentSlider.getValue();
2633 String jvmmemmax = jvmMemoryMaxTextField.getText();
2636 if (selected && (0 <= jvmmempc && jvmmempc <= 100)
2637 && MemorySetting.isValidMemoryString(jvmmemmax))
2639 mem = MemorySetting.getMemorySetting(jvmmemmax,
2640 String.valueOf(jvmmempc), false, true);
2644 mem = MemorySetting.getMemorySetting(null, null, false, true);
2646 exampleMemoryLabel.setText(MemorySetting.memoryLongToString(mem));
2647 String message = MemorySetting.getAdjustmentMessage();
2648 exampleMemoryMessageTextArea.setText(
2649 MessageManager.getString("label.adjustments_for_this_computer")
2652 ? MessageManager.getString("label.none")
2656 private void memoryOptionsSetEnabled()
2658 boolean enabled = customiseMemorySetting.isSelected();
2659 // leave exampleMemoryLabel enabled always
2660 maxMemoryLabel.setEnabled(enabled);
2661 jvmMemoryPercentLabel.setEnabled(enabled);
2662 jvmMemoryPercentSlider.setEnabled(enabled);
2663 jvmMemoryPercentDisplay.setEnabled(enabled);
2664 jvmMemoryMaxLabel.setEnabled(enabled);
2665 jvmMemoryMaxTextField.setEnabled(enabled);
2666 exampleMemoryMessageTextArea.setEnabled(enabled);
2667 setExampleMemoryLabel();
2671 * Initialises the Backups tabbed panel.
2675 private JPanel initBackupsTab()
2677 JPanel backupsTab = new JPanel();
2678 backupsTab.setBorder(new TitledBorder(
2679 MessageManager.getString("label.backup_files")));
2680 backupsTab.setLayout(new GridBagLayout());
2682 GridBagConstraints gbc = new GridBagConstraints();
2685 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2686 gbc.fill = GridBagConstraints.NONE;
2688 initBackupsTabPresetsPanel();
2689 initBackupsTabSuffixPanel();
2690 initBackupsTabKeepFilesPanel();
2691 initBackupsTabFilenameExamplesPanel();
2693 enableBackupFiles.setFont(LABEL_FONT_BOLD);
2695 .setText(MessageManager.getString("label.enable_backupfiles"));
2696 enableBackupFiles.addActionListener(new ActionListener()
2699 public void actionPerformed(ActionEvent e)
2701 // enable other options only when the first is checked
2702 backupsOptionsSetEnabled();
2706 // enable checkbox 1 col
2710 gbc.gridy = 0; // row 0
2711 backupsTab.add(enableBackupFiles, gbc);
2713 // summary of scheme box (over two rows)
2717 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
2718 gbc.fill = GridBagConstraints.BOTH;
2719 backupsTab.add(exampleFilesPanel, gbc);
2721 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2722 gbc.fill = GridBagConstraints.NONE;
2724 // fill empty space on right
2727 backupsTab.add(new JPanel(), gbc);
2732 gbc.gridy++; // row 1
2733 backupsTab.add(presetsPanel, gbc);
2735 // now using whole row
2740 gbc.gridy++; // row 2
2741 backupsTab.add(keepfilesPanel, gbc);
2743 // filename strategy box
2744 gbc.gridy++; // row 3
2745 backupsTab.add(suffixPanel, gbc);
2748 gbc.gridy++; // row 4
2750 backupsTab.add(new JPanel(), gbc);
2752 backupsOptionsSetEnabled();
2756 private JPanel initBackupsTabPresetsPanel()
2759 String title = MessageManager.getString("label.schemes");
2761 presetsPanel.setLayout(new GridBagLayout());
2763 GridBagConstraints gbc = new GridBagConstraints();
2766 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
2767 gbc.fill = GridBagConstraints.NONE;
2775 presetsComboLabel = new JLabel(title + ":");
2776 presetsPanel.add(presetsComboLabel, gbc);
2778 List<Object> entries = Arrays
2779 .asList((Object[]) BackupFilesPresetEntry.backupfilesPresetEntries);
2780 List<String> tooltips = Arrays.asList(
2781 BackupFilesPresetEntry.backupfilesPresetEntryDescriptions);
2782 backupfilesPresetsCombo = JvSwingUtils.buildComboWithTooltips(entries,
2785 for (int i = 0; i < BackupFilesPresetEntry.backupfilesPresetEntries.length; i++)
2787 backupfilesPresetsCombo
2788 .addItem(BackupFilesPresetEntry.backupfilesPresetEntries[i]);
2792 backupfilesPresetsCombo.addActionListener(new ActionListener()
2795 public void actionPerformed(ActionEvent e)
2797 int key = getComboIntStringKey(backupfilesPresetsCombo);
2798 if (!customiseCheckbox.isSelected())
2800 backupfilesPresetsComboLastSelected = key;
2802 if (key == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
2804 if (customiseCheckbox.isSelected())
2806 // got here by clicking on customiseCheckbox so don't change the values
2807 backupfilesCustomOptionsSetEnabled();
2811 backupsTabUpdatePresets();
2812 backupfilesCustomOptionsSetEnabled();
2817 customiseCheckbox.setSelected(false);
2818 backupsTabUpdatePresets();
2819 backupfilesCustomOptionsSetEnabled();
2824 // dropdown list of preset schemes
2826 presetsPanel.add(backupfilesPresetsCombo, gbc);
2828 revertButton.setText(MessageManager.getString("label.cancel_changes"));
2829 revertButton.setToolTipText(
2830 MessageManager.getString("label.cancel_changes_description"));
2831 revertButton.addActionListener(new ActionListener()
2834 public void actionPerformed(ActionEvent e)
2837 BackupFilesPresetEntry.backupfilesPresetEntriesValues.get(
2838 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM));
2839 backupfilesCustomOptionsSetEnabled();
2843 revertButton.setFont(LABEL_FONT);
2845 customiseCheckbox.setFont(LABEL_FONT);
2846 customiseCheckbox.setText(MessageManager.getString("label.customise"));
2847 customiseCheckbox.addActionListener(new ActionListener()
2850 public void actionPerformed(ActionEvent e)
2852 int currently = getComboIntStringKey(backupfilesPresetsCombo);
2853 if (customiseCheckbox.isSelected())
2855 backupfilesPresetsComboLastSelected = currently;
2856 setComboIntStringKey(backupfilesPresetsCombo,
2857 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2861 setComboIntStringKey(backupfilesPresetsCombo,
2862 backupfilesPresetsComboLastSelected);
2865 backupfilesCustomOptionsSetEnabled();
2868 customiseCheckbox.setToolTipText(
2869 MessageManager.getString("label.customise_description"));
2871 // customise checkbox
2874 presetsPanel.add(customiseCheckbox, gbc);
2876 // "Cancel changes" button (aligned with combo box above)
2878 presetsPanel.add(revertButton, gbc);
2880 return presetsPanel;
2883 private JPanel initBackupsTabFilenameExamplesPanel()
2885 String title = MessageManager
2886 .getString("label.scheme_examples");
2887 TitledBorder tb = new TitledBorder(title);
2888 exampleFilesPanel.setBorder(tb);
2889 exampleFilesPanel.setLayout(new GridBagLayout());
2891 backupfilesExampleLabel.setEditable(false);
2892 backupfilesExampleLabel
2893 .setBackground(exampleFilesPanel.getBackground());
2895 updateBackupFilesExampleLabel();
2897 GridBagConstraints gbc = new GridBagConstraints();
2900 gbc.fill = GridBagConstraints.NONE;
2901 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2903 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
2904 return exampleFilesPanel;
2907 private void backupsTabUpdatePresets()
2909 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
2912 String value = entry.v;
2914 if (BackupFilesPresetEntry.backupfilesPresetEntriesValues
2918 BackupFilesPresetEntry.backupfilesPresetEntriesValues
2924 "Preset '" + value + "' [key:" + key + "] not implemented");
2927 // Custom options will now be enabled when the customiseCheckbox is checked
2928 // (performed above)
2929 // backupfilesCustomOptionsSetEnabled();
2930 updateBackupFilesExampleLabel();
2933 protected int getComboIntStringKey(
2934 JComboBox<Object> backupfilesPresetsCombo2)
2936 IntKeyStringValueEntry e;
2939 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2
2941 } catch (Exception ex)
2944 "Problem casting Combo entry to IntKeyStringValueEntry.");
2947 return e != null ? e.k : 0;
2950 protected void setComboIntStringKey(
2951 JComboBox<Object> backupfilesPresetsCombo2,
2954 for (int i = 0; i < backupfilesPresetsCombo2.getItemCount(); i++)
2956 IntKeyStringValueEntry e;
2959 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2.getItemAt(i);
2960 } catch (Exception ex)
2963 "Problem casting Combo entry to IntKeyStringValueEntry. Skipping item. ");
2968 backupfilesPresetsCombo2.setSelectedIndex(i);
2972 // backupsTabUpdatePresets();
2975 private JPanel initBackupsTabSuffixPanel()
2977 suffixPanel.setBorder(new TitledBorder(
2978 MessageManager.getString("label.backup_filename_strategy")));
2979 suffixPanel.setLayout(new GridBagLayout());
2982 .setText(MessageManager.getString("label.append_to_filename"));
2983 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
2984 suffixTemplateLabel.setFont(LABEL_FONT);
2986 final String tooltip = JvSwingUtils.wrapTooltip(true,
2987 MessageManager.getString("label.append_to_filename_tooltip"));
2988 suffixTemplate.setToolTipText(tooltip);
2989 suffixTemplate.addActionListener(new ActionListener()
2992 public void actionPerformed(ActionEvent e)
2994 updateBackupFilesExampleLabel();
2995 backupfilesCustomOptionsSetEnabled();
2996 backupfilesRevertButtonSetEnabled(true);
3000 suffixTemplate.addKeyListener(new KeyListener()
3003 public void keyReleased(KeyEvent e)
3005 updateBackupFilesExampleLabel();
3006 backupfilesCustomOptionsSetEnabled();
3007 backupfilesRevertButtonSetEnabled(true);
3011 public void keyPressed(KeyEvent e)
3015 // disable use of ':' or '/' or '\'
3017 public void keyTyped(KeyEvent e)
3019 char c = e.getKeyChar();
3020 if (c == ':' || c == '/' || c == '\\')
3022 // don't process ':' or '/' or '\'
3031 .setText(MessageManager.getString("label.index_digits"));
3032 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
3033 suffixDigitsLabel.setFont(LABEL_FONT);
3034 ChangeListener c = new ChangeListener()
3037 public void stateChanged(ChangeEvent e)
3039 backupfilesRevertButtonSetEnabled(true);
3040 updateBackupFilesExampleLabel();
3044 setIntegerSpinner(suffixDigitsSpinner, BackupFilesPresetEntry.DIGITSMIN,
3045 BackupFilesPresetEntry.DIGITSMAX, 3, c);
3047 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
3048 MessageManager.getString("label.increment_index"));
3049 suffixReverse.addActionListener(new ActionListener()
3052 public void actionPerformed(ActionEvent e)
3054 boolean okay = true;
3055 if (warnAboutSuffixReverseChange())
3058 okay = confirmSuffixReverseChange();
3062 backupfilesRevertButtonSetEnabled(true);
3063 updateBackupFilesExampleLabel();
3067 boolean savedSuffixReverse = BackupFilesPresetEntry
3068 .getSavedBackupEntry().reverse;
3069 suffixReverse.setSelected(savedSuffixReverse);
3074 GridBagConstraints sgbc = new GridBagConstraints();
3076 // first row (template text box)
3077 sgbc.anchor = GridBagConstraints.WEST;
3081 sgbc.gridheight = 1;
3084 sgbc.fill = GridBagConstraints.NONE;
3085 suffixPanel.add(suffixTemplateLabel, sgbc);
3088 sgbc.fill = GridBagConstraints.HORIZONTAL;
3089 suffixPanel.add(suffixTemplate, sgbc);
3091 // second row (number of digits spinner)
3095 sgbc.fill = GridBagConstraints.NONE;
3096 suffixPanel.add(suffixDigitsLabel, sgbc);
3099 sgbc.fill = GridBagConstraints.HORIZONTAL;
3100 suffixPanel.add(suffixDigitsSpinner, sgbc);
3102 // third row (forward order radio selection)
3105 sgbc.gridwidth = GridBagConstraints.REMAINDER;
3106 sgbc.fill = GridBagConstraints.HORIZONTAL;
3107 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
3109 // fourth row (reverse order radio selection)
3111 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
3115 private boolean confirmSuffixReverseChange()
3117 boolean ret = false;
3118 String warningMessage = MessageManager
3119 .getString("label.warning_confirm_change_reverse");
3120 int confirm = JvOptionPane.showConfirmDialog(Desktop.getDesktopPane(),
3122 MessageManager.getString("label.change_increment_decrement"),
3123 JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE);
3125 ret = (confirm == JvOptionPane.YES_OPTION);
3129 private JPanel initBackupsTabKeepFilesPanel()
3131 keepfilesPanel.setBorder(
3132 new TitledBorder(MessageManager.getString("label.keep_files")));
3133 keepfilesPanel.setLayout(new GridBagLayout());
3135 backupfilesKeepAll.setLabels(
3136 MessageManager.getString("label.keep_all_backup_files"),
3137 MessageManager.getString(
3138 "label.keep_only_this_number_of_backup_files"));
3139 backupfilesKeepAll.addTrueActionListener(new ActionListener()
3142 public void actionPerformed(ActionEvent e)
3144 backupfilesRevertButtonSetEnabled(true);
3145 updateBackupFilesExampleLabel();
3148 backupfilesKeepAll.addActionListener(new ActionListener()
3151 public void actionPerformed(ActionEvent e)
3153 backupfilesRevertButtonSetEnabled(true);
3154 keepRollMaxOptionsEnabled();
3155 updateBackupFilesExampleLabel();
3159 ChangeListener c = new ChangeListener()
3162 public void stateChanged(ChangeEvent e)
3164 backupfilesRevertButtonSetEnabled(true);
3165 updateBackupFilesExampleLabel();
3169 setIntegerSpinner(backupfilesRollMaxSpinner,
3170 BackupFilesPresetEntry.ROLLMAXMIN,
3171 BackupFilesPresetEntry.ROLLMAXMAX, 4, true, c);
3173 backupfilesConfirmDelete.setLabels(
3174 MessageManager.getString("label.always_ask"),
3175 MessageManager.getString("label.auto_delete"));
3176 backupfilesConfirmDelete.addActionListener(new ActionListener()
3179 public void actionPerformed(ActionEvent e)
3181 backupfilesRevertButtonSetEnabled(true);
3184 // update the enabled section
3185 keepRollMaxOptionsEnabled();
3187 GridBagConstraints kgbc = new GridBagConstraints();
3189 // first row (template text box)
3190 kgbc.anchor = GridBagConstraints.WEST;
3193 kgbc.gridwidth = GridBagConstraints.REMAINDER;
3194 kgbc.gridheight = 1;
3197 kgbc.fill = GridBagConstraints.HORIZONTAL;
3198 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
3204 kgbc.gridwidth = GridBagConstraints.RELATIVE;
3205 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
3208 kgbc.gridwidth = GridBagConstraints.REMAINDER;
3209 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
3211 // third row (indented)
3213 kgbc.insets = new Insets(0, 20, 0, 0);
3216 kgbc.gridwidth = GridBagConstraints.REMAINDER;
3217 kgbc.fill = GridBagConstraints.HORIZONTAL;
3220 JPanel jp = new JPanel();
3221 jp.setLayout(new FlowLayout());
3223 .setText(MessageManager
3224 .getString("label.autodelete_old_backup_files"));
3225 oldBackupFilesLabel.setFont(LABEL_FONT);
3226 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
3227 jp.add(oldBackupFilesLabel);
3228 jp.add(backupfilesConfirmDelete.getTrueButton());
3229 jp.add(backupfilesConfirmDelete.getFalseButton());
3230 keepfilesPanel.add(jp, kgbc);
3232 return keepfilesPanel;
3235 protected void updateBackupFilesExampleLabel()
3237 int exampleindex = 12;
3238 String base = MessageManager.getString("label.filename") + ".fa";
3239 if (base == null || base.length() == 0)
3241 base = "file_name.fa";
3244 boolean reverse = suffixReverse.isSelected();
3245 boolean keepAll = backupfilesKeepAll.isSelected();
3247 String suffix = suffixTemplate.getText();
3250 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
3251 if (suffix == null || suffix.length() == 0)
3253 backupfilesExampleLabel
3254 .setText(MessageManager.getString("label.no_backup_files"));
3255 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
3259 rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 4);
3260 rollMax = rollMax < 1 ? 1 : rollMax;
3262 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
3267 digits = getSpinnerInt(suffixDigitsSpinner, 3);
3268 digits = digits < 1 ? 1 : digits;
3270 int lowersurround = 2;
3271 int uppersurround = 0;
3272 StringBuilder exampleSB = new StringBuilder();
3273 boolean firstLine = true;
3279 int max = keepAll ? exampleindex : rollMax;
3280 for (int index = min; index <= max; index++)
3282 if (index == min + lowersurround && index < max - uppersurround - 1)
3284 exampleSB.append("\n...");
3287 else if (index > min + lowersurround && index < max - uppersurround)
3299 exampleSB.append("\n");
3302 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
3303 base, suffix, digits));
3306 // no extra text needed
3308 else if (index == min)
3310 String newest = MessageManager.getString("label.braced_newest");
3311 if (newest != null && newest.length() > 0)
3313 exampleSB.append(" " + newest);
3316 else if (index == max)
3318 String oldest = MessageManager.getString("label.braced_oldest");
3319 if (oldest != null && oldest.length() > 0)
3321 exampleSB.append(" " + oldest);
3330 int min = (keepAll || exampleindex - rollMax < 0) ? 1
3331 : exampleindex - rollMax + 1;
3332 int max = exampleindex;
3334 for (int index = min; index <= max; index++)
3337 if (index == min + lowersurround && index < max - uppersurround - 1)
3339 exampleSB.append("\n...");
3342 else if (index > min + lowersurround && index < max - uppersurround)
3354 exampleSB.append("\n");
3357 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
3358 base, suffix, digits));
3361 // no extra text needed
3363 else if (index == min)
3365 String oldest = MessageManager.getString("label.braced_oldest");
3366 if (oldest != null && oldest.length() > 0)
3368 exampleSB.append(" " + oldest);
3371 else if (index == max)
3373 String newest = MessageManager.getString("label.braced_newest");
3374 if (newest != null && newest.length() > 0)
3376 exampleSB.append(" " + newest);
3384 // add some extra empty lines to pad out the example files box. ugh, please tell
3385 // me how to do this better
3386 int remainingLines = lowersurround + uppersurround + 1 - lineNumber;
3387 if (remainingLines > 0)
3389 for (int i = 0; i < remainingLines; i++)
3391 exampleSB.append("\n ");
3396 backupfilesExampleLabel.setText(exampleSB.toString());
3399 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
3400 boolean useExistingVal, ChangeListener c)
3407 i = ((Integer) s.getValue()).intValue();
3408 } catch (Exception e)
3411 "Exception casting the initial value of s.getValue()");
3415 setIntegerSpinner(s, min, max, i, c);
3418 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
3421 // integer spinner for number of digits
3430 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
3433 s.addChangeListener(c);
3437 protected static int getSpinnerInt(JSpinner s, int def)
3443 i = (Integer) s.getValue();
3444 } catch (Exception e)
3446 Console.error("Failed casting (Integer) JSpinner s.getValue()");
3451 private void keepRollMaxOptionsEnabled()
3453 boolean enabled = backupfilesKeepAll.isEnabled()
3454 && !backupfilesKeepAll.isSelected();
3455 oldBackupFilesLabel.setEnabled(enabled);
3456 backupfilesRollMaxSpinner.setEnabled(enabled);
3457 backupfilesConfirmDelete.setEnabled(enabled);
3460 private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
3462 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3463 && customiseCheckbox.isSelected()
3464 && suffixTemplate.getText()
3465 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
3466 keepfilesPanel.setEnabled(enabled);
3467 backupfilesKeepAll.setEnabled(enabled);
3468 oldBackupFilesLabel.setEnabled(enabled);
3469 keepRollMaxOptionsEnabled();
3472 private void backupfilesSuffixTemplateDigitsSetEnabled()
3474 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
3475 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
3476 suffixDigitsLabel.setEnabled(enabled);
3477 suffixDigitsSpinner.setEnabled(enabled);
3478 suffixReverse.setEnabled(enabled);
3481 private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
3483 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3484 && customiseCheckbox.isSelected();
3485 suffixPanel.setEnabled(enabled);
3486 suffixTemplateLabel.setEnabled(enabled);
3487 suffixTemplate.setEnabled(enabled);
3488 backupfilesSuffixTemplateDigitsSetEnabled();
3491 private void backupfilesRevertButtonSetEnabled(boolean tryEnabled)
3493 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
3494 && customiseCheckbox.isSelected() && backupfilesCustomChanged();
3495 revertButton.setEnabled(enabled);
3498 private boolean backupfilesCustomChanged()
3500 BackupFilesPresetEntry custom = BackupFilesPresetEntry.backupfilesPresetEntriesValues
3501 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
3502 BackupFilesPresetEntry current = getBackupfilesCurrentEntry();
3503 return !custom.equals(current);
3506 protected BackupFilesPresetEntry getBackupfilesCurrentEntry()
3508 String suffix = suffixTemplate.getText();
3509 int digits = getSpinnerInt(suffixDigitsSpinner, 3);
3510 boolean reverse = suffixReverse.isSelected();
3511 boolean keepAll = backupfilesKeepAll.isSelected();
3512 int rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 3);
3513 boolean confirmDelete = backupfilesConfirmDelete.isSelected();
3515 BackupFilesPresetEntry bfpe = new BackupFilesPresetEntry(suffix, digits,
3516 reverse, keepAll, rollMax, confirmDelete);
3521 protected void backupfilesCustomOptionsSetEnabled()
3523 boolean enabled = customiseCheckbox.isSelected();
3525 backupfilesRevertButtonSetEnabled(enabled);
3526 backupfilesSuffixTemplateSetEnabled(enabled);
3527 backupfilesKeepAllSetEnabled(enabled);
3530 private void backupfilesSummarySetEnabled()
3532 boolean enabled = enableBackupFiles.isSelected();
3533 backupfilesExampleLabel.setEnabled(enabled);
3534 exampleFilesPanel.setEnabled(enabled);
3537 private void backupfilesPresetsSetEnabled()
3539 boolean enabled = enableBackupFiles.isSelected();
3540 presetsPanel.setEnabled(enabled);
3541 presetsComboLabel.setEnabled(enabled);
3542 backupfilesPresetsCombo.setEnabled(enabled);
3543 customiseCheckbox.setEnabled(enabled);
3544 revertButton.setEnabled(enabled);
3547 protected void backupsOptionsSetEnabled()
3549 backupfilesPresetsSetEnabled();
3550 backupfilesSummarySetEnabled();
3551 backupfilesCustomOptionsSetEnabled();
3554 protected void backupsSetOptions(String suffix, int digits,
3555 boolean reverse, boolean keepAll, int rollMax,
3556 boolean confirmDelete)
3558 suffixTemplate.setText(suffix);
3559 suffixDigitsSpinner.setValue(digits);
3560 suffixReverse.setSelected(reverse);
3561 backupfilesKeepAll.setSelected(keepAll);
3562 backupfilesRollMaxSpinner.setValue(rollMax);
3563 backupfilesConfirmDelete.setSelected(confirmDelete);
3566 protected void backupsSetOptions(BackupFilesPresetEntry p)
3568 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
3572 protected void autoIdWidth_actionPerformed()
3574 // TODO Auto-generated method stub
3578 protected void userIdWidth_actionPerformed()
3580 // TODO Auto-generated method stub
3584 protected void maxColour_actionPerformed(JPanel panel)
3588 protected void minColour_actionPerformed(JPanel panel)
3592 protected void gapColour_actionPerformed(JPanel panel)
3596 protected void hiddenColour_actionPerformed(JPanel panel)
3600 protected void showunconserved_actionPerformed(ActionEvent e)
3602 // TODO Auto-generated method stub
3606 protected void useLegacyGaps_actionPerformed(ActionEvent e)
3610 protected void resetOvDefaults_actionPerformed(ActionEvent e)
3620 public void ok_actionPerformed(ActionEvent e)
3630 public void cancel_actionPerformed(ActionEvent e)
3640 public void annotations_actionPerformed(ActionEvent e)
3647 public void startupFileTextfield_mouseClicked()
3651 public void newLink_actionPerformed(ActionEvent e)
3656 public void editLink_actionPerformed(ActionEvent e)
3661 public void deleteLink_actionPerformed(ActionEvent e)
3666 public void defaultBrowser_mouseClicked(MouseEvent e)
3671 public void linkURLList_keyTyped(KeyEvent e)
3676 public void setProxyAuthEnabled()
3678 boolean enabled = proxyAuth.isSelected() && proxyAuth.isEnabled();
3679 proxyAuthUsernameLabel.setEnabled(enabled);
3680 proxyAuthPasswordLabel.setEnabled(enabled);
3681 passwordNotStoredLabel.setEnabled(enabled);
3682 proxyAuthUsernameTB.setEnabled(enabled);
3683 proxyAuthPasswordPB.setEnabled(enabled);
3686 public void setCustomProxyEnabled()
3688 boolean enabled = customProxy.isSelected();
3689 portLabel.setEnabled(enabled);
3690 serverLabel.setEnabled(enabled);
3691 portLabel2.setEnabled(enabled);
3692 serverLabel2.setEnabled(enabled);
3693 httpLabel.setEnabled(enabled);
3694 httpsLabel.setEnabled(enabled);
3695 proxyServerHttpTB.setEnabled(enabled);
3696 proxyPortHttpTB.setEnabled(enabled);
3697 proxyServerHttpsTB.setEnabled(enabled);
3698 proxyPortHttpsTB.setEnabled(enabled);
3699 proxyAuth.setEnabled(enabled);
3700 setProxyAuthEnabled();
3703 public void proxyType_actionPerformed()
3705 setCustomProxyEnabled();
3706 proxyAuthPasswordCheckHighlight(true);
3707 applyProxyButtonEnabled(true);
3710 public void proxyAuth_actionPerformed()
3712 setProxyAuthEnabled();
3713 proxyAuthPasswordCheckHighlight(true);
3714 applyProxyButtonEnabled(true);
3718 * Customer renderer for JTable: supports column of radio buttons
3720 public class RadioButtonRenderer extends JRadioButton
3721 implements TableCellRenderer
3723 public RadioButtonRenderer()
3725 setHorizontalAlignment(CENTER);
3726 setToolTipText(MessageManager.getString("label.urltooltip"));
3730 public Component getTableCellRendererComponent(JTable table,
3731 Object value, boolean isSelected, boolean hasFocus, int row,
3734 setSelected((boolean) value);
3736 // set colours to match rest of table
3739 setBackground(table.getSelectionBackground());
3740 setForeground(table.getSelectionForeground());
3744 setBackground(table.getBackground());
3745 setForeground(table.getForeground());
3752 * Customer cell editor for JTable: supports column of radio buttons in
3753 * conjunction with renderer
3755 public class RadioButtonEditor extends AbstractCellEditor
3756 implements TableCellEditor
3758 private JRadioButton button = new JRadioButton();
3760 public RadioButtonEditor()
3762 button.setHorizontalAlignment(SwingConstants.CENTER);
3763 this.button.addActionListener(new ActionListener()
3766 public void actionPerformed(ActionEvent e)
3768 fireEditingStopped();
3774 public Component getTableCellEditorComponent(JTable table, Object value,
3775 boolean isSelected, int row, int column)
3777 button.setSelected((boolean) value);
3782 public Object getCellEditorValue()
3784 return button.isSelected();
3789 protected void validateHmmerPath()
3793 protected void validateCygwinPath()
3798 * A helper method to add a panel containing a label and a component to a
3806 protected static void addtoLayout(JPanel panel, String tooltip,
3807 JComponent label, JComponent valBox)
3809 JPanel laypanel = new JPanel(new GridLayout(1, 2));
3810 JPanel labPanel = new JPanel(new BorderLayout());
3811 JPanel valPanel = new JPanel();
3812 labPanel.setBounds(new Rectangle(7, 7, 158, 23));
3813 valPanel.setBounds(new Rectangle(172, 7, 270, 23));
3814 labPanel.add(label, BorderLayout.WEST);
3815 valPanel.add(valBox);
3816 laypanel.add(labPanel);
3817 laypanel.add(valPanel);
3818 valPanel.setToolTipText(tooltip);
3819 labPanel.setToolTipText(tooltip);
3820 valBox.setToolTipText(tooltip);
3821 panel.add(laypanel);