2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.jbgui;
23 import java.awt.BorderLayout;
24 import java.awt.Color;
25 import java.awt.Component;
26 import java.awt.Dimension;
27 import java.awt.FlowLayout;
29 import java.awt.GridBagConstraints;
30 import java.awt.GridBagLayout;
31 import java.awt.GridLayout;
32 import java.awt.Insets;
33 import java.awt.Rectangle;
34 import java.awt.event.ActionEvent;
35 import java.awt.event.ActionListener;
36 import java.awt.event.FocusEvent;
37 import java.awt.event.KeyEvent;
38 import java.awt.event.KeyListener;
39 import java.awt.event.MouseAdapter;
40 import java.awt.event.MouseEvent;
41 import java.util.Arrays;
42 import java.util.List;
44 import javax.swing.AbstractCellEditor;
45 import javax.swing.BorderFactory;
46 import javax.swing.ButtonGroup;
47 import javax.swing.DefaultListCellRenderer;
48 import javax.swing.JButton;
49 import javax.swing.JCheckBox;
50 import javax.swing.JComboBox;
51 import javax.swing.JFileChooser;
52 import javax.swing.JLabel;
53 import javax.swing.JPanel;
54 import javax.swing.JRadioButton;
55 import javax.swing.JScrollPane;
56 import javax.swing.JSpinner;
57 import javax.swing.JTabbedPane;
58 import javax.swing.JTable;
59 import javax.swing.JTextArea;
60 import javax.swing.JTextField;
61 import javax.swing.ListSelectionModel;
62 import javax.swing.SpinnerModel;
63 import javax.swing.SpinnerNumberModel;
64 import javax.swing.SwingConstants;
65 import javax.swing.border.Border;
66 import javax.swing.border.EmptyBorder;
67 import javax.swing.border.EtchedBorder;
68 import javax.swing.border.TitledBorder;
69 import javax.swing.event.ChangeEvent;
70 import javax.swing.event.ChangeListener;
71 import javax.swing.table.TableCellEditor;
72 import javax.swing.table.TableCellRenderer;
74 import jalview.bin.Cache;
75 import jalview.fts.core.FTSDataColumnPreferences;
76 import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource;
77 import jalview.fts.service.pdb.PDBFTSRestClient;
78 import jalview.gui.Desktop;
79 import jalview.gui.JalviewBooleanRadioButtons;
80 import jalview.gui.JvOptionPane;
81 import jalview.gui.JvSwingUtils;
82 import jalview.gui.StructureViewer.ViewerType;
83 import jalview.io.BackupFilenameParts;
84 import jalview.io.BackupFiles;
85 import jalview.io.BackupFilesPresetEntry;
86 import jalview.io.IntKeyStringValueEntry;
87 import jalview.util.MessageManager;
90 * Base class for the Preferences panel.
95 public class GPreferences extends JPanel
97 private static final Font LABEL_FONT = JvSwingUtils.getLabelFont();
99 private static final Font LABEL_FONT_ITALIC = JvSwingUtils
100 .getLabelFont(false, true);
102 private static final Font LABEL_FONT_BOLD = JvSwingUtils
103 .getLabelFont(true, false);
106 * Visual tab components
108 protected JCheckBox fullScreen = new JCheckBox();
110 protected JCheckBox openoverv = new JCheckBox();
112 protected JCheckBox seqLimit = new JCheckBox();
114 protected JCheckBox rightAlign = new JCheckBox();
116 protected JComboBox<String> fontSizeCB = new JComboBox<>();
118 protected JComboBox<String> fontStyleCB = new JComboBox<>();
120 protected JComboBox<String> fontNameCB = new JComboBox<>();
122 protected JCheckBox showOccupancy = new JCheckBox();
124 protected JCheckBox showUnconserved = new JCheckBox();
126 protected JCheckBox idItalics = new JCheckBox();
128 protected JCheckBox smoothFont = new JCheckBox();
130 protected JCheckBox scaleProteinToCdna = new JCheckBox();
132 protected JComboBox<String> gapSymbolCB = new JComboBox<>();
134 protected JCheckBox wrap = new JCheckBox();
136 protected JComboBox<String> sortby = new JComboBox<>();
138 protected JComboBox<String> sortAnnBy = new JComboBox<>();
140 protected JComboBox<String> sortAutocalc = new JComboBox<>();
142 protected JCheckBox startupCheckbox = new JCheckBox();
144 protected JTextField startupFileTextfield = new JTextField();
146 // below are in the 'second column'
147 protected JCheckBox annotations = new JCheckBox();
149 protected JCheckBox quality = new JCheckBox();
151 protected JCheckBox conservation = new JCheckBox();
153 protected JCheckBox identity = new JCheckBox();
155 protected JCheckBox showGroupConsensus = new JCheckBox();
157 protected JCheckBox showGroupConservation = new JCheckBox();
159 protected JCheckBox showConsensHistogram = new JCheckBox();
161 protected JCheckBox showConsensLogo = new JCheckBox();
163 protected JCheckBox showDbRefTooltip = new JCheckBox();
165 protected JCheckBox showNpTooltip = new JCheckBox();
168 * Structure tab and components
170 protected JPanel structureTab;
172 protected JCheckBox structFromPdb = new JCheckBox();
174 protected JCheckBox useRnaView = new JCheckBox();
176 protected JCheckBox addSecondaryStructure = new JCheckBox();
178 protected JCheckBox addTempFactor = new JCheckBox();
180 protected JComboBox<String> structViewer = new JComboBox<>();
182 protected JTextField chimeraPath = new JTextField();
184 protected ButtonGroup mappingMethod = new ButtonGroup();
186 protected JRadioButton siftsMapping = new JRadioButton();
188 protected JRadioButton nwMapping = new JRadioButton();
191 * Colours tab components
193 protected JPanel minColour = new JPanel();
195 protected JPanel maxColour = new JPanel();
197 protected JComboBox<String> protColour = new JComboBox<>();
199 protected JComboBox<String> nucColour = new JComboBox<>();
202 * Overview tab components
204 protected JPanel gapColour = new JPanel();
206 protected JPanel hiddenColour = new JPanel();
208 protected JCheckBox useLegacyGap;
210 protected JCheckBox showHiddenAtStart;
212 protected JLabel gapLabel;
215 * Connections tab components
217 protected JTable linkUrlTable = new JTable();
219 protected JButton editLink = new JButton();
221 protected JButton deleteLink = new JButton();
223 protected JTextField filterTB = new JTextField();
225 protected JButton doReset = new JButton();
227 protected JButton userOnly = new JButton();
229 protected JLabel httpLabel = new JLabel();
231 protected JLabel httpsLabel = new JLabel();
233 protected JLabel portLabel = new JLabel();
235 protected JLabel serverLabel = new JLabel();
237 protected JLabel portLabel2 = new JLabel();
239 protected JLabel serverLabel2 = new JLabel();
241 protected JTextField proxyServerHttpTB = new JTextField();
243 protected JTextField proxyPortHttpTB = new JTextField();
245 protected JTextField proxyServerHttpsTB = new JTextField();
247 protected JTextField proxyPortHttpsTB = new JTextField();
249 protected JTextField defaultBrowser = new JTextField();
251 protected ButtonGroup proxyType = new ButtonGroup();
253 protected JRadioButton noProxy = new JRadioButton();
255 protected JRadioButton systemProxy = new JRadioButton();
257 protected JRadioButton customProxy = new JRadioButton();
259 protected JCheckBox usagestats = new JCheckBox();
261 protected JCheckBox questionnaire = new JCheckBox();
263 protected JCheckBox versioncheck = new JCheckBox();
266 * Output tab components
268 protected JComboBox<Object> epsRendering = new JComboBox<>();
270 protected JLabel userIdWidthlabel = new JLabel();
272 protected JCheckBox autoIdWidth = new JCheckBox();
274 protected JTextField userIdWidth = new JTextField();
276 protected JCheckBox blcjv = new JCheckBox();
278 protected JCheckBox pileupjv = new JCheckBox();
280 protected JCheckBox clustaljv = new JCheckBox();
282 protected JCheckBox msfjv = new JCheckBox();
284 protected JCheckBox fastajv = new JCheckBox();
286 protected JCheckBox pfamjv = new JCheckBox();
288 protected JCheckBox pirjv = new JCheckBox();
290 protected JCheckBox modellerOutput = new JCheckBox();
292 protected JCheckBox embbedBioJSON = new JCheckBox();
295 * Editing tab components
297 protected JCheckBox autoCalculateConsCheck = new JCheckBox();
299 protected JCheckBox padGaps = new JCheckBox();
301 protected JCheckBox sortByTree = new JCheckBox();
306 protected JPanel wsTab = new JPanel();
309 * Backups tab components
310 * a lot of these are member variables instead of local variables only so that they
311 * can be enabled/disabled easily in one go
314 protected JCheckBox enableBackupFiles = new JCheckBox();
316 protected JPanel presetsPanel = new JPanel();
318 protected JLabel presetsComboLabel = new JLabel();
320 protected JCheckBox customiseCheckbox = new JCheckBox();
322 protected JButton revertButton = new JButton();
324 protected JComboBox<Object> backupfilesPresetsCombo = new JComboBox<>();
326 private int backupfilesPresetsComboLastSelected = 0;
328 protected JPanel suffixPanel = new JPanel();
330 protected JPanel keepfilesPanel = new JPanel();
332 protected JPanel exampleFilesPanel = new JPanel();
334 protected JTextField suffixTemplate = new JTextField(null, 8);
336 protected JLabel suffixTemplateLabel = new JLabel();
338 protected JLabel suffixDigitsLabel = new JLabel();
340 protected JSpinner suffixDigitsSpinner = new JSpinner();
342 protected JalviewBooleanRadioButtons suffixReverse = new JalviewBooleanRadioButtons();
344 protected JalviewBooleanRadioButtons backupfilesKeepAll = new JalviewBooleanRadioButtons();
346 public JSpinner backupfilesRollMaxSpinner = new JSpinner();
348 protected JLabel oldBackupFilesLabel = new JLabel();
350 protected JalviewBooleanRadioButtons backupfilesConfirmDelete = new JalviewBooleanRadioButtons();
352 protected JTextArea backupfilesExampleLabel = new JTextArea();
355 * Creates a new GPreferences object.
357 public GPreferences()
362 } catch (Exception ex)
364 ex.printStackTrace();
369 * Construct the panel and its tabbed sub-panels.
373 private void jbInit() throws Exception
375 final JTabbedPane tabbedPane = new JTabbedPane();
376 this.setLayout(new BorderLayout());
377 JPanel okCancelPanel = initOkCancelPanel();
378 this.add(tabbedPane, BorderLayout.CENTER);
379 this.add(okCancelPanel, BorderLayout.SOUTH);
381 tabbedPane.add(initVisualTab(),
382 MessageManager.getString("label.visual"));
384 tabbedPane.add(initColoursTab(),
385 MessageManager.getString("label.colours"));
387 tabbedPane.add(initOverviewTab(),
388 MessageManager.getString("label.overview"));
390 tabbedPane.add(initStructureTab(),
391 MessageManager.getString("label.structure"));
393 tabbedPane.add(initConnectionsTab(),
394 MessageManager.getString("label.connections"));
396 tabbedPane.add(initBackupsTab(),
397 MessageManager.getString("label.backups"));
399 tabbedPane.add(initLinksTab(),
400 MessageManager.getString("label.urllinks"));
402 tabbedPane.add(initOutputTab(),
403 MessageManager.getString("label.output"));
405 tabbedPane.add(initEditingTab(),
406 MessageManager.getString("label.editing"));
409 * See WsPreferences for the real work of configuring this tab.
411 wsTab.setLayout(new BorderLayout());
412 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
415 * Handler to validate a tab before leaving it - currently only for
418 tabbedPane.addChangeListener(new ChangeListener()
420 private Component lastTab;
423 public void stateChanged(ChangeEvent e)
425 if (lastTab == structureTab
426 && tabbedPane.getSelectedComponent() != structureTab)
428 if (!validateStructure())
430 tabbedPane.setSelectedComponent(structureTab);
434 lastTab = tabbedPane.getSelectedComponent();
441 * Initialises the Editing tabbed panel.
445 private JPanel initEditingTab()
447 JPanel editingTab = new JPanel();
448 editingTab.setLayout(null);
449 autoCalculateConsCheck.setFont(LABEL_FONT);
450 autoCalculateConsCheck.setText(
451 MessageManager.getString("label.autocalculate_consensus"));
452 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
453 padGaps.setFont(LABEL_FONT);
455 MessageManager.getString("label.pad_gaps_when_editing"));
456 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
457 sortByTree.setFont(LABEL_FONT);
459 .setText(MessageManager.getString("label.sort_with_new_tree"));
460 sortByTree.setToolTipText(MessageManager.getString(
461 "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
462 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
463 editingTab.add(autoCalculateConsCheck);
464 editingTab.add(padGaps);
465 editingTab.add(sortByTree);
470 * Initialises the Output tabbed panel.
474 private JPanel initOutputTab()
476 JPanel outputTab = new JPanel();
477 outputTab.setLayout(null);
478 JLabel epsLabel = new JLabel();
479 epsLabel.setFont(LABEL_FONT);
480 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
481 epsLabel.setText(MessageManager.getString("label.eps_rendering_style"));
482 epsLabel.setBounds(new Rectangle(9, 31, 140, 24));
483 epsRendering.setFont(LABEL_FONT);
484 epsRendering.setBounds(new Rectangle(154, 34, 187, 21));
485 JLabel jLabel1 = new JLabel();
486 jLabel1.setFont(LABEL_FONT);
487 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
488 jLabel1.setText(MessageManager.getString("label.append_start_end"));
489 jLabel1.setFont(LABEL_FONT);
490 fastajv.setFont(LABEL_FONT);
491 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
492 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
493 blcjv.setText(MessageManager.getString("label.blc") + " ");
494 fastajv.setText(MessageManager.getString("label.fasta") + " ");
495 msfjv.setText(MessageManager.getString("label.msf") + " ");
496 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
497 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
498 msfjv.setFont(LABEL_FONT);
499 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
500 pirjv.setText(MessageManager.getString("label.pir") + " ");
501 JPanel jPanel11 = new JPanel();
502 jPanel11.setFont(LABEL_FONT);
503 TitledBorder titledBorder2 = new TitledBorder(
504 MessageManager.getString("label.file_output"));
505 jPanel11.setBorder(titledBorder2);
506 jPanel11.setBounds(new Rectangle(30, 72, 196, 182));
507 GridLayout gridLayout3 = new GridLayout();
508 jPanel11.setLayout(gridLayout3);
509 gridLayout3.setRows(8);
510 blcjv.setFont(LABEL_FONT);
511 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
512 clustaljv.setFont(LABEL_FONT);
513 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
514 pfamjv.setFont(LABEL_FONT);
515 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
516 pileupjv.setFont(LABEL_FONT);
517 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
518 pirjv.setFont(LABEL_FONT);
519 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
520 autoIdWidth.setFont(LABEL_FONT);
522 MessageManager.getString("label.automatically_set_id_width"));
523 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
524 .getString("label.adjusts_width_generated_eps_png")));
525 autoIdWidth.setBounds(new Rectangle(228, 96, 188, 23));
526 autoIdWidth.addActionListener(new ActionListener()
530 public void actionPerformed(ActionEvent e)
532 autoIdWidth_actionPerformed();
535 userIdWidthlabel.setFont(LABEL_FONT);
536 userIdWidthlabel.setText(
537 MessageManager.getString("label.figure_id_column_width"));
538 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
539 .getString("label.manually_specify_width_left_column")));
540 userIdWidthlabel.setToolTipText(
541 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
542 "label.manually_specify_width_left_column")));
543 userIdWidthlabel.setBounds(new Rectangle(236, 120, 168, 23));
544 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
545 userIdWidth.setText("");
546 userIdWidth.setBounds(new Rectangle(232, 144, 84, 23));
547 userIdWidth.addActionListener(new ActionListener()
551 public void actionPerformed(ActionEvent e)
553 userIdWidth_actionPerformed();
556 modellerOutput.setFont(LABEL_FONT);
558 .setText(MessageManager.getString("label.use_modeller_output"));
559 modellerOutput.setBounds(new Rectangle(228, 226, 168, 23));
560 embbedBioJSON.setFont(LABEL_FONT);
561 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
562 embbedBioJSON.setBounds(new Rectangle(228, 200, 250, 23));
564 jPanel11.add(jLabel1);
566 jPanel11.add(clustaljv);
567 jPanel11.add(fastajv);
569 jPanel11.add(pfamjv);
570 jPanel11.add(pileupjv);
572 outputTab.add(autoIdWidth);
573 outputTab.add(userIdWidth);
574 outputTab.add(userIdWidthlabel);
575 outputTab.add(modellerOutput);
576 outputTab.add(embbedBioJSON);
577 outputTab.add(epsLabel);
578 outputTab.add(epsRendering);
579 outputTab.add(jPanel11);
584 * Initialises the Connections tabbed panel.
588 private JPanel initConnectionsTab()
590 JPanel connectTab = new JPanel();
591 connectTab.setLayout(new GridBagLayout());
593 // Label for browser text box
594 JLabel browserLabel = new JLabel();
595 browserLabel.setFont(LABEL_FONT);
596 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
597 browserLabel.setText(
598 MessageManager.getString("label.default_browser_unix"));
599 defaultBrowser.setFont(LABEL_FONT);
600 defaultBrowser.setText("");
601 final String tooltip = JvSwingUtils.wrapTooltip(true,
602 MessageManager.getString("label.double_click_to_browse"));
603 defaultBrowser.setToolTipText(tooltip);
604 defaultBrowser.addMouseListener(new MouseAdapter()
607 public void mouseClicked(MouseEvent e)
609 if (e.getClickCount() > 1)
611 defaultBrowser_mouseClicked(e);
616 JPanel proxyPanel = initConnTabProxyPanel();
617 initConnTabCheckboxes();
619 // Add default Browser text box
620 connectTab.add(browserLabel,
621 new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
622 GridBagConstraints.WEST, GridBagConstraints.NONE,
623 new Insets(10, 0, 5, 5), 5, 1));
624 defaultBrowser.setFont(LABEL_FONT);
625 defaultBrowser.setText("");
627 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
628 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
629 new Insets(10, 0, 5, 10), 30, 1));
631 // Add proxy server panel
632 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
633 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
634 new Insets(10, 0, 5, 12), 4, 10));
636 // Add usage stats, version check and questionnaire checkboxes
637 connectTab.add(usagestats,
638 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
639 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
640 new Insets(0, 2, 5, 5), 70, 1));
641 connectTab.add(questionnaire,
642 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
643 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
644 new Insets(0, 2, 5, 10), 70, 1));
645 connectTab.add(versioncheck,
646 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
647 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
648 new Insets(0, 2, 5, 5), 70, 1));
650 versioncheck.setVisible(false);
652 // Add padding so the panel doesn't look ridiculous
653 JPanel spacePanel = new JPanel();
654 connectTab.add(spacePanel,
655 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
656 GridBagConstraints.WEST, GridBagConstraints.BOTH,
657 new Insets(0, 0, 0, 5), 70, 1));
663 * Initialises the Links tabbed panel.
667 private JPanel initLinksTab()
669 JPanel linkTab = new JPanel();
670 linkTab.setLayout(new GridBagLayout());
672 // Set up table for Url links
673 linkUrlTable.getTableHeader().setReorderingAllowed(false);
674 linkUrlTable.setFillsViewportHeight(true);
675 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
676 linkUrlTable.setAutoCreateRowSorter(true);
677 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
679 // adjust row height so radio buttons actually fit
680 // don't do this in the renderer, it causes the awt thread to activate
682 JRadioButton temp = new JRadioButton();
683 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
685 // Table in scrollpane so that the table is given a scrollbar
686 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
687 linkScrollPane.setBorder(null);
689 // Panel for links functionality
690 JPanel linkPanel = new JPanel(new GridBagLayout());
691 linkPanel.setBorder(new TitledBorder(
692 MessageManager.getString("label.url_linkfrom_sequence_id")));
694 // Put the Url links panel together
696 // Buttons go at top right, resizing only resizes the blank space vertically
697 JPanel buttonPanel = initLinkTabUrlButtons();
698 GridBagConstraints linkConstraints1 = new GridBagConstraints();
699 linkConstraints1.insets = new Insets(0, 0, 5, 0);
700 linkConstraints1.gridx = 0;
701 linkConstraints1.gridy = 0;
702 linkConstraints1.weightx = 1.0;
703 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
704 linkTab.add(buttonPanel, linkConstraints1);
706 // Links table goes at top left, resizing resizes the table
707 GridBagConstraints linkConstraints2 = new GridBagConstraints();
708 linkConstraints2.insets = new Insets(0, 0, 5, 5);
709 linkConstraints2.gridx = 0;
710 linkConstraints2.gridy = 1;
711 linkConstraints2.weightx = 1.0;
712 linkConstraints2.weighty = 1.0;
713 linkConstraints2.fill = GridBagConstraints.BOTH;
714 linkTab.add(linkScrollPane, linkConstraints2);
716 // Filter box and buttons goes at bottom left, resizing resizes the text box
717 JPanel filterPanel = initLinkTabFilterPanel();
718 GridBagConstraints linkConstraints3 = new GridBagConstraints();
719 linkConstraints3.insets = new Insets(0, 0, 0, 5);
720 linkConstraints3.gridx = 0;
721 linkConstraints3.gridy = 2;
722 linkConstraints3.weightx = 1.0;
723 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
724 linkTab.add(filterPanel, linkConstraints3);
729 private JPanel initLinkTabFilterPanel()
731 // Filter textbox and reset button
732 JLabel filterLabel = new JLabel(
733 MessageManager.getString("label.filter"));
734 filterLabel.setFont(LABEL_FONT);
735 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
736 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
738 filterTB.setFont(LABEL_FONT);
739 filterTB.setText("");
741 doReset.setText(MessageManager.getString("action.showall"));
742 userOnly.setText(MessageManager.getString("action.customfilter"));
744 // Panel for filter functionality
745 JPanel filterPanel = new JPanel(new GridBagLayout());
746 filterPanel.setBorder(new TitledBorder("Filter"));
747 GridBagConstraints gbc = new GridBagConstraints();
750 gbc.fill = GridBagConstraints.NONE;
751 gbc.anchor = GridBagConstraints.WEST;
753 filterPanel.add(filterLabel, gbc);
755 GridBagConstraints gbc1 = new GridBagConstraints();
758 gbc1.fill = GridBagConstraints.HORIZONTAL;
759 gbc1.anchor = GridBagConstraints.WEST;
761 filterPanel.add(filterTB, gbc1);
763 GridBagConstraints gbc2 = new GridBagConstraints();
765 gbc2.fill = GridBagConstraints.NONE;
766 gbc2.anchor = GridBagConstraints.WEST;
767 filterPanel.add(doReset, gbc2);
769 GridBagConstraints gbc3 = new GridBagConstraints();
771 gbc3.fill = GridBagConstraints.NONE;
772 gbc3.anchor = GridBagConstraints.WEST;
773 filterPanel.add(userOnly, gbc3);
778 private JPanel initLinkTabUrlButtons()
780 // Buttons for new / edit / delete Url links
781 JButton newLink = new JButton();
782 newLink.setText(MessageManager.getString("action.new"));
784 editLink.setText(MessageManager.getString("action.edit"));
786 deleteLink.setText(MessageManager.getString("action.delete"));
788 // no current selection, so initially disable delete/edit buttons
789 editLink.setEnabled(false);
790 deleteLink.setEnabled(false);
792 newLink.addActionListener(new java.awt.event.ActionListener()
795 public void actionPerformed(ActionEvent e)
797 newLink_actionPerformed(e);
801 editLink.setText(MessageManager.getString("action.edit"));
802 editLink.addActionListener(new java.awt.event.ActionListener()
805 public void actionPerformed(ActionEvent e)
807 editLink_actionPerformed(e);
811 deleteLink.setText(MessageManager.getString("action.delete"));
812 deleteLink.addActionListener(new java.awt.event.ActionListener()
815 public void actionPerformed(ActionEvent e)
817 deleteLink_actionPerformed(e);
821 JPanel buttonPanel = new JPanel(new GridBagLayout());
822 buttonPanel.setBorder(new TitledBorder("Edit links"));
823 GridBagConstraints gbc = new GridBagConstraints();
826 gbc.fill = GridBagConstraints.NONE;
827 buttonPanel.add(newLink, gbc);
829 GridBagConstraints gbc1 = new GridBagConstraints();
832 gbc1.fill = GridBagConstraints.NONE;
833 buttonPanel.add(editLink, gbc1);
835 GridBagConstraints gbc2 = new GridBagConstraints();
838 gbc2.fill = GridBagConstraints.NONE;
839 buttonPanel.add(deleteLink, gbc2);
841 GridBagConstraints gbc3 = new GridBagConstraints();
844 gbc3.fill = GridBagConstraints.HORIZONTAL;
846 JPanel spacePanel = new JPanel();
847 spacePanel.setBorder(null);
848 buttonPanel.add(spacePanel, gbc3);
854 * Initialises the proxy server panel in the Connections tab
856 * @return the proxy server panel
858 private JPanel initConnTabProxyPanel()
860 // Label for server text box
861 serverLabel.setText(MessageManager.getString("label.host") + ": ");
862 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
863 serverLabel.setFont(LABEL_FONT);
864 serverLabel2.setText(MessageManager.getString("label.host") + ": ");
865 serverLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
866 serverLabel2.setFont(LABEL_FONT);
868 // Proxy server and port text boxes
869 proxyServerHttpTB.setFont(LABEL_FONT);
870 proxyServerHttpTB.setColumns(40);
871 proxyPortHttpTB.setFont(LABEL_FONT);
872 proxyPortHttpTB.setColumns(4);
873 proxyServerHttpsTB.setFont(LABEL_FONT);
874 proxyServerHttpsTB.setColumns(40);
875 proxyPortHttpsTB.setFont(LABEL_FONT);
876 proxyPortHttpsTB.setColumns(4);
878 // Label for Port text box
879 portLabel.setFont(LABEL_FONT);
880 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
881 portLabel.setText(MessageManager.getString("label.port") + ": ");
882 portLabel2.setFont(LABEL_FONT);
883 portLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
884 portLabel2.setText(MessageManager.getString("label.port") + ": ");
886 httpLabel.setText("HTTP");
887 httpLabel.setFont(LABEL_FONT_BOLD);
888 httpLabel.setHorizontalAlignment(SwingConstants.LEFT);
889 httpsLabel.setText("HTTPS");
890 httpsLabel.setFont(LABEL_FONT_BOLD);
891 httpsLabel.setHorizontalAlignment(SwingConstants.LEFT);
893 // Proxy type radio buttons
894 noProxy.setFont(LABEL_FONT);
895 noProxy.setHorizontalAlignment(SwingConstants.LEFT);
896 // noProxy.setHorizontalTextPosition(SwingConstants.LEADING);
897 noProxy.setText(MessageManager.getString("label.no_proxy"));
898 systemProxy.setFont(LABEL_FONT);
899 systemProxy.setHorizontalAlignment(SwingConstants.LEFT);
900 // systemProxy.setHorizontalTextPosition(SwingConstants.LEADING);
901 systemProxy.setText(MessageManager.formatMessage("label.system_proxy",
902 displayHostPort(Cache.startupProxyProperties[0],
903 Cache.startupProxyProperties[1]),
904 displayHostPort(Cache.startupProxyProperties[2],
905 Cache.startupProxyProperties[3])));
906 customProxy.setFont(LABEL_FONT);
907 customProxy.setHorizontalAlignment(SwingConstants.LEFT);
908 // customProxy.setHorizontalTextPosition(SwingConstants.LEADING);
909 customProxy.addActionListener(new ActionListener()
912 public void actionPerformed(ActionEvent e)
914 customProxy_actionPerformed();
918 MessageManager.getString("label.use_proxy_server") + ":");
919 proxyType.add(noProxy);
920 proxyType.add(systemProxy);
921 proxyType.add(customProxy);
923 // Make proxy server panel
924 JPanel proxyPanel = new JPanel();
925 TitledBorder titledBorder1 = new TitledBorder(
926 MessageManager.getString("label.proxy_servers"));
927 proxyPanel.setBorder(titledBorder1);
928 GridBagConstraints gbc = new GridBagConstraints();
929 proxyPanel.setLayout(new GridBagLayout());
935 gbc.anchor = GridBagConstraints.WEST;
936 gbc.fill = GridBagConstraints.BOTH;
939 proxyPanel.add(noProxy, gbc);
942 proxyPanel.add(systemProxy, gbc);
945 proxyPanel.add(customProxy, gbc);
951 proxyPanel.add(httpLabel, gbc);
954 gbc.anchor = GridBagConstraints.EAST;
956 proxyPanel.add(serverLabel, gbc);
959 gbc.anchor = GridBagConstraints.WEST;
961 proxyPanel.add(proxyServerHttpTB, gbc);
964 gbc.anchor = GridBagConstraints.EAST;
966 proxyPanel.add(portLabel, gbc);
969 gbc.anchor = GridBagConstraints.WEST;
971 proxyPanel.add(proxyPortHttpTB, gbc);
975 gbc.anchor = GridBagConstraints.WEST;
977 proxyPanel.add(httpsLabel, gbc);
980 gbc.anchor = GridBagConstraints.EAST;
982 proxyPanel.add(serverLabel2, gbc);
985 gbc.anchor = GridBagConstraints.WEST;
987 proxyPanel.add(proxyServerHttpsTB, gbc);
990 gbc.anchor = GridBagConstraints.EAST;
992 proxyPanel.add(portLabel2, gbc);
995 gbc.anchor = GridBagConstraints.WEST;
997 proxyPanel.add(proxyPortHttpsTB, gbc);
1000 proxyPanel.add(serverLabel,
1001 new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
1002 GridBagConstraints.WEST, GridBagConstraints.NONE,
1003 new Insets(0, 2, 2, 0), 5, 0));
1004 proxyPanel.add(portLabel,
1005 new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
1006 GridBagConstraints.WEST, GridBagConstraints.NONE,
1007 new Insets(0, 0, 2, 0), 11, 0));
1008 proxyPanel.add(useProxy,
1009 new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
1010 GridBagConstraints.WEST, GridBagConstraints.NONE,
1011 new Insets(0, 2, 5, 185), 2, -4));
1012 proxyPanel.add(proxyPortTB,
1013 new GridBagConstraints(3, 1, 1, 1, 1.0, 0.0,
1014 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
1015 new Insets(0, 2, 2, 2), 54, 1));
1016 proxyPanel.add(proxyServerTB,
1017 new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0,
1018 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
1019 new Insets(0, 2, 2, 0), 263, 1));
1025 private String displayHostPort(String host, String port)
1027 boolean hostBlank = (host == null || host.isEmpty());
1028 boolean portBlank = (port == null || port.isEmpty());
1029 if (hostBlank && portBlank)
1031 return MessageManager.getString("label.none");
1034 StringBuilder sb = new StringBuilder();
1035 sb.append(hostBlank ? "" : host);
1041 return sb.toString();
1045 * Initialises the checkboxes in the Connections tab
1047 private void initConnTabCheckboxes()
1049 // Usage stats checkbox label
1051 MessageManager.getString("label.send_usage_statistics"));
1052 usagestats.setFont(LABEL_FONT);
1053 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
1054 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
1056 // Questionnaire checkbox label
1057 questionnaire.setText(
1058 MessageManager.getString("label.check_for_questionnaires"));
1059 questionnaire.setFont(LABEL_FONT);
1060 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
1061 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
1063 // Check for latest version checkbox label
1064 versioncheck.setText(
1065 MessageManager.getString("label.check_for_latest_version"));
1066 versioncheck.setFont(LABEL_FONT);
1067 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
1068 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
1072 * Initialises the parent panel which contains the tabbed sections.
1076 private JPanel initOkCancelPanel()
1078 JButton ok = new JButton();
1079 ok.setText(MessageManager.getString("action.ok"));
1080 ok.addActionListener(new ActionListener()
1083 public void actionPerformed(ActionEvent e)
1085 ok_actionPerformed(e);
1088 JButton cancel = new JButton();
1089 cancel.setText(MessageManager.getString("action.cancel"));
1090 cancel.addActionListener(new ActionListener()
1093 public void actionPerformed(ActionEvent e)
1095 cancel_actionPerformed(e);
1098 JPanel okCancelPanel = new JPanel();
1099 okCancelPanel.add(ok);
1100 okCancelPanel.add(cancel);
1101 return okCancelPanel;
1105 * Initialises the Colours tabbed panel.
1109 private JPanel initColoursTab()
1111 JPanel coloursTab = new JPanel();
1112 coloursTab.setBorder(new TitledBorder(
1113 MessageManager.getString("action.open_new_alignment")));
1114 coloursTab.setLayout(new FlowLayout());
1115 JLabel mincolourLabel = new JLabel();
1116 mincolourLabel.setFont(LABEL_FONT);
1117 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1118 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
1119 minColour.setFont(LABEL_FONT);
1120 minColour.setBorder(BorderFactory.createEtchedBorder());
1121 minColour.setPreferredSize(new Dimension(40, 20));
1122 minColour.addMouseListener(new MouseAdapter()
1125 public void mousePressed(MouseEvent e)
1127 minColour_actionPerformed(minColour);
1130 JLabel maxcolourLabel = new JLabel();
1131 maxcolourLabel.setFont(LABEL_FONT);
1132 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1133 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
1134 maxColour.setFont(LABEL_FONT);
1135 maxColour.setBorder(BorderFactory.createEtchedBorder());
1136 maxColour.setPreferredSize(new Dimension(40, 20));
1137 maxColour.addMouseListener(new MouseAdapter()
1140 public void mousePressed(MouseEvent e)
1142 maxColour_actionPerformed(maxColour);
1146 protColour.setFont(LABEL_FONT);
1147 protColour.setBounds(new Rectangle(172, 225, 155, 21));
1148 JLabel protColourLabel = new JLabel();
1149 protColourLabel.setFont(LABEL_FONT);
1150 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1151 protColourLabel.setText(
1152 MessageManager.getString("label.prot_alignment_colour") + " ");
1153 JvSwingUtils.addtoLayout(coloursTab,
1155 .getString("label.default_colour_scheme_for_alignment"),
1156 protColourLabel, protColour);
1158 nucColour.setFont(LABEL_FONT);
1159 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1160 JLabel nucColourLabel = new JLabel();
1161 nucColourLabel.setFont(LABEL_FONT);
1162 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1163 nucColourLabel.setText(
1164 MessageManager.getString("label.nuc_alignment_colour") + " ");
1165 JvSwingUtils.addtoLayout(coloursTab,
1167 .getString("label.default_colour_scheme_for_alignment"),
1168 nucColourLabel, nucColour);
1170 JPanel annotationShding = new JPanel();
1171 annotationShding.setBorder(new TitledBorder(
1172 MessageManager.getString("label.annotation_shading_default")));
1173 annotationShding.setLayout(new GridLayout(1, 2));
1174 JvSwingUtils.addtoLayout(annotationShding,
1175 MessageManager.getString(
1176 "label.default_minimum_colour_annotation_shading"),
1177 mincolourLabel, minColour);
1178 JvSwingUtils.addtoLayout(annotationShding,
1179 MessageManager.getString(
1180 "label.default_maximum_colour_annotation_shading"),
1181 maxcolourLabel, maxColour);
1182 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1187 * Initialises the Overview tabbed panel.
1191 private JPanel initOverviewTab()
1193 JPanel overviewPanel = new JPanel();
1194 overviewPanel.setBorder(new TitledBorder(
1195 MessageManager.getString("label.overview_settings")));
1197 gapColour.setFont(LABEL_FONT);
1198 // fixing the border colours stops apparent colour bleed from the panel
1199 gapColour.setBorder(
1200 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1201 gapColour.setPreferredSize(new Dimension(40, 20));
1202 gapColour.addMouseListener(new MouseAdapter()
1205 public void mousePressed(MouseEvent e)
1207 gapColour_actionPerformed(gapColour);
1211 hiddenColour.setFont(LABEL_FONT);
1212 // fixing the border colours stops apparent colour bleed from the panel
1213 hiddenColour.setBorder(
1214 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1215 hiddenColour.setPreferredSize(new Dimension(40, 20));
1216 hiddenColour.addMouseListener(new MouseAdapter()
1219 public void mousePressed(MouseEvent e)
1221 hiddenColour_actionPerformed(hiddenColour);
1225 useLegacyGap = new JCheckBox(
1226 MessageManager.getString("label.ov_legacy_gap"));
1227 useLegacyGap.setFont(LABEL_FONT);
1228 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1229 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1230 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1231 gapLabel.setFont(LABEL_FONT);
1232 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1233 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1234 showHiddenAtStart = new JCheckBox(
1235 MessageManager.getString("label.ov_show_hide_default"));
1236 showHiddenAtStart.setFont(LABEL_FONT);
1237 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1238 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1239 JLabel hiddenLabel = new JLabel(
1240 MessageManager.getString("label.hidden_colour"));
1241 hiddenLabel.setFont(LABEL_FONT);
1242 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1243 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1245 useLegacyGap.addActionListener(new ActionListener()
1248 public void actionPerformed(ActionEvent e)
1250 useLegacyGaps_actionPerformed(e);
1254 overviewPanel.setLayout(new GridBagLayout());
1255 GridBagConstraints c1 = new GridBagConstraints();
1257 c1.fill = GridBagConstraints.HORIZONTAL;
1262 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1263 overviewPanel.add(useLegacyGap, c1);
1265 GridBagConstraints c2 = new GridBagConstraints();
1266 c2.fill = GridBagConstraints.HORIZONTAL;
1269 c2.insets = new Insets(0, 15, 0, 10);
1270 overviewPanel.add(gapLabel, c2);
1272 GridBagConstraints c3 = new GridBagConstraints();
1273 c3.fill = GridBagConstraints.HORIZONTAL;
1276 c3.insets = new Insets(0, 0, 0, 15);
1277 overviewPanel.add(gapColour, c3);
1279 GridBagConstraints c4 = new GridBagConstraints();
1280 c4.fill = GridBagConstraints.HORIZONTAL;
1284 overviewPanel.add(showHiddenAtStart, c4);
1286 GridBagConstraints c5 = new GridBagConstraints();
1287 c5.fill = GridBagConstraints.HORIZONTAL;
1290 c5.insets = new Insets(0, 15, 0, 10);
1291 overviewPanel.add(hiddenLabel, c5);
1293 GridBagConstraints c6 = new GridBagConstraints();
1294 c6.fill = GridBagConstraints.HORIZONTAL;
1297 c6.insets = new Insets(0, 0, 0, 15);
1298 overviewPanel.add(hiddenColour, c6);
1300 JButton resetButton = new JButton(
1301 MessageManager.getString("label.reset_to_defaults"));
1303 resetButton.addActionListener(new ActionListener()
1306 public void actionPerformed(ActionEvent e)
1308 resetOvDefaults_actionPerformed(e);
1312 GridBagConstraints c7 = new GridBagConstraints();
1313 c7.fill = GridBagConstraints.NONE;
1316 c7.insets = new Insets(10, 0, 0, 0);
1317 c7.anchor = GridBagConstraints.WEST;
1318 overviewPanel.add(resetButton, c7);
1320 // Add padding so the panel doesn't look ridiculous
1321 JPanel spacePanel = new JPanel();
1322 overviewPanel.add(spacePanel,
1323 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1324 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1325 new Insets(0, 0, 0, 5), 0, 0));
1327 return overviewPanel;
1331 * Initialises the Structure tabbed panel.
1335 private JPanel initStructureTab()
1337 structureTab = new JPanel();
1339 structureTab.setBorder(new TitledBorder(
1340 MessageManager.getString("label.structure_options")));
1341 structureTab.setLayout(null);
1342 final int width = 400;
1343 final int height = 22;
1344 final int lineSpacing = 25;
1347 structFromPdb.setFont(LABEL_FONT);
1349 .setText(MessageManager.getString("label.struct_from_pdb"));
1350 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1351 structFromPdb.addActionListener(new ActionListener()
1354 public void actionPerformed(ActionEvent e)
1356 boolean selected = structFromPdb.isSelected();
1357 // enable other options only when the first is checked
1358 useRnaView.setEnabled(selected);
1359 addSecondaryStructure.setEnabled(selected);
1360 addTempFactor.setEnabled(selected);
1363 structureTab.add(structFromPdb);
1365 // indent checkboxes that are conditional on the first one
1366 ypos += lineSpacing;
1367 useRnaView.setFont(LABEL_FONT);
1368 useRnaView.setText(MessageManager.getString("label.use_rnaview"));
1369 useRnaView.setBounds(new Rectangle(25, ypos, width, height));
1370 structureTab.add(useRnaView);
1372 ypos += lineSpacing;
1373 addSecondaryStructure.setFont(LABEL_FONT);
1374 addSecondaryStructure
1375 .setText(MessageManager.getString("label.autoadd_secstr"));
1376 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1377 structureTab.add(addSecondaryStructure);
1379 ypos += lineSpacing;
1380 addTempFactor.setFont(LABEL_FONT);
1381 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1382 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1383 structureTab.add(addTempFactor);
1385 ypos += lineSpacing;
1386 JLabel viewerLabel = new JLabel();
1387 viewerLabel.setFont(LABEL_FONT);
1388 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1389 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1390 viewerLabel.setBounds(new Rectangle(10, ypos, 200, height));
1391 structureTab.add(viewerLabel);
1393 structViewer.setFont(LABEL_FONT);
1394 structViewer.setBounds(new Rectangle(160, ypos, 120, height));
1395 structViewer.addItem(ViewerType.JMOL.name());
1396 structViewer.addItem(ViewerType.CHIMERA.name());
1397 structViewer.addActionListener(new ActionListener()
1400 public void actionPerformed(ActionEvent e)
1402 structureViewer_actionPerformed(
1403 (String) structViewer.getSelectedItem());
1406 structureTab.add(structViewer);
1408 ypos += lineSpacing;
1409 JLabel pathLabel = new JLabel();
1410 pathLabel.setFont(new java.awt.Font("SansSerif", 0, 11));
1411 pathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1412 pathLabel.setText(MessageManager.getString("label.chimera_path"));
1413 pathLabel.setBounds(new Rectangle(10, ypos, 140, height));
1414 structureTab.add(pathLabel);
1416 chimeraPath.setFont(LABEL_FONT);
1417 chimeraPath.setText("");
1418 final String tooltip = JvSwingUtils.wrapTooltip(true,
1419 MessageManager.getString("label.chimera_path_tip"));
1420 chimeraPath.setToolTipText(tooltip);
1421 chimeraPath.setBounds(new Rectangle(160, ypos, 300, height));
1422 chimeraPath.addMouseListener(new MouseAdapter()
1425 public void mouseClicked(MouseEvent e)
1427 if (e.getClickCount() == 2)
1429 String chosen = openFileChooser();
1432 chimeraPath.setText(chosen);
1437 structureTab.add(chimeraPath);
1439 ypos += lineSpacing;
1440 nwMapping.setFont(LABEL_FONT);
1441 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1442 siftsMapping.setFont(LABEL_FONT);
1443 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1444 mappingMethod.add(nwMapping);
1445 mappingMethod.add(siftsMapping);
1446 JPanel mappingPanel = new JPanel();
1447 mappingPanel.setFont(LABEL_FONT);
1448 TitledBorder mmTitledBorder = new TitledBorder(
1449 MessageManager.getString("label.mapping_method"));
1450 mmTitledBorder.setTitleFont(LABEL_FONT);
1451 mappingPanel.setBorder(mmTitledBorder);
1452 mappingPanel.setBounds(new Rectangle(10, ypos, 452, 45));
1453 // GridLayout mappingLayout = new GridLayout();
1454 mappingPanel.setLayout(new GridLayout());
1455 mappingPanel.add(nwMapping);
1456 mappingPanel.add(siftsMapping);
1457 structureTab.add(mappingPanel);
1459 ypos += lineSpacing;
1460 ypos += lineSpacing;
1461 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1462 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1463 docFieldPref.setBounds(new Rectangle(10, ypos, 450, 120));
1464 structureTab.add(docFieldPref);
1466 return structureTab;
1470 * Action on choosing a structure viewer from combobox options.
1472 * @param selectedItem
1474 protected void structureViewer_actionPerformed(String selectedItem)
1479 * Show a dialog for the user to choose a file. Returns the chosen path, or
1484 protected String openFileChooser()
1486 String choice = null;
1487 JFileChooser chooser = new JFileChooser();
1489 // chooser.setFileView(new JalviewFileView());
1490 chooser.setDialogTitle(
1491 MessageManager.getString("label.open_local_file"));
1492 chooser.setToolTipText(MessageManager.getString("action.open"));
1494 int value = chooser.showOpenDialog(this);
1496 if (value == JFileChooser.APPROVE_OPTION)
1498 choice = chooser.getSelectedFile().getPath();
1504 * Validate the structure tab preferences; if invalid, set focus on this tab.
1508 protected boolean validateStructure(FocusEvent e)
1510 if (!validateStructure())
1512 e.getComponent().requestFocusInWindow();
1518 protected boolean validateStructure()
1524 * Initialises the Visual tabbed panel.
1528 private JPanel initVisualTab()
1530 JPanel visualTab = new JPanel();
1531 visualTab.setBorder(new TitledBorder(
1532 MessageManager.getString("action.open_new_alignment")));
1533 visualTab.setLayout(null);
1534 fullScreen.setFont(LABEL_FONT);
1535 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1536 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1537 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1538 quality.setEnabled(false);
1539 quality.setFont(LABEL_FONT);
1540 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1541 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1542 quality.setSelected(true);
1543 quality.setText(MessageManager.getString("label.quality"));
1544 conservation.setEnabled(false);
1545 conservation.setFont(LABEL_FONT);
1546 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1547 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1548 conservation.setSelected(true);
1549 conservation.setText(MessageManager.getString("label.conservation"));
1550 identity.setEnabled(false);
1551 identity.setFont(LABEL_FONT);
1552 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1553 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1554 identity.setSelected(true);
1555 identity.setText(MessageManager.getString("label.consensus"));
1556 showOccupancy.setFont(LABEL_FONT);
1557 showOccupancy.setEnabled(false);
1558 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1559 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1560 showOccupancy.setSelected(true);
1561 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1563 JLabel showGroupbits = new JLabel();
1564 showGroupbits.setFont(LABEL_FONT);
1565 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1566 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1568 .setText(MessageManager.getString("action.show_group") + ":");
1569 JLabel showConsensbits = new JLabel();
1570 showConsensbits.setFont(LABEL_FONT);
1571 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1572 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1574 .setText(MessageManager.getString("label.consensus") + ":");
1575 showConsensHistogram.setEnabled(false);
1576 showConsensHistogram.setFont(LABEL_FONT);
1577 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1578 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1579 showConsensHistogram.setSelected(true);
1580 showConsensHistogram
1581 .setText(MessageManager.getString("label.histogram"));
1582 showConsensLogo.setEnabled(false);
1583 showConsensLogo.setFont(LABEL_FONT);
1584 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1585 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1586 showConsensLogo.setSelected(true);
1587 showConsensLogo.setText(MessageManager.getString("label.logo"));
1588 showGroupConsensus.setEnabled(false);
1589 showGroupConsensus.setFont(LABEL_FONT);
1590 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1591 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1592 showGroupConsensus.setSelected(true);
1593 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1594 showGroupConservation.setEnabled(false);
1595 showGroupConservation.setFont(LABEL_FONT);
1596 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1597 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1598 showGroupConservation.setSelected(true);
1599 showGroupConservation
1600 .setText(MessageManager.getString("label.conservation"));
1601 showNpTooltip.setEnabled(true);
1602 showNpTooltip.setFont(LABEL_FONT);
1603 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1604 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1605 showNpTooltip.setSelected(true);
1606 showNpTooltip.setText(
1607 MessageManager.getString("label.non_positional_features"));
1608 showDbRefTooltip.setEnabled(true);
1609 showDbRefTooltip.setFont(LABEL_FONT);
1610 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1611 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1612 showDbRefTooltip.setSelected(true);
1614 .setText(MessageManager.getString("label.database_references"));
1615 annotations.setFont(LABEL_FONT);
1616 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1617 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1618 annotations.setSelected(true);
1619 annotations.setText(MessageManager.getString("label.show_annotations"));
1620 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1621 annotations.addActionListener(new ActionListener()
1624 public void actionPerformed(ActionEvent e)
1626 annotations_actionPerformed(e);
1629 identity.addActionListener(new ActionListener()
1632 public void actionPerformed(ActionEvent e)
1634 annotations_actionPerformed(e);
1637 showGroupConsensus.addActionListener(new ActionListener()
1640 public void actionPerformed(ActionEvent e)
1642 annotations_actionPerformed(e);
1645 showUnconserved.setFont(LABEL_FONT);
1646 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1647 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1648 showUnconserved.setSelected(true);
1650 .setText(MessageManager.getString("action.show_unconserved"));
1651 showUnconserved.addActionListener(new ActionListener()
1654 public void actionPerformed(ActionEvent e)
1656 showunconserved_actionPerformed(e);
1660 // TODO these are not yet added to / action from Preferences
1661 // JCheckBox shareSelections = new JCheckBox();
1662 // shareSelections.setFont(verdana11);
1663 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1664 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1665 // shareSelections.setSelected(true);
1666 // shareSelections.setText(MessageManager
1667 // .getString("label.share_selection_across_views"));
1668 // JCheckBox followHighlight = new JCheckBox();
1669 // followHighlight.setFont(verdana11);
1670 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1671 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1672 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1673 // followHighlight.setSelected(true);
1674 // followHighlight.setText(MessageManager
1675 // .getString("label.scroll_highlighted_regions"));
1677 seqLimit.setFont(LABEL_FONT);
1678 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1679 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1680 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1681 smoothFont.setFont(LABEL_FONT);
1682 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1683 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1684 smoothFont.setText(MessageManager.getString("label.smooth_font"));
1685 scaleProteinToCdna.setFont(LABEL_FONT);
1686 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1687 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1688 scaleProteinToCdna.setText(
1689 MessageManager.getString("label.scale_protein_to_cdna"));
1690 scaleProteinToCdna.setToolTipText(
1691 MessageManager.getString("label.scale_protein_to_cdna_tip"));
1692 JLabel gapLabel = new JLabel();
1693 gapLabel.setFont(LABEL_FONT);
1694 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1695 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1696 JLabel fontLabel = new JLabel();
1697 fontLabel.setFont(LABEL_FONT);
1698 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1699 fontLabel.setText(MessageManager.getString("label.font"));
1700 fontSizeCB.setFont(LABEL_FONT);
1701 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
1702 fontStyleCB.setFont(LABEL_FONT);
1703 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
1704 fontNameCB.setFont(LABEL_FONT);
1705 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
1706 gapSymbolCB.setFont(LABEL_FONT);
1707 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
1708 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1709 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1710 gapSymbolCB.setRenderer(dlcr);
1712 startupCheckbox.setText(MessageManager.getString("action.open_file"));
1713 startupCheckbox.setFont(LABEL_FONT);
1714 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1715 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1716 startupCheckbox.setSelected(true);
1717 startupFileTextfield.setFont(LABEL_FONT);
1718 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
1719 final String tooltip = JvSwingUtils.wrapTooltip(true,
1720 MessageManager.getString("label.double_click_to_browse"));
1721 startupFileTextfield.setToolTipText(tooltip);
1722 startupFileTextfield.addMouseListener(new MouseAdapter()
1725 public void mouseClicked(MouseEvent e)
1727 if (e.getClickCount() > 1)
1729 startupFileTextfield_mouseClicked();
1734 sortby.setFont(LABEL_FONT);
1735 sortby.setBounds(new Rectangle(172, 260, 155, 21));
1736 JLabel sortLabel = new JLabel();
1737 sortLabel.setFont(LABEL_FONT);
1738 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1739 sortLabel.setText(MessageManager.getString("label.sort_by"));
1740 sortAnnBy.setFont(LABEL_FONT);
1741 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
1742 JLabel sortAnnLabel = new JLabel();
1743 sortAnnLabel.setFont(LABEL_FONT);
1744 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1745 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
1746 sortAutocalc.setFont(LABEL_FONT);
1747 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
1749 JPanel annsettingsPanel = new JPanel();
1750 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
1751 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1752 annsettingsPanel.setBorder(new EtchedBorder());
1753 visualTab.add(annsettingsPanel);
1754 Border jb = new EmptyBorder(1, 1, 4, 5);
1755 annotations.setBorder(jb);
1756 showOccupancy.setBorder(jb);
1757 quality.setBorder(jb);
1758 conservation.setBorder(jb);
1759 identity.setBorder(jb);
1760 showConsensbits.setBorder(jb);
1761 showGroupbits.setBorder(jb);
1762 showGroupConsensus.setBorder(jb);
1763 showGroupConservation.setBorder(jb);
1764 showConsensHistogram.setBorder(jb);
1765 showConsensLogo.setBorder(jb);
1767 JPanel autoAnnotSettings = new JPanel();
1768 annsettingsPanel.add(autoAnnotSettings);
1769 autoAnnotSettings.setLayout(new GridLayout(0, 2));
1770 autoAnnotSettings.add(annotations);
1771 autoAnnotSettings.add(quality);
1772 // second row of autoannotation box
1773 autoAnnotSettings = new JPanel();
1774 annsettingsPanel.add(autoAnnotSettings);
1776 autoAnnotSettings.setLayout(new GridLayout(0, 3));
1777 autoAnnotSettings.add(conservation);
1778 autoAnnotSettings.add(identity);
1779 autoAnnotSettings.add(showOccupancy);
1780 autoAnnotSettings.add(showGroupbits);
1781 autoAnnotSettings.add(showGroupConservation);
1782 autoAnnotSettings.add(showGroupConsensus);
1783 autoAnnotSettings.add(showConsensbits);
1784 autoAnnotSettings.add(showConsensHistogram);
1785 autoAnnotSettings.add(showConsensLogo);
1787 JPanel tooltipSettings = new JPanel();
1788 tooltipSettings.setBorder(new TitledBorder(
1789 MessageManager.getString("label.sequence_id_tooltip")));
1790 tooltipSettings.setBounds(173, 140, 220, 62);
1791 tooltipSettings.setLayout(new GridLayout(2, 1));
1792 tooltipSettings.add(showDbRefTooltip);
1793 tooltipSettings.add(showNpTooltip);
1794 visualTab.add(tooltipSettings);
1796 wrap.setFont(LABEL_FONT);
1797 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
1798 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
1799 wrap.setText(MessageManager.getString("label.wrap_alignment"));
1800 rightAlign.setFont(LABEL_FONT);
1801 rightAlign.setForeground(Color.black);
1802 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
1803 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
1804 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
1805 idItalics.setFont(LABEL_FONT_ITALIC);
1806 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
1807 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
1809 MessageManager.getString("label.sequence_name_italics"));
1810 openoverv.setFont(LABEL_FONT);
1811 openoverv.setActionCommand(
1812 MessageManager.getString("label.open_overview"));
1813 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
1814 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
1815 openoverv.setText(MessageManager.getString("label.open_overview"));
1816 JPanel jPanel2 = new JPanel();
1817 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
1818 jPanel2.setLayout(new GridLayout(14, 1));
1819 jPanel2.add(fullScreen);
1820 jPanel2.add(openoverv);
1821 jPanel2.add(seqLimit);
1822 jPanel2.add(rightAlign);
1823 jPanel2.add(fontLabel);
1824 jPanel2.add(showUnconserved);
1825 jPanel2.add(idItalics);
1826 jPanel2.add(smoothFont);
1827 jPanel2.add(scaleProteinToCdna);
1828 jPanel2.add(gapLabel);
1830 jPanel2.add(sortLabel);
1831 jPanel2.add(sortAnnLabel);
1832 jPanel2.add(startupCheckbox);
1833 visualTab.add(jPanel2);
1834 visualTab.add(startupFileTextfield);
1835 visualTab.add(sortby);
1836 visualTab.add(sortAnnBy);
1837 visualTab.add(sortAutocalc);
1838 visualTab.add(gapSymbolCB);
1839 visualTab.add(fontNameCB);
1840 visualTab.add(fontSizeCB);
1841 visualTab.add(fontStyleCB);
1846 * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
1849 protected void loadLastSavedBackupsOptions()
1851 BackupFilesPresetEntry savedPreset = BackupFilesPresetEntry
1852 .getSavedBackupEntry();
1854 .setSelected(Cache.getDefault(BackupFiles.ENABLED, true));
1856 BackupFilesPresetEntry backupfilesCustomEntry = BackupFilesPresetEntry
1857 .createBackupFilesPresetEntry(Cache
1858 .getDefault(BackupFilesPresetEntry.CUSTOMCONFIG, null));
1859 if (backupfilesCustomEntry == null)
1861 backupfilesCustomEntry = BackupFilesPresetEntry.backupfilesPresetEntriesValues
1862 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT);
1864 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
1865 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM,
1866 backupfilesCustomEntry);
1868 setComboIntStringKey(backupfilesPresetsCombo,
1869 Cache.getDefault(BackupFiles.NS + "_PRESET",
1870 BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT));
1872 backupsSetOptions(savedPreset);
1874 backupsOptionsSetEnabled();
1875 updateBackupFilesExampleLabel();
1878 private boolean warnAboutSuffixReverseChange()
1880 BackupFilesPresetEntry bfpe = BackupFilesPresetEntry
1881 .getSavedBackupEntry();
1882 boolean savedSuffixReverse = bfpe.reverse;
1883 int savedSuffixDigits = bfpe.digits;
1884 String savedSuffixTemplate = bfpe.suffix;
1886 boolean nowSuffixReverse = suffixReverse.isSelected();
1887 int nowSuffixDigits = getSpinnerInt(suffixDigitsSpinner, 3);
1888 String nowSuffixTemplate = suffixTemplate.getText();
1889 return nowSuffixReverse != savedSuffixReverse
1890 && nowSuffixDigits == savedSuffixDigits
1891 && nowSuffixTemplate != null
1892 && nowSuffixTemplate.equals(savedSuffixTemplate);
1896 * Initialises the Backups tabbed panel.
1900 private JPanel initBackupsTab()
1902 JPanel backupsTab = new JPanel();
1903 backupsTab.setBorder(new TitledBorder(
1904 MessageManager.getString("label.backup_files")));
1905 backupsTab.setLayout(new GridBagLayout());
1907 GridBagConstraints gbc = new GridBagConstraints();
1910 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1911 gbc.fill = GridBagConstraints.NONE;
1913 initBackupsTabPresetsPanel();
1914 initBackupsTabSuffixPanel();
1915 initBackupsTabKeepFilesPanel();
1916 initBackupsTabFilenameExamplesPanel();
1918 enableBackupFiles.setFont(LABEL_FONT_BOLD);
1920 .setText(MessageManager.getString("label.enable_backupfiles"));
1921 enableBackupFiles.addActionListener(new ActionListener()
1924 public void actionPerformed(ActionEvent e)
1926 // enable other options only when the first is checked
1927 backupsOptionsSetEnabled();
1931 // enable checkbox 1 col
1935 gbc.gridy = 0; // row 0
1936 backupsTab.add(enableBackupFiles, gbc);
1938 // summary of scheme box (over two rows)
1942 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
1943 gbc.fill = GridBagConstraints.BOTH;
1944 backupsTab.add(exampleFilesPanel, gbc);
1946 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1947 gbc.fill = GridBagConstraints.NONE;
1949 // fill empty space on right
1952 backupsTab.add(new JPanel(), gbc);
1957 gbc.gridy++; // row 1
1958 backupsTab.add(presetsPanel, gbc);
1960 // now using whole row
1965 gbc.gridy++; // row 2
1966 backupsTab.add(keepfilesPanel, gbc);
1968 // filename strategy box
1969 gbc.gridy++; // row 3
1970 backupsTab.add(suffixPanel, gbc);
1973 gbc.gridy++; // row 4
1975 backupsTab.add(new JPanel(), gbc);
1977 backupsOptionsSetEnabled();
1981 private JPanel initBackupsTabPresetsPanel()
1984 String title = MessageManager.getString("label.schemes");
1986 presetsPanel.setLayout(new GridBagLayout());
1988 GridBagConstraints gbc = new GridBagConstraints();
1991 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
1992 gbc.fill = GridBagConstraints.NONE;
2000 presetsComboLabel = new JLabel(title + ":");
2001 presetsPanel.add(presetsComboLabel, gbc);
2003 List<Object> entries = Arrays.asList(
2004 (Object[]) BackupFilesPresetEntry.backupfilesPresetEntries);
2005 List<String> tooltips = Arrays.asList(
2006 BackupFilesPresetEntry.backupfilesPresetEntryDescriptions);
2007 backupfilesPresetsCombo = JvSwingUtils.buildComboWithTooltips(entries,
2010 for (int i = 0; i < BackupFilesPresetEntry.backupfilesPresetEntries.length; i++)
2012 backupfilesPresetsCombo
2013 .addItem(BackupFilesPresetEntry.backupfilesPresetEntries[i]);
2017 backupfilesPresetsCombo.addActionListener(new ActionListener()
2020 public void actionPerformed(ActionEvent e)
2022 int key = getComboIntStringKey(backupfilesPresetsCombo);
2023 if (!customiseCheckbox.isSelected())
2025 backupfilesPresetsComboLastSelected = key;
2027 if (key == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
2029 if (customiseCheckbox.isSelected())
2031 // got here by clicking on customiseCheckbox so don't change the
2033 backupfilesCustomOptionsSetEnabled();
2037 backupsTabUpdatePresets();
2038 backupfilesCustomOptionsSetEnabled();
2043 customiseCheckbox.setSelected(false);
2044 backupsTabUpdatePresets();
2045 backupfilesCustomOptionsSetEnabled();
2050 // dropdown list of preset schemes
2052 presetsPanel.add(backupfilesPresetsCombo, gbc);
2054 revertButton.setText(MessageManager.getString("label.cancel_changes"));
2055 revertButton.setToolTipText(
2056 MessageManager.getString("label.cancel_changes_description"));
2057 revertButton.addActionListener(new ActionListener()
2060 public void actionPerformed(ActionEvent e)
2063 BackupFilesPresetEntry.backupfilesPresetEntriesValues.get(
2064 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM));
2065 backupfilesCustomOptionsSetEnabled();
2069 revertButton.setFont(LABEL_FONT);
2071 customiseCheckbox.setFont(LABEL_FONT);
2072 customiseCheckbox.setText(MessageManager.getString("label.customise"));
2073 customiseCheckbox.addActionListener(new ActionListener()
2076 public void actionPerformed(ActionEvent e)
2078 int currently = getComboIntStringKey(backupfilesPresetsCombo);
2079 if (customiseCheckbox.isSelected())
2081 backupfilesPresetsComboLastSelected = currently;
2082 setComboIntStringKey(backupfilesPresetsCombo,
2083 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2087 setComboIntStringKey(backupfilesPresetsCombo,
2088 backupfilesPresetsComboLastSelected);
2091 backupfilesCustomOptionsSetEnabled();
2094 customiseCheckbox.setToolTipText(
2095 MessageManager.getString("label.customise_description"));
2097 // customise checkbox
2100 presetsPanel.add(customiseCheckbox, gbc);
2102 // "Cancel changes" button (aligned with combo box above)
2104 presetsPanel.add(revertButton, gbc);
2106 return presetsPanel;
2109 private JPanel initBackupsTabFilenameExamplesPanel()
2111 String title = MessageManager.getString("label.scheme_examples");
2112 TitledBorder tb = new TitledBorder(title);
2113 exampleFilesPanel.setBorder(tb);
2114 exampleFilesPanel.setLayout(new GridBagLayout());
2116 backupfilesExampleLabel.setEditable(false);
2117 backupfilesExampleLabel
2118 .setBackground(exampleFilesPanel.getBackground());
2120 updateBackupFilesExampleLabel();
2122 GridBagConstraints gbc = new GridBagConstraints();
2125 gbc.fill = GridBagConstraints.NONE;
2126 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2128 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
2129 return exampleFilesPanel;
2132 private void backupsTabUpdatePresets()
2134 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
2137 String value = entry.v;
2139 if (BackupFilesPresetEntry.backupfilesPresetEntriesValues
2143 BackupFilesPresetEntry.backupfilesPresetEntriesValues
2149 "Preset '" + value + "' [key:" + key + "] not implemented");
2152 // Custom options will now be enabled when the customiseCheckbox is checked
2153 // (performed above)
2154 // backupfilesCustomOptionsSetEnabled();
2155 updateBackupFilesExampleLabel();
2158 protected int getComboIntStringKey(
2159 JComboBox<Object> backupfilesPresetsCombo2)
2161 IntKeyStringValueEntry e;
2164 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2
2166 } catch (Exception ex)
2169 "Problem casting Combo entry to IntKeyStringValueEntry.");
2172 return e != null ? e.k : 0;
2175 protected void setComboIntStringKey(
2176 JComboBox<Object> backupfilesPresetsCombo2, int key)
2178 for (int i = 0; i < backupfilesPresetsCombo2.getItemCount(); i++)
2180 IntKeyStringValueEntry e;
2183 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2.getItemAt(i);
2184 } catch (Exception ex)
2187 "Problem casting Combo entry to IntKeyStringValueEntry. Skipping item. ");
2192 backupfilesPresetsCombo2.setSelectedIndex(i);
2196 // backupsTabUpdatePresets();
2199 private JPanel initBackupsTabSuffixPanel()
2201 suffixPanel.setBorder(new TitledBorder(
2202 MessageManager.getString("label.backup_filename_strategy")));
2203 suffixPanel.setLayout(new GridBagLayout());
2206 .setText(MessageManager.getString("label.append_to_filename"));
2207 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
2208 suffixTemplateLabel.setFont(LABEL_FONT);
2210 final String tooltip = JvSwingUtils.wrapTooltip(true,
2211 MessageManager.getString("label.append_to_filename_tooltip"));
2212 suffixTemplate.setToolTipText(tooltip);
2213 suffixTemplate.addActionListener(new ActionListener()
2216 public void actionPerformed(ActionEvent e)
2218 updateBackupFilesExampleLabel();
2219 backupfilesCustomOptionsSetEnabled();
2220 backupfilesRevertButtonSetEnabled(true);
2224 suffixTemplate.addKeyListener(new KeyListener()
2227 public void keyReleased(KeyEvent e)
2229 updateBackupFilesExampleLabel();
2230 backupfilesCustomOptionsSetEnabled();
2231 backupfilesRevertButtonSetEnabled(true);
2235 public void keyPressed(KeyEvent e)
2239 // disable use of ':' or '/' or '\'
2241 public void keyTyped(KeyEvent e)
2243 char c = e.getKeyChar();
2244 if (c == ':' || c == '/' || c == '\\')
2246 // don't process ':' or '/' or '\'
2255 .setText(MessageManager.getString("label.index_digits"));
2256 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
2257 suffixDigitsLabel.setFont(LABEL_FONT);
2258 ChangeListener c = new ChangeListener()
2261 public void stateChanged(ChangeEvent e)
2263 backupfilesRevertButtonSetEnabled(true);
2264 updateBackupFilesExampleLabel();
2268 setIntegerSpinner(suffixDigitsSpinner, BackupFilesPresetEntry.DIGITSMIN,
2269 BackupFilesPresetEntry.DIGITSMAX, 3, c);
2271 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
2272 MessageManager.getString("label.increment_index"));
2273 suffixReverse.addActionListener(new ActionListener()
2276 public void actionPerformed(ActionEvent e)
2278 boolean okay = true;
2279 if (warnAboutSuffixReverseChange())
2282 okay = confirmSuffixReverseChange();
2286 backupfilesRevertButtonSetEnabled(true);
2287 updateBackupFilesExampleLabel();
2291 boolean savedSuffixReverse = BackupFilesPresetEntry
2292 .getSavedBackupEntry().reverse;
2293 suffixReverse.setSelected(savedSuffixReverse);
2298 GridBagConstraints sgbc = new GridBagConstraints();
2300 // first row (template text box)
2301 sgbc.anchor = GridBagConstraints.WEST;
2305 sgbc.gridheight = 1;
2308 sgbc.fill = GridBagConstraints.NONE;
2309 suffixPanel.add(suffixTemplateLabel, sgbc);
2312 sgbc.fill = GridBagConstraints.HORIZONTAL;
2313 suffixPanel.add(suffixTemplate, sgbc);
2315 // second row (number of digits spinner)
2319 sgbc.fill = GridBagConstraints.NONE;
2320 suffixPanel.add(suffixDigitsLabel, sgbc);
2323 sgbc.fill = GridBagConstraints.HORIZONTAL;
2324 suffixPanel.add(suffixDigitsSpinner, sgbc);
2326 // third row (forward order radio selection)
2329 sgbc.gridwidth = GridBagConstraints.REMAINDER;
2330 sgbc.fill = GridBagConstraints.HORIZONTAL;
2331 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
2333 // fourth row (reverse order radio selection)
2335 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
2339 private boolean confirmSuffixReverseChange()
2341 boolean ret = false;
2342 String warningMessage = MessageManager
2343 .getString("label.warning_confirm_change_reverse");
2344 int confirm = JvOptionPane.showConfirmDialog(Desktop.desktop,
2346 MessageManager.getString("label.change_increment_decrement"),
2347 JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE);
2349 ret = (confirm == JvOptionPane.YES_OPTION);
2353 private JPanel initBackupsTabKeepFilesPanel()
2355 keepfilesPanel.setBorder(
2356 new TitledBorder(MessageManager.getString("label.keep_files")));
2357 keepfilesPanel.setLayout(new GridBagLayout());
2359 backupfilesKeepAll.setLabels(
2360 MessageManager.getString("label.keep_all_backup_files"),
2361 MessageManager.getString(
2362 "label.keep_only_this_number_of_backup_files"));
2363 backupfilesKeepAll.addTrueActionListener(new ActionListener()
2366 public void actionPerformed(ActionEvent e)
2368 backupfilesRevertButtonSetEnabled(true);
2369 updateBackupFilesExampleLabel();
2372 backupfilesKeepAll.addActionListener(new ActionListener()
2375 public void actionPerformed(ActionEvent e)
2377 backupfilesRevertButtonSetEnabled(true);
2378 keepRollMaxOptionsEnabled();
2379 updateBackupFilesExampleLabel();
2383 ChangeListener c = new ChangeListener()
2386 public void stateChanged(ChangeEvent e)
2388 backupfilesRevertButtonSetEnabled(true);
2389 updateBackupFilesExampleLabel();
2393 setIntegerSpinner(backupfilesRollMaxSpinner,
2394 BackupFilesPresetEntry.ROLLMAXMIN,
2395 BackupFilesPresetEntry.ROLLMAXMAX, 4, true, c);
2397 backupfilesConfirmDelete.setLabels(
2398 MessageManager.getString("label.always_ask"),
2399 MessageManager.getString("label.auto_delete"));
2400 backupfilesConfirmDelete.addActionListener(new ActionListener()
2403 public void actionPerformed(ActionEvent e)
2405 backupfilesRevertButtonSetEnabled(true);
2408 // update the enabled section
2409 keepRollMaxOptionsEnabled();
2411 GridBagConstraints kgbc = new GridBagConstraints();
2413 // first row (template text box)
2414 kgbc.anchor = GridBagConstraints.WEST;
2417 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2418 kgbc.gridheight = 1;
2421 kgbc.fill = GridBagConstraints.HORIZONTAL;
2422 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
2428 kgbc.gridwidth = GridBagConstraints.RELATIVE;
2429 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
2432 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2433 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
2435 // third row (indented)
2437 kgbc.insets = new Insets(0, 20, 0, 0);
2440 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2441 kgbc.fill = GridBagConstraints.HORIZONTAL;
2444 JPanel jp = new JPanel();
2445 jp.setLayout(new FlowLayout());
2446 oldBackupFilesLabel.setText(
2447 MessageManager.getString("label.autodelete_old_backup_files"));
2448 oldBackupFilesLabel.setFont(LABEL_FONT);
2449 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
2450 jp.add(oldBackupFilesLabel);
2451 jp.add(backupfilesConfirmDelete.getTrueButton());
2452 jp.add(backupfilesConfirmDelete.getFalseButton());
2453 keepfilesPanel.add(jp, kgbc);
2455 return keepfilesPanel;
2458 protected void updateBackupFilesExampleLabel()
2460 int exampleindex = 12;
2461 String base = MessageManager.getString("label.filename") + ".fa";
2462 if (base == null || base.length() == 0)
2464 base = "file_name.fa";
2467 boolean reverse = suffixReverse.isSelected();
2468 boolean keepAll = backupfilesKeepAll.isSelected();
2470 String suffix = suffixTemplate.getText();
2473 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
2474 if (suffix == null || suffix.length() == 0)
2476 backupfilesExampleLabel
2477 .setText(MessageManager.getString("label.no_backup_files"));
2478 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
2482 rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 4);
2483 rollMax = rollMax < 1 ? 1 : rollMax;
2485 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
2490 digits = getSpinnerInt(suffixDigitsSpinner, 3);
2491 digits = digits < 1 ? 1 : digits;
2493 int lowersurround = 2;
2494 int uppersurround = 0;
2495 StringBuilder exampleSB = new StringBuilder();
2496 boolean firstLine = true;
2502 int max = keepAll ? exampleindex : rollMax;
2503 for (int index = min; index <= max; index++)
2505 if (index == min + lowersurround && index < max - uppersurround - 1)
2507 exampleSB.append("\n...");
2510 else if (index > min + lowersurround && index < max - uppersurround)
2522 exampleSB.append("\n");
2525 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2526 base, suffix, digits));
2529 // no extra text needed
2531 else if (index == min)
2533 String newest = MessageManager.getString("label.braced_newest");
2534 if (newest != null && newest.length() > 0)
2536 exampleSB.append(" " + newest);
2539 else if (index == max)
2541 String oldest = MessageManager.getString("label.braced_oldest");
2542 if (oldest != null && oldest.length() > 0)
2544 exampleSB.append(" " + oldest);
2553 int min = (keepAll || exampleindex - rollMax < 0) ? 1
2554 : exampleindex - rollMax + 1;
2555 int max = exampleindex;
2557 for (int index = min; index <= max; index++)
2560 if (index == min + lowersurround && index < max - uppersurround - 1)
2562 exampleSB.append("\n...");
2565 else if (index > min + lowersurround && index < max - uppersurround)
2577 exampleSB.append("\n");
2580 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2581 base, suffix, digits));
2584 // no extra text needed
2586 else if (index == min)
2588 String oldest = MessageManager.getString("label.braced_oldest");
2589 if (oldest != null && oldest.length() > 0)
2591 exampleSB.append(" " + oldest);
2594 else if (index == max)
2596 String newest = MessageManager.getString("label.braced_newest");
2597 if (newest != null && newest.length() > 0)
2599 exampleSB.append(" " + newest);
2607 // add some extra empty lines to pad out the example files box. ugh, please
2609 // me how to do this better
2610 int remainingLines = lowersurround + uppersurround + 1 - lineNumber;
2611 if (remainingLines > 0)
2613 for (int i = 0; i < remainingLines; i++)
2615 exampleSB.append("\n ");
2620 backupfilesExampleLabel.setText(exampleSB.toString());
2623 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2624 boolean useExistingVal, ChangeListener c)
2631 i = ((Integer) s.getValue()).intValue();
2632 } catch (Exception e)
2635 "Exception casting the initial value of s.getValue()");
2639 setIntegerSpinner(s, min, max, i, c);
2642 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2645 // integer spinner for number of digits
2654 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
2657 s.addChangeListener(c);
2661 protected static int getSpinnerInt(JSpinner s, int def)
2667 i = (Integer) s.getValue();
2668 } catch (Exception e)
2670 Cache.log.error("Failed casting (Integer) JSpinner s.getValue()");
2675 private void keepRollMaxOptionsEnabled()
2677 boolean enabled = backupfilesKeepAll.isEnabled()
2678 && !backupfilesKeepAll.isSelected();
2679 oldBackupFilesLabel.setEnabled(enabled);
2680 backupfilesRollMaxSpinner.setEnabled(enabled);
2681 backupfilesConfirmDelete.setEnabled(enabled);
2684 private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
2686 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2687 && customiseCheckbox.isSelected() && suffixTemplate.getText()
2688 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2689 keepfilesPanel.setEnabled(enabled);
2690 backupfilesKeepAll.setEnabled(enabled);
2691 oldBackupFilesLabel.setEnabled(enabled);
2692 keepRollMaxOptionsEnabled();
2695 private void backupfilesSuffixTemplateDigitsSetEnabled()
2697 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
2698 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2699 suffixDigitsLabel.setEnabled(enabled);
2700 suffixDigitsSpinner.setEnabled(enabled);
2701 suffixReverse.setEnabled(enabled);
2704 private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
2706 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2707 && customiseCheckbox.isSelected();
2708 suffixPanel.setEnabled(enabled);
2709 suffixTemplateLabel.setEnabled(enabled);
2710 suffixTemplate.setEnabled(enabled);
2711 backupfilesSuffixTemplateDigitsSetEnabled();
2714 private void backupfilesRevertButtonSetEnabled(boolean tryEnabled)
2716 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2717 && customiseCheckbox.isSelected() && backupfilesCustomChanged();
2718 revertButton.setEnabled(enabled);
2721 private boolean backupfilesCustomChanged()
2723 BackupFilesPresetEntry custom = BackupFilesPresetEntry.backupfilesPresetEntriesValues
2724 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2725 BackupFilesPresetEntry current = getBackupfilesCurrentEntry();
2726 return !custom.equals(current);
2729 protected BackupFilesPresetEntry getBackupfilesCurrentEntry()
2731 String suffix = suffixTemplate.getText();
2732 int digits = getSpinnerInt(suffixDigitsSpinner, 3);
2733 boolean reverse = suffixReverse.isSelected();
2734 boolean keepAll = backupfilesKeepAll.isSelected();
2735 int rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 3);
2736 boolean confirmDelete = backupfilesConfirmDelete.isSelected();
2738 BackupFilesPresetEntry bfpe = new BackupFilesPresetEntry(suffix, digits,
2739 reverse, keepAll, rollMax, confirmDelete);
2744 protected void backupfilesCustomOptionsSetEnabled()
2746 boolean enabled = customiseCheckbox.isSelected();
2748 backupfilesRevertButtonSetEnabled(enabled);
2749 backupfilesSuffixTemplateSetEnabled(enabled);
2750 backupfilesKeepAllSetEnabled(enabled);
2753 private void backupfilesSummarySetEnabled()
2755 boolean enabled = enableBackupFiles.isSelected();
2756 backupfilesExampleLabel.setEnabled(enabled);
2757 exampleFilesPanel.setEnabled(enabled);
2760 private void backupfilesPresetsSetEnabled()
2762 boolean enabled = enableBackupFiles.isSelected();
2763 presetsPanel.setEnabled(enabled);
2764 presetsComboLabel.setEnabled(enabled);
2765 backupfilesPresetsCombo.setEnabled(enabled);
2766 customiseCheckbox.setEnabled(enabled);
2767 revertButton.setEnabled(enabled);
2770 protected void backupsOptionsSetEnabled()
2772 backupfilesPresetsSetEnabled();
2773 backupfilesSummarySetEnabled();
2774 backupfilesCustomOptionsSetEnabled();
2777 protected void backupsSetOptions(String suffix, int digits,
2778 boolean reverse, boolean keepAll, int rollMax,
2779 boolean confirmDelete)
2781 suffixTemplate.setText(suffix);
2782 suffixDigitsSpinner.setValue(digits);
2783 suffixReverse.setSelected(reverse);
2784 backupfilesKeepAll.setSelected(keepAll);
2785 backupfilesRollMaxSpinner.setValue(rollMax);
2786 backupfilesConfirmDelete.setSelected(confirmDelete);
2789 protected void backupsSetOptions(BackupFilesPresetEntry p)
2791 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
2795 protected void autoIdWidth_actionPerformed()
2797 // TODO Auto-generated method stub
2801 protected void userIdWidth_actionPerformed()
2803 // TODO Auto-generated method stub
2807 protected void maxColour_actionPerformed(JPanel panel)
2811 protected void minColour_actionPerformed(JPanel panel)
2815 protected void gapColour_actionPerformed(JPanel panel)
2819 protected void hiddenColour_actionPerformed(JPanel panel)
2823 protected void showunconserved_actionPerformed(ActionEvent e)
2825 // TODO Auto-generated method stub
2829 protected void useLegacyGaps_actionPerformed(ActionEvent e)
2833 protected void resetOvDefaults_actionPerformed(ActionEvent e)
2843 public void ok_actionPerformed(ActionEvent e)
2853 public void cancel_actionPerformed(ActionEvent e)
2863 public void annotations_actionPerformed(ActionEvent e)
2870 public void startupFileTextfield_mouseClicked()
2874 public void newLink_actionPerformed(ActionEvent e)
2879 public void editLink_actionPerformed(ActionEvent e)
2884 public void deleteLink_actionPerformed(ActionEvent e)
2889 public void defaultBrowser_mouseClicked(MouseEvent e)
2894 public void linkURLList_keyTyped(KeyEvent e)
2899 public void customProxy_actionPerformed()
2901 boolean enabled = customProxy.isSelected();
2902 portLabel.setEnabled(enabled);
2903 serverLabel.setEnabled(enabled);
2904 httpLabel.setEnabled(enabled);
2905 httpsLabel.setEnabled(enabled);
2906 proxyServerHttpTB.setEnabled(enabled);
2907 proxyPortHttpTB.setEnabled(enabled);
2908 proxyServerHttpsTB.setEnabled(enabled);
2909 proxyPortHttpsTB.setEnabled(enabled);
2913 * Customer renderer for JTable: supports column of radio buttons
2915 public class RadioButtonRenderer extends JRadioButton
2916 implements TableCellRenderer
2918 public RadioButtonRenderer()
2920 setHorizontalAlignment(CENTER);
2921 setToolTipText(MessageManager.getString("label.urltooltip"));
2925 public Component getTableCellRendererComponent(JTable table,
2926 Object value, boolean isSelected, boolean hasFocus, int row,
2929 setSelected((boolean) value);
2931 // set colours to match rest of table
2934 setBackground(table.getSelectionBackground());
2935 setForeground(table.getSelectionForeground());
2939 setBackground(table.getBackground());
2940 setForeground(table.getForeground());
2947 * Customer cell editor for JTable: supports column of radio buttons in
2948 * conjunction with renderer
2950 public class RadioButtonEditor extends AbstractCellEditor
2951 implements TableCellEditor
2953 private JRadioButton button = new JRadioButton();
2955 public RadioButtonEditor()
2957 button.setHorizontalAlignment(SwingConstants.CENTER);
2958 this.button.addActionListener(new ActionListener()
2961 public void actionPerformed(ActionEvent e)
2963 fireEditingStopped();
2969 public Component getTableCellEditorComponent(JTable table, Object value,
2970 boolean isSelected, int row, int column)
2972 button.setSelected((boolean) value);
2977 public Object getCellEditorValue()
2979 return button.isSelected();