2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.jbgui;
23 import java.awt.BorderLayout;
24 import java.awt.Color;
25 import java.awt.Component;
26 import java.awt.Dimension;
27 import java.awt.FlowLayout;
29 import java.awt.GridBagConstraints;
30 import java.awt.GridBagLayout;
31 import java.awt.GridLayout;
32 import java.awt.Insets;
33 import java.awt.Rectangle;
34 import java.awt.event.ActionEvent;
35 import java.awt.event.ActionListener;
36 import java.awt.event.FocusEvent;
37 import java.awt.event.KeyEvent;
38 import java.awt.event.KeyListener;
39 import java.awt.event.MouseAdapter;
40 import java.awt.event.MouseEvent;
41 import java.util.Arrays;
42 import java.util.List;
44 import javax.swing.AbstractCellEditor;
45 import javax.swing.BorderFactory;
46 import javax.swing.ButtonGroup;
47 import javax.swing.DefaultListCellRenderer;
48 import javax.swing.JButton;
49 import javax.swing.JCheckBox;
50 import javax.swing.JComboBox;
51 import javax.swing.JFileChooser;
52 import javax.swing.JLabel;
53 import javax.swing.JPanel;
54 import javax.swing.JPasswordField;
55 import javax.swing.JRadioButton;
56 import javax.swing.JScrollPane;
57 import javax.swing.JSpinner;
58 import javax.swing.JTabbedPane;
59 import javax.swing.JTable;
60 import javax.swing.JTextArea;
61 import javax.swing.JTextField;
62 import javax.swing.ListSelectionModel;
63 import javax.swing.SpinnerModel;
64 import javax.swing.SpinnerNumberModel;
65 import javax.swing.SwingConstants;
66 import javax.swing.border.Border;
67 import javax.swing.border.EmptyBorder;
68 import javax.swing.border.EtchedBorder;
69 import javax.swing.border.TitledBorder;
70 import javax.swing.event.ChangeEvent;
71 import javax.swing.event.ChangeListener;
72 import javax.swing.table.TableCellEditor;
73 import javax.swing.table.TableCellRenderer;
75 import jalview.bin.Cache;
76 import jalview.fts.core.FTSDataColumnPreferences;
77 import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource;
78 import jalview.fts.service.pdb.PDBFTSRestClient;
79 import jalview.gui.Desktop;
80 import jalview.gui.JalviewBooleanRadioButtons;
81 import jalview.gui.JvOptionPane;
82 import jalview.gui.JvSwingUtils;
83 import jalview.gui.StructureViewer.ViewerType;
84 import jalview.io.BackupFilenameParts;
85 import jalview.io.BackupFiles;
86 import jalview.io.BackupFilesPresetEntry;
87 import jalview.io.IntKeyStringValueEntry;
88 import jalview.util.MessageManager;
91 * Base class for the Preferences panel.
96 public class GPreferences extends JPanel
98 private static final Font LABEL_FONT = JvSwingUtils.getLabelFont();
100 private static final Font LABEL_FONT_ITALIC = JvSwingUtils
101 .getLabelFont(false, true);
103 private static final Font LABEL_FONT_BOLD = JvSwingUtils
104 .getLabelFont(true, false);
107 * Visual tab components
109 protected JCheckBox fullScreen = new JCheckBox();
111 protected JCheckBox openoverv = new JCheckBox();
113 protected JCheckBox seqLimit = new JCheckBox();
115 protected JCheckBox rightAlign = new JCheckBox();
117 protected JComboBox<String> fontSizeCB = new JComboBox<>();
119 protected JComboBox<String> fontStyleCB = new JComboBox<>();
121 protected JComboBox<String> fontNameCB = new JComboBox<>();
123 protected JCheckBox showOccupancy = new JCheckBox();
125 protected JCheckBox showUnconserved = new JCheckBox();
127 protected JCheckBox idItalics = new JCheckBox();
129 protected JCheckBox smoothFont = new JCheckBox();
131 protected JCheckBox scaleProteinToCdna = new JCheckBox();
133 protected JComboBox<String> gapSymbolCB = new JComboBox<>();
135 protected JCheckBox wrap = new JCheckBox();
137 protected JComboBox<String> sortby = new JComboBox<>();
139 protected JComboBox<String> sortAnnBy = new JComboBox<>();
141 protected JComboBox<String> sortAutocalc = new JComboBox<>();
143 protected JCheckBox startupCheckbox = new JCheckBox();
145 protected JTextField startupFileTextfield = new JTextField();
147 // below are in the 'second column'
148 protected JCheckBox annotations = new JCheckBox();
150 protected JCheckBox quality = new JCheckBox();
152 protected JCheckBox conservation = new JCheckBox();
154 protected JCheckBox identity = new JCheckBox();
156 protected JCheckBox showGroupConsensus = new JCheckBox();
158 protected JCheckBox showGroupConservation = new JCheckBox();
160 protected JCheckBox showConsensHistogram = new JCheckBox();
162 protected JCheckBox showConsensLogo = new JCheckBox();
164 protected JCheckBox showDbRefTooltip = new JCheckBox();
166 protected JCheckBox showNpTooltip = new JCheckBox();
169 * Structure tab and components
171 protected JPanel structureTab;
173 protected JCheckBox structFromPdb = new JCheckBox();
175 protected JCheckBox useRnaView = new JCheckBox();
177 protected JCheckBox addSecondaryStructure = new JCheckBox();
179 protected JCheckBox addTempFactor = new JCheckBox();
181 protected JComboBox<String> structViewer = new JComboBox<>();
183 protected JTextField chimeraPath = new JTextField();
185 protected ButtonGroup mappingMethod = new ButtonGroup();
187 protected JRadioButton siftsMapping = new JRadioButton();
189 protected JRadioButton nwMapping = new JRadioButton();
192 * Colours tab components
194 protected JPanel minColour = new JPanel();
196 protected JPanel maxColour = new JPanel();
198 protected JComboBox<String> protColour = new JComboBox<>();
200 protected JComboBox<String> nucColour = new JComboBox<>();
203 * Overview tab components
205 protected JPanel gapColour = new JPanel();
207 protected JPanel hiddenColour = new JPanel();
209 protected JCheckBox useLegacyGap;
211 protected JCheckBox showHiddenAtStart;
213 protected JLabel gapLabel;
216 * Connections tab components
218 protected JTable linkUrlTable = new JTable();
220 protected JButton editLink = new JButton();
222 protected JButton deleteLink = new JButton();
224 protected JTextField filterTB = new JTextField();
226 protected JButton doReset = new JButton();
228 protected JButton userOnly = new JButton();
230 protected JLabel httpLabel = new JLabel();
232 protected JLabel httpsLabel = new JLabel();
234 protected JLabel portLabel = new JLabel();
236 protected JLabel serverLabel = new JLabel();
238 protected JLabel portLabel2 = new JLabel();
240 protected JLabel serverLabel2 = new JLabel();
242 protected JLabel proxyAuthUsernameLabel = new JLabel();
244 protected JLabel proxyAuthPasswordLabel = new JLabel();
246 protected JTextField proxyServerHttpTB = new JTextField();
248 protected JTextField proxyPortHttpTB = new JTextField();
250 protected JTextField proxyServerHttpsTB = new JTextField();
252 protected JTextField proxyPortHttpsTB = new JTextField();
254 protected JCheckBox proxyAuth = new JCheckBox();
256 protected JTextField proxyAuthUsernameTB = new JTextField();
258 protected JTextField proxyAuthPasswordTB = new JPasswordField();
260 protected JTextField defaultBrowser = new JTextField();
262 protected ButtonGroup proxyType = new ButtonGroup();
264 protected JRadioButton noProxy = new JRadioButton();
266 protected JRadioButton systemProxy = new JRadioButton();
268 protected JRadioButton customProxy = new JRadioButton();
270 protected JCheckBox usagestats = new JCheckBox();
272 protected JCheckBox questionnaire = new JCheckBox();
274 protected JCheckBox versioncheck = new JCheckBox();
277 * Output tab components
279 protected JComboBox<Object> epsRendering = new JComboBox<>();
281 protected JLabel userIdWidthlabel = new JLabel();
283 protected JCheckBox autoIdWidth = new JCheckBox();
285 protected JTextField userIdWidth = new JTextField();
287 protected JCheckBox blcjv = new JCheckBox();
289 protected JCheckBox pileupjv = new JCheckBox();
291 protected JCheckBox clustaljv = new JCheckBox();
293 protected JCheckBox msfjv = new JCheckBox();
295 protected JCheckBox fastajv = new JCheckBox();
297 protected JCheckBox pfamjv = new JCheckBox();
299 protected JCheckBox pirjv = new JCheckBox();
301 protected JCheckBox modellerOutput = new JCheckBox();
303 protected JCheckBox embbedBioJSON = new JCheckBox();
306 * Editing tab components
308 protected JCheckBox autoCalculateConsCheck = new JCheckBox();
310 protected JCheckBox padGaps = new JCheckBox();
312 protected JCheckBox sortByTree = new JCheckBox();
317 protected JPanel wsTab = new JPanel();
320 * Backups tab components
321 * a lot of these are member variables instead of local variables only so that they
322 * can be enabled/disabled easily in one go
325 protected JCheckBox enableBackupFiles = new JCheckBox();
327 protected JPanel presetsPanel = new JPanel();
329 protected JLabel presetsComboLabel = new JLabel();
331 protected JCheckBox customiseCheckbox = new JCheckBox();
333 protected JButton revertButton = new JButton();
335 protected JComboBox<Object> backupfilesPresetsCombo = new JComboBox<>();
337 private int backupfilesPresetsComboLastSelected = 0;
339 protected JPanel suffixPanel = new JPanel();
341 protected JPanel keepfilesPanel = new JPanel();
343 protected JPanel exampleFilesPanel = new JPanel();
345 protected JTextField suffixTemplate = new JTextField(null, 8);
347 protected JLabel suffixTemplateLabel = new JLabel();
349 protected JLabel suffixDigitsLabel = new JLabel();
351 protected JSpinner suffixDigitsSpinner = new JSpinner();
353 protected JalviewBooleanRadioButtons suffixReverse = new JalviewBooleanRadioButtons();
355 protected JalviewBooleanRadioButtons backupfilesKeepAll = new JalviewBooleanRadioButtons();
357 public JSpinner backupfilesRollMaxSpinner = new JSpinner();
359 protected JLabel oldBackupFilesLabel = new JLabel();
361 protected JalviewBooleanRadioButtons backupfilesConfirmDelete = new JalviewBooleanRadioButtons();
363 protected JTextArea backupfilesExampleLabel = new JTextArea();
366 * Creates a new GPreferences object.
368 public GPreferences()
373 } catch (Exception ex)
375 ex.printStackTrace();
380 * Construct the panel and its tabbed sub-panels.
384 private void jbInit() throws Exception
386 final JTabbedPane tabbedPane = new JTabbedPane();
387 this.setLayout(new BorderLayout());
388 JPanel okCancelPanel = initOkCancelPanel();
389 this.add(tabbedPane, BorderLayout.CENTER);
390 this.add(okCancelPanel, BorderLayout.SOUTH);
392 tabbedPane.add(initVisualTab(),
393 MessageManager.getString("label.visual"));
395 tabbedPane.add(initColoursTab(),
396 MessageManager.getString("label.colours"));
398 tabbedPane.add(initOverviewTab(),
399 MessageManager.getString("label.overview"));
401 tabbedPane.add(initStructureTab(),
402 MessageManager.getString("label.structure"));
404 tabbedPane.add(initConnectionsTab(),
405 MessageManager.getString("label.connections"));
407 tabbedPane.add(initBackupsTab(),
408 MessageManager.getString("label.backups"));
410 tabbedPane.add(initLinksTab(),
411 MessageManager.getString("label.urllinks"));
413 tabbedPane.add(initOutputTab(),
414 MessageManager.getString("label.output"));
416 tabbedPane.add(initEditingTab(),
417 MessageManager.getString("label.editing"));
420 * See WsPreferences for the real work of configuring this tab.
422 wsTab.setLayout(new BorderLayout());
423 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
426 * Handler to validate a tab before leaving it - currently only for
429 tabbedPane.addChangeListener(new ChangeListener()
431 private Component lastTab;
434 public void stateChanged(ChangeEvent e)
436 if (lastTab == structureTab
437 && tabbedPane.getSelectedComponent() != structureTab)
439 if (!validateStructure())
441 tabbedPane.setSelectedComponent(structureTab);
445 lastTab = tabbedPane.getSelectedComponent();
452 * Initialises the Editing tabbed panel.
456 private JPanel initEditingTab()
458 JPanel editingTab = new JPanel();
459 editingTab.setLayout(null);
460 autoCalculateConsCheck.setFont(LABEL_FONT);
461 autoCalculateConsCheck.setText(
462 MessageManager.getString("label.autocalculate_consensus"));
463 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
464 padGaps.setFont(LABEL_FONT);
466 MessageManager.getString("label.pad_gaps_when_editing"));
467 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
468 sortByTree.setFont(LABEL_FONT);
470 .setText(MessageManager.getString("label.sort_with_new_tree"));
471 sortByTree.setToolTipText(MessageManager.getString(
472 "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
473 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
474 editingTab.add(autoCalculateConsCheck);
475 editingTab.add(padGaps);
476 editingTab.add(sortByTree);
481 * Initialises the Output tabbed panel.
485 private JPanel initOutputTab()
487 JPanel outputTab = new JPanel();
488 outputTab.setLayout(null);
489 JLabel epsLabel = new JLabel();
490 epsLabel.setFont(LABEL_FONT);
491 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
492 epsLabel.setText(MessageManager.getString("label.eps_rendering_style"));
493 epsLabel.setBounds(new Rectangle(9, 31, 140, 24));
494 epsRendering.setFont(LABEL_FONT);
495 epsRendering.setBounds(new Rectangle(154, 34, 187, 21));
496 JLabel jLabel1 = new JLabel();
497 jLabel1.setFont(LABEL_FONT);
498 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
499 jLabel1.setText(MessageManager.getString("label.append_start_end"));
500 jLabel1.setFont(LABEL_FONT);
501 fastajv.setFont(LABEL_FONT);
502 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
503 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
504 blcjv.setText(MessageManager.getString("label.blc") + " ");
505 fastajv.setText(MessageManager.getString("label.fasta") + " ");
506 msfjv.setText(MessageManager.getString("label.msf") + " ");
507 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
508 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
509 msfjv.setFont(LABEL_FONT);
510 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
511 pirjv.setText(MessageManager.getString("label.pir") + " ");
512 JPanel jPanel11 = new JPanel();
513 jPanel11.setFont(LABEL_FONT);
514 TitledBorder titledBorder2 = new TitledBorder(
515 MessageManager.getString("label.file_output"));
516 jPanel11.setBorder(titledBorder2);
517 jPanel11.setBounds(new Rectangle(30, 72, 196, 182));
518 GridLayout gridLayout3 = new GridLayout();
519 jPanel11.setLayout(gridLayout3);
520 gridLayout3.setRows(8);
521 blcjv.setFont(LABEL_FONT);
522 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
523 clustaljv.setFont(LABEL_FONT);
524 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
525 pfamjv.setFont(LABEL_FONT);
526 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
527 pileupjv.setFont(LABEL_FONT);
528 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
529 pirjv.setFont(LABEL_FONT);
530 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
531 autoIdWidth.setFont(LABEL_FONT);
533 MessageManager.getString("label.automatically_set_id_width"));
534 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
535 .getString("label.adjusts_width_generated_eps_png")));
536 autoIdWidth.setBounds(new Rectangle(228, 96, 188, 23));
537 autoIdWidth.addActionListener(new ActionListener()
541 public void actionPerformed(ActionEvent e)
543 autoIdWidth_actionPerformed();
546 userIdWidthlabel.setFont(LABEL_FONT);
547 userIdWidthlabel.setText(
548 MessageManager.getString("label.figure_id_column_width"));
549 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
550 .getString("label.manually_specify_width_left_column")));
551 userIdWidthlabel.setToolTipText(
552 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
553 "label.manually_specify_width_left_column")));
554 userIdWidthlabel.setBounds(new Rectangle(236, 120, 168, 23));
555 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
556 userIdWidth.setText("");
557 userIdWidth.setBounds(new Rectangle(232, 144, 84, 23));
558 userIdWidth.addActionListener(new ActionListener()
562 public void actionPerformed(ActionEvent e)
564 userIdWidth_actionPerformed();
567 modellerOutput.setFont(LABEL_FONT);
569 .setText(MessageManager.getString("label.use_modeller_output"));
570 modellerOutput.setBounds(new Rectangle(228, 226, 168, 23));
571 embbedBioJSON.setFont(LABEL_FONT);
572 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
573 embbedBioJSON.setBounds(new Rectangle(228, 200, 250, 23));
575 jPanel11.add(jLabel1);
577 jPanel11.add(clustaljv);
578 jPanel11.add(fastajv);
580 jPanel11.add(pfamjv);
581 jPanel11.add(pileupjv);
583 outputTab.add(autoIdWidth);
584 outputTab.add(userIdWidth);
585 outputTab.add(userIdWidthlabel);
586 outputTab.add(modellerOutput);
587 outputTab.add(embbedBioJSON);
588 outputTab.add(epsLabel);
589 outputTab.add(epsRendering);
590 outputTab.add(jPanel11);
595 * Initialises the Connections tabbed panel.
599 private JPanel initConnectionsTab()
601 JPanel connectTab = new JPanel();
602 connectTab.setLayout(new GridBagLayout());
604 // Label for browser text box
605 JLabel browserLabel = new JLabel();
606 browserLabel.setFont(LABEL_FONT);
607 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
608 browserLabel.setText(
609 MessageManager.getString("label.default_browser_unix"));
610 defaultBrowser.setFont(LABEL_FONT);
611 defaultBrowser.setText("");
612 final String tooltip = JvSwingUtils.wrapTooltip(true,
613 MessageManager.getString("label.double_click_to_browse"));
614 defaultBrowser.setToolTipText(tooltip);
615 defaultBrowser.addMouseListener(new MouseAdapter()
618 public void mouseClicked(MouseEvent e)
620 if (e.getClickCount() > 1)
622 defaultBrowser_mouseClicked(e);
627 JPanel proxyPanel = initConnTabProxyPanel();
628 initConnTabCheckboxes();
630 // Add default Browser text box
631 connectTab.add(browserLabel,
632 new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
633 GridBagConstraints.WEST, GridBagConstraints.NONE,
634 new Insets(10, 0, 5, 5), 5, 1));
635 defaultBrowser.setFont(LABEL_FONT);
636 defaultBrowser.setText("");
638 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
639 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
640 new Insets(10, 0, 5, 10), 30, 1));
642 // Add proxy server panel
643 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
644 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
645 new Insets(10, 0, 5, 12), 4, 10));
647 // Add usage stats, version check and questionnaire checkboxes
648 connectTab.add(usagestats,
649 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
650 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
651 new Insets(0, 2, 5, 5), 70, 1));
652 connectTab.add(questionnaire,
653 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
654 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
655 new Insets(0, 2, 5, 10), 70, 1));
656 connectTab.add(versioncheck,
657 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
658 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
659 new Insets(0, 2, 5, 5), 70, 1));
661 versioncheck.setVisible(false);
663 // Add padding so the panel doesn't look ridiculous
664 JPanel spacePanel = new JPanel();
665 connectTab.add(spacePanel,
666 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
667 GridBagConstraints.WEST, GridBagConstraints.BOTH,
668 new Insets(0, 0, 0, 5), 70, 1));
674 * Initialises the Links tabbed panel.
678 private JPanel initLinksTab()
680 JPanel linkTab = new JPanel();
681 linkTab.setLayout(new GridBagLayout());
683 // Set up table for Url links
684 linkUrlTable.getTableHeader().setReorderingAllowed(false);
685 linkUrlTable.setFillsViewportHeight(true);
686 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
687 linkUrlTable.setAutoCreateRowSorter(true);
688 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
690 // adjust row height so radio buttons actually fit
691 // don't do this in the renderer, it causes the awt thread to activate
693 JRadioButton temp = new JRadioButton();
694 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
696 // Table in scrollpane so that the table is given a scrollbar
697 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
698 linkScrollPane.setBorder(null);
700 // Panel for links functionality
701 JPanel linkPanel = new JPanel(new GridBagLayout());
702 linkPanel.setBorder(new TitledBorder(
703 MessageManager.getString("label.url_linkfrom_sequence_id")));
705 // Put the Url links panel together
707 // Buttons go at top right, resizing only resizes the blank space vertically
708 JPanel buttonPanel = initLinkTabUrlButtons();
709 GridBagConstraints linkConstraints1 = new GridBagConstraints();
710 linkConstraints1.insets = new Insets(0, 0, 5, 0);
711 linkConstraints1.gridx = 0;
712 linkConstraints1.gridy = 0;
713 linkConstraints1.weightx = 1.0;
714 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
715 linkTab.add(buttonPanel, linkConstraints1);
717 // Links table goes at top left, resizing resizes the table
718 GridBagConstraints linkConstraints2 = new GridBagConstraints();
719 linkConstraints2.insets = new Insets(0, 0, 5, 5);
720 linkConstraints2.gridx = 0;
721 linkConstraints2.gridy = 1;
722 linkConstraints2.weightx = 1.0;
723 linkConstraints2.weighty = 1.0;
724 linkConstraints2.fill = GridBagConstraints.BOTH;
725 linkTab.add(linkScrollPane, linkConstraints2);
727 // Filter box and buttons goes at bottom left, resizing resizes the text box
728 JPanel filterPanel = initLinkTabFilterPanel();
729 GridBagConstraints linkConstraints3 = new GridBagConstraints();
730 linkConstraints3.insets = new Insets(0, 0, 0, 5);
731 linkConstraints3.gridx = 0;
732 linkConstraints3.gridy = 2;
733 linkConstraints3.weightx = 1.0;
734 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
735 linkTab.add(filterPanel, linkConstraints3);
740 private JPanel initLinkTabFilterPanel()
742 // Filter textbox and reset button
743 JLabel filterLabel = new JLabel(
744 MessageManager.getString("label.filter"));
745 filterLabel.setFont(LABEL_FONT);
746 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
747 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
749 filterTB.setFont(LABEL_FONT);
750 filterTB.setText("");
752 doReset.setText(MessageManager.getString("action.showall"));
753 userOnly.setText(MessageManager.getString("action.customfilter"));
755 // Panel for filter functionality
756 JPanel filterPanel = new JPanel(new GridBagLayout());
757 filterPanel.setBorder(new TitledBorder("Filter"));
758 GridBagConstraints gbc = new GridBagConstraints();
761 gbc.fill = GridBagConstraints.NONE;
762 gbc.anchor = GridBagConstraints.WEST;
764 filterPanel.add(filterLabel, gbc);
766 GridBagConstraints gbc1 = new GridBagConstraints();
769 gbc1.fill = GridBagConstraints.HORIZONTAL;
770 gbc1.anchor = GridBagConstraints.WEST;
772 filterPanel.add(filterTB, gbc1);
774 GridBagConstraints gbc2 = new GridBagConstraints();
776 gbc2.fill = GridBagConstraints.NONE;
777 gbc2.anchor = GridBagConstraints.WEST;
778 filterPanel.add(doReset, gbc2);
780 GridBagConstraints gbc3 = new GridBagConstraints();
782 gbc3.fill = GridBagConstraints.NONE;
783 gbc3.anchor = GridBagConstraints.WEST;
784 filterPanel.add(userOnly, gbc3);
789 private JPanel initLinkTabUrlButtons()
791 // Buttons for new / edit / delete Url links
792 JButton newLink = new JButton();
793 newLink.setText(MessageManager.getString("action.new"));
795 editLink.setText(MessageManager.getString("action.edit"));
797 deleteLink.setText(MessageManager.getString("action.delete"));
799 // no current selection, so initially disable delete/edit buttons
800 editLink.setEnabled(false);
801 deleteLink.setEnabled(false);
803 newLink.addActionListener(new java.awt.event.ActionListener()
806 public void actionPerformed(ActionEvent e)
808 newLink_actionPerformed(e);
812 editLink.setText(MessageManager.getString("action.edit"));
813 editLink.addActionListener(new java.awt.event.ActionListener()
816 public void actionPerformed(ActionEvent e)
818 editLink_actionPerformed(e);
822 deleteLink.setText(MessageManager.getString("action.delete"));
823 deleteLink.addActionListener(new java.awt.event.ActionListener()
826 public void actionPerformed(ActionEvent e)
828 deleteLink_actionPerformed(e);
832 JPanel buttonPanel = new JPanel(new GridBagLayout());
833 buttonPanel.setBorder(new TitledBorder("Edit links"));
834 GridBagConstraints gbc = new GridBagConstraints();
837 gbc.fill = GridBagConstraints.NONE;
838 buttonPanel.add(newLink, gbc);
840 GridBagConstraints gbc1 = new GridBagConstraints();
843 gbc1.fill = GridBagConstraints.NONE;
844 buttonPanel.add(editLink, gbc1);
846 GridBagConstraints gbc2 = new GridBagConstraints();
849 gbc2.fill = GridBagConstraints.NONE;
850 buttonPanel.add(deleteLink, gbc2);
852 GridBagConstraints gbc3 = new GridBagConstraints();
855 gbc3.fill = GridBagConstraints.HORIZONTAL;
857 JPanel spacePanel = new JPanel();
858 spacePanel.setBorder(null);
859 buttonPanel.add(spacePanel, gbc3);
865 * Initialises the proxy server panel in the Connections tab
867 * @return the proxy server panel
869 private JPanel initConnTabProxyPanel()
871 // Label for server text box
872 serverLabel.setText(MessageManager.getString("label.host") + ": ");
873 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
874 serverLabel.setFont(LABEL_FONT);
875 serverLabel2.setText(MessageManager.getString("label.host") + ": ");
876 serverLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
877 serverLabel2.setFont(LABEL_FONT);
879 // Proxy server and port text boxes
880 proxyServerHttpTB.setFont(LABEL_FONT);
881 proxyServerHttpTB.setColumns(40);
882 proxyPortHttpTB.setFont(LABEL_FONT);
883 proxyPortHttpTB.setColumns(4);
884 proxyServerHttpsTB.setFont(LABEL_FONT);
885 proxyServerHttpsTB.setColumns(40);
886 proxyPortHttpsTB.setFont(LABEL_FONT);
887 proxyPortHttpsTB.setColumns(4);
888 proxyAuthUsernameTB.setFont(LABEL_FONT);
889 proxyAuthUsernameTB.setColumns(30);
890 proxyAuthPasswordTB.setFont(LABEL_FONT);
891 proxyAuthPasswordTB.setColumns(30);
893 // Label for Port text box
894 portLabel.setFont(LABEL_FONT);
895 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
896 portLabel.setText(MessageManager.getString("label.port") + ": ");
897 portLabel2.setFont(LABEL_FONT);
898 portLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
899 portLabel2.setText(MessageManager.getString("label.port") + ": ");
901 httpLabel.setText("HTTP");
902 httpLabel.setFont(LABEL_FONT_BOLD);
903 httpLabel.setHorizontalAlignment(SwingConstants.LEFT);
904 httpsLabel.setText("HTTPS");
905 httpsLabel.setFont(LABEL_FONT_BOLD);
906 httpsLabel.setHorizontalAlignment(SwingConstants.LEFT);
908 proxyAuthUsernameLabel
909 .setText(MessageManager.getString("label.username") + ": ");
910 proxyAuthUsernameLabel.setFont(LABEL_FONT);
911 proxyAuthUsernameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
912 proxyAuthPasswordLabel
913 .setText(MessageManager.getString("label.password") + ": ");
914 proxyAuthPasswordLabel.setFont(LABEL_FONT);
915 proxyAuthPasswordLabel.setHorizontalAlignment(SwingConstants.RIGHT);
917 // Proxy type radio buttons
918 noProxy.setFont(LABEL_FONT);
919 noProxy.setHorizontalAlignment(SwingConstants.LEFT);
920 noProxy.setText(MessageManager.getString("label.no_proxy"));
921 systemProxy.setFont(LABEL_FONT);
922 systemProxy.setHorizontalAlignment(SwingConstants.LEFT);
923 systemProxy.setText(MessageManager.formatMessage("label.system_proxy",
924 displayUserHostPort(Cache.startupProxyProperties[4],
925 Cache.startupProxyProperties[0],
926 Cache.startupProxyProperties[1]),
927 displayUserHostPort(Cache.startupProxyProperties[6],
928 Cache.startupProxyProperties[2],
929 Cache.startupProxyProperties[3])));
930 customProxy.setFont(LABEL_FONT);
931 customProxy.setHorizontalAlignment(SwingConstants.LEFT);
933 MessageManager.getString("label.use_proxy_server") + ":");
934 ActionListener al = new ActionListener()
937 public void actionPerformed(ActionEvent e)
939 proxyType_actionPerformed();
942 noProxy.addActionListener(al);
943 systemProxy.addActionListener(al);
944 customProxy.addActionListener(al);
945 proxyType.add(noProxy);
946 proxyType.add(systemProxy);
947 proxyType.add(customProxy);
949 proxyAuth.setFont(LABEL_FONT);
950 proxyAuth.setHorizontalAlignment(SwingConstants.LEFT);
951 proxyAuth.setText(MessageManager.getString("label.auth_required"));
952 proxyAuth.addActionListener(new ActionListener()
955 public void actionPerformed(ActionEvent e)
957 proxyAuth_actionPerformed();
961 setCustomProxyEnabled();
963 // Make proxy server panel
964 JPanel proxyPanel = new JPanel();
965 TitledBorder titledBorder1 = new TitledBorder(
966 MessageManager.getString("label.proxy_servers"));
967 proxyPanel.setBorder(titledBorder1);
968 GridBagConstraints gbc = new GridBagConstraints();
969 proxyPanel.setLayout(new GridBagLayout());
975 gbc.anchor = GridBagConstraints.WEST;
976 gbc.fill = GridBagConstraints.BOTH;
979 proxyPanel.add(noProxy, gbc);
982 proxyPanel.add(systemProxy, gbc);
985 proxyPanel.add(customProxy, gbc);
991 proxyPanel.add(httpLabel, gbc);
994 gbc.anchor = GridBagConstraints.EAST;
996 proxyPanel.add(serverLabel, gbc);
999 gbc.anchor = GridBagConstraints.WEST;
1001 proxyPanel.add(proxyServerHttpTB, gbc);
1004 gbc.anchor = GridBagConstraints.EAST;
1006 proxyPanel.add(portLabel, gbc);
1009 gbc.anchor = GridBagConstraints.WEST;
1011 proxyPanel.add(proxyPortHttpTB, gbc);
1015 gbc.anchor = GridBagConstraints.WEST;
1017 proxyPanel.add(httpsLabel, gbc);
1020 gbc.anchor = GridBagConstraints.EAST;
1022 proxyPanel.add(serverLabel2, gbc);
1025 gbc.anchor = GridBagConstraints.WEST;
1027 proxyPanel.add(proxyServerHttpsTB, gbc);
1030 gbc.anchor = GridBagConstraints.EAST;
1032 proxyPanel.add(portLabel2, gbc);
1035 gbc.anchor = GridBagConstraints.WEST;
1037 proxyPanel.add(proxyPortHttpsTB, gbc);
1042 gbc.anchor = GridBagConstraints.WEST;
1044 proxyPanel.add(proxyAuth, gbc);
1049 gbc.anchor = GridBagConstraints.EAST;
1050 proxyPanel.add(proxyAuthUsernameLabel, gbc);
1054 gbc.anchor = GridBagConstraints.WEST;
1055 proxyPanel.add(proxyAuthUsernameTB, gbc);
1060 gbc.anchor = GridBagConstraints.EAST;
1061 proxyPanel.add(proxyAuthPasswordLabel, gbc);
1065 gbc.anchor = GridBagConstraints.WEST;
1066 proxyPanel.add(proxyAuthPasswordTB, gbc);
1071 private String displayUserHostPort(String user, String host, String port)
1073 boolean hostBlank = (host == null || host.isEmpty());
1074 boolean portBlank = (port == null || port.isEmpty());
1075 if (hostBlank && portBlank)
1077 return MessageManager.getString("label.none");
1080 StringBuilder sb = new StringBuilder();
1083 sb.append(user.isEmpty() || user.indexOf(" ") > -1 ? '"' + user + '"'
1087 sb.append(hostBlank ? "" : host);
1093 return sb.toString();
1097 * Initialises the checkboxes in the Connections tab
1099 private void initConnTabCheckboxes()
1101 // Usage stats checkbox label
1103 MessageManager.getString("label.send_usage_statistics"));
1104 usagestats.setFont(LABEL_FONT);
1105 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
1106 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
1108 // Questionnaire checkbox label
1109 questionnaire.setText(
1110 MessageManager.getString("label.check_for_questionnaires"));
1111 questionnaire.setFont(LABEL_FONT);
1112 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
1113 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
1115 // Check for latest version checkbox label
1116 versioncheck.setText(
1117 MessageManager.getString("label.check_for_latest_version"));
1118 versioncheck.setFont(LABEL_FONT);
1119 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
1120 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
1124 * Initialises the parent panel which contains the tabbed sections.
1128 private JPanel initOkCancelPanel()
1130 JButton ok = new JButton();
1131 ok.setText(MessageManager.getString("action.ok"));
1132 ok.addActionListener(new ActionListener()
1135 public void actionPerformed(ActionEvent e)
1137 ok_actionPerformed(e);
1140 JButton cancel = new JButton();
1141 cancel.setText(MessageManager.getString("action.cancel"));
1142 cancel.addActionListener(new ActionListener()
1145 public void actionPerformed(ActionEvent e)
1147 cancel_actionPerformed(e);
1150 JPanel okCancelPanel = new JPanel();
1151 okCancelPanel.add(ok);
1152 okCancelPanel.add(cancel);
1153 return okCancelPanel;
1157 * Initialises the Colours tabbed panel.
1161 private JPanel initColoursTab()
1163 JPanel coloursTab = new JPanel();
1164 coloursTab.setBorder(new TitledBorder(
1165 MessageManager.getString("action.open_new_alignment")));
1166 coloursTab.setLayout(new FlowLayout());
1167 JLabel mincolourLabel = new JLabel();
1168 mincolourLabel.setFont(LABEL_FONT);
1169 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1170 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
1171 minColour.setFont(LABEL_FONT);
1172 minColour.setBorder(BorderFactory.createEtchedBorder());
1173 minColour.setPreferredSize(new Dimension(40, 20));
1174 minColour.addMouseListener(new MouseAdapter()
1177 public void mousePressed(MouseEvent e)
1179 minColour_actionPerformed(minColour);
1182 JLabel maxcolourLabel = new JLabel();
1183 maxcolourLabel.setFont(LABEL_FONT);
1184 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1185 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
1186 maxColour.setFont(LABEL_FONT);
1187 maxColour.setBorder(BorderFactory.createEtchedBorder());
1188 maxColour.setPreferredSize(new Dimension(40, 20));
1189 maxColour.addMouseListener(new MouseAdapter()
1192 public void mousePressed(MouseEvent e)
1194 maxColour_actionPerformed(maxColour);
1198 protColour.setFont(LABEL_FONT);
1199 protColour.setBounds(new Rectangle(172, 225, 155, 21));
1200 JLabel protColourLabel = new JLabel();
1201 protColourLabel.setFont(LABEL_FONT);
1202 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1203 protColourLabel.setText(
1204 MessageManager.getString("label.prot_alignment_colour") + " ");
1205 JvSwingUtils.addtoLayout(coloursTab,
1207 .getString("label.default_colour_scheme_for_alignment"),
1208 protColourLabel, protColour);
1210 nucColour.setFont(LABEL_FONT);
1211 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1212 JLabel nucColourLabel = new JLabel();
1213 nucColourLabel.setFont(LABEL_FONT);
1214 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1215 nucColourLabel.setText(
1216 MessageManager.getString("label.nuc_alignment_colour") + " ");
1217 JvSwingUtils.addtoLayout(coloursTab,
1219 .getString("label.default_colour_scheme_for_alignment"),
1220 nucColourLabel, nucColour);
1222 JPanel annotationShding = new JPanel();
1223 annotationShding.setBorder(new TitledBorder(
1224 MessageManager.getString("label.annotation_shading_default")));
1225 annotationShding.setLayout(new GridLayout(1, 2));
1226 JvSwingUtils.addtoLayout(annotationShding,
1227 MessageManager.getString(
1228 "label.default_minimum_colour_annotation_shading"),
1229 mincolourLabel, minColour);
1230 JvSwingUtils.addtoLayout(annotationShding,
1231 MessageManager.getString(
1232 "label.default_maximum_colour_annotation_shading"),
1233 maxcolourLabel, maxColour);
1234 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1239 * Initialises the Overview tabbed panel.
1243 private JPanel initOverviewTab()
1245 JPanel overviewPanel = new JPanel();
1246 overviewPanel.setBorder(new TitledBorder(
1247 MessageManager.getString("label.overview_settings")));
1249 gapColour.setFont(LABEL_FONT);
1250 // fixing the border colours stops apparent colour bleed from the panel
1251 gapColour.setBorder(
1252 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1253 gapColour.setPreferredSize(new Dimension(40, 20));
1254 gapColour.addMouseListener(new MouseAdapter()
1257 public void mousePressed(MouseEvent e)
1259 gapColour_actionPerformed(gapColour);
1263 hiddenColour.setFont(LABEL_FONT);
1264 // fixing the border colours stops apparent colour bleed from the panel
1265 hiddenColour.setBorder(
1266 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1267 hiddenColour.setPreferredSize(new Dimension(40, 20));
1268 hiddenColour.addMouseListener(new MouseAdapter()
1271 public void mousePressed(MouseEvent e)
1273 hiddenColour_actionPerformed(hiddenColour);
1277 useLegacyGap = new JCheckBox(
1278 MessageManager.getString("label.ov_legacy_gap"));
1279 useLegacyGap.setFont(LABEL_FONT);
1280 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1281 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1282 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1283 gapLabel.setFont(LABEL_FONT);
1284 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1285 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1286 showHiddenAtStart = new JCheckBox(
1287 MessageManager.getString("label.ov_show_hide_default"));
1288 showHiddenAtStart.setFont(LABEL_FONT);
1289 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1290 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1291 JLabel hiddenLabel = new JLabel(
1292 MessageManager.getString("label.hidden_colour"));
1293 hiddenLabel.setFont(LABEL_FONT);
1294 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1295 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1297 useLegacyGap.addActionListener(new ActionListener()
1300 public void actionPerformed(ActionEvent e)
1302 useLegacyGaps_actionPerformed(e);
1306 overviewPanel.setLayout(new GridBagLayout());
1307 GridBagConstraints c1 = new GridBagConstraints();
1309 c1.fill = GridBagConstraints.HORIZONTAL;
1314 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1315 overviewPanel.add(useLegacyGap, c1);
1317 GridBagConstraints c2 = new GridBagConstraints();
1318 c2.fill = GridBagConstraints.HORIZONTAL;
1321 c2.insets = new Insets(0, 15, 0, 10);
1322 overviewPanel.add(gapLabel, c2);
1324 GridBagConstraints c3 = new GridBagConstraints();
1325 c3.fill = GridBagConstraints.HORIZONTAL;
1328 c3.insets = new Insets(0, 0, 0, 15);
1329 overviewPanel.add(gapColour, c3);
1331 GridBagConstraints c4 = new GridBagConstraints();
1332 c4.fill = GridBagConstraints.HORIZONTAL;
1336 overviewPanel.add(showHiddenAtStart, c4);
1338 GridBagConstraints c5 = new GridBagConstraints();
1339 c5.fill = GridBagConstraints.HORIZONTAL;
1342 c5.insets = new Insets(0, 15, 0, 10);
1343 overviewPanel.add(hiddenLabel, c5);
1345 GridBagConstraints c6 = new GridBagConstraints();
1346 c6.fill = GridBagConstraints.HORIZONTAL;
1349 c6.insets = new Insets(0, 0, 0, 15);
1350 overviewPanel.add(hiddenColour, c6);
1352 JButton resetButton = new JButton(
1353 MessageManager.getString("label.reset_to_defaults"));
1355 resetButton.addActionListener(new ActionListener()
1358 public void actionPerformed(ActionEvent e)
1360 resetOvDefaults_actionPerformed(e);
1364 GridBagConstraints c7 = new GridBagConstraints();
1365 c7.fill = GridBagConstraints.NONE;
1368 c7.insets = new Insets(10, 0, 0, 0);
1369 c7.anchor = GridBagConstraints.WEST;
1370 overviewPanel.add(resetButton, c7);
1372 // Add padding so the panel doesn't look ridiculous
1373 JPanel spacePanel = new JPanel();
1374 overviewPanel.add(spacePanel,
1375 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1376 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1377 new Insets(0, 0, 0, 5), 0, 0));
1379 return overviewPanel;
1383 * Initialises the Structure tabbed panel.
1387 private JPanel initStructureTab()
1389 structureTab = new JPanel();
1391 structureTab.setBorder(new TitledBorder(
1392 MessageManager.getString("label.structure_options")));
1393 structureTab.setLayout(null);
1394 final int width = 400;
1395 final int height = 22;
1396 final int lineSpacing = 25;
1399 structFromPdb.setFont(LABEL_FONT);
1401 .setText(MessageManager.getString("label.struct_from_pdb"));
1402 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1403 structFromPdb.addActionListener(new ActionListener()
1406 public void actionPerformed(ActionEvent e)
1408 boolean selected = structFromPdb.isSelected();
1409 // enable other options only when the first is checked
1410 useRnaView.setEnabled(selected);
1411 addSecondaryStructure.setEnabled(selected);
1412 addTempFactor.setEnabled(selected);
1415 structureTab.add(structFromPdb);
1417 // indent checkboxes that are conditional on the first one
1418 ypos += lineSpacing;
1419 useRnaView.setFont(LABEL_FONT);
1420 useRnaView.setText(MessageManager.getString("label.use_rnaview"));
1421 useRnaView.setBounds(new Rectangle(25, ypos, width, height));
1422 structureTab.add(useRnaView);
1424 ypos += lineSpacing;
1425 addSecondaryStructure.setFont(LABEL_FONT);
1426 addSecondaryStructure
1427 .setText(MessageManager.getString("label.autoadd_secstr"));
1428 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1429 structureTab.add(addSecondaryStructure);
1431 ypos += lineSpacing;
1432 addTempFactor.setFont(LABEL_FONT);
1433 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1434 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1435 structureTab.add(addTempFactor);
1437 ypos += lineSpacing;
1438 JLabel viewerLabel = new JLabel();
1439 viewerLabel.setFont(LABEL_FONT);
1440 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1441 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1442 viewerLabel.setBounds(new Rectangle(10, ypos, 200, height));
1443 structureTab.add(viewerLabel);
1445 structViewer.setFont(LABEL_FONT);
1446 structViewer.setBounds(new Rectangle(160, ypos, 120, height));
1447 structViewer.addItem(ViewerType.JMOL.name());
1448 structViewer.addItem(ViewerType.CHIMERA.name());
1449 structViewer.addActionListener(new ActionListener()
1452 public void actionPerformed(ActionEvent e)
1454 structureViewer_actionPerformed(
1455 (String) structViewer.getSelectedItem());
1458 structureTab.add(structViewer);
1460 ypos += lineSpacing;
1461 JLabel pathLabel = new JLabel();
1462 pathLabel.setFont(new java.awt.Font("SansSerif", 0, 11));
1463 pathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1464 pathLabel.setText(MessageManager.getString("label.chimera_path"));
1465 pathLabel.setBounds(new Rectangle(10, ypos, 140, height));
1466 structureTab.add(pathLabel);
1468 chimeraPath.setFont(LABEL_FONT);
1469 chimeraPath.setText("");
1470 final String tooltip = JvSwingUtils.wrapTooltip(true,
1471 MessageManager.getString("label.chimera_path_tip"));
1472 chimeraPath.setToolTipText(tooltip);
1473 chimeraPath.setBounds(new Rectangle(160, ypos, 300, height));
1474 chimeraPath.addMouseListener(new MouseAdapter()
1477 public void mouseClicked(MouseEvent e)
1479 if (e.getClickCount() == 2)
1481 String chosen = openFileChooser();
1484 chimeraPath.setText(chosen);
1489 structureTab.add(chimeraPath);
1491 ypos += lineSpacing;
1492 nwMapping.setFont(LABEL_FONT);
1493 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1494 siftsMapping.setFont(LABEL_FONT);
1495 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1496 mappingMethod.add(nwMapping);
1497 mappingMethod.add(siftsMapping);
1498 JPanel mappingPanel = new JPanel();
1499 mappingPanel.setFont(LABEL_FONT);
1500 TitledBorder mmTitledBorder = new TitledBorder(
1501 MessageManager.getString("label.mapping_method"));
1502 mmTitledBorder.setTitleFont(LABEL_FONT);
1503 mappingPanel.setBorder(mmTitledBorder);
1504 mappingPanel.setBounds(new Rectangle(10, ypos, 452, 45));
1505 // GridLayout mappingLayout = new GridLayout();
1506 mappingPanel.setLayout(new GridLayout());
1507 mappingPanel.add(nwMapping);
1508 mappingPanel.add(siftsMapping);
1509 structureTab.add(mappingPanel);
1511 ypos += lineSpacing;
1512 ypos += lineSpacing;
1513 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1514 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1515 docFieldPref.setBounds(new Rectangle(10, ypos, 450, 120));
1516 structureTab.add(docFieldPref);
1518 return structureTab;
1522 * Action on choosing a structure viewer from combobox options.
1524 * @param selectedItem
1526 protected void structureViewer_actionPerformed(String selectedItem)
1531 * Show a dialog for the user to choose a file. Returns the chosen path, or
1536 protected String openFileChooser()
1538 String choice = null;
1539 JFileChooser chooser = new JFileChooser();
1541 // chooser.setFileView(new JalviewFileView());
1542 chooser.setDialogTitle(
1543 MessageManager.getString("label.open_local_file"));
1544 chooser.setToolTipText(MessageManager.getString("action.open"));
1546 int value = chooser.showOpenDialog(this);
1548 if (value == JFileChooser.APPROVE_OPTION)
1550 choice = chooser.getSelectedFile().getPath();
1556 * Validate the structure tab preferences; if invalid, set focus on this tab.
1560 protected boolean validateStructure(FocusEvent e)
1562 if (!validateStructure())
1564 e.getComponent().requestFocusInWindow();
1570 protected boolean validateStructure()
1576 * Initialises the Visual tabbed panel.
1580 private JPanel initVisualTab()
1582 JPanel visualTab = new JPanel();
1583 visualTab.setBorder(new TitledBorder(
1584 MessageManager.getString("action.open_new_alignment")));
1585 visualTab.setLayout(null);
1586 fullScreen.setFont(LABEL_FONT);
1587 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1588 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1589 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1590 quality.setEnabled(false);
1591 quality.setFont(LABEL_FONT);
1592 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1593 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1594 quality.setSelected(true);
1595 quality.setText(MessageManager.getString("label.quality"));
1596 conservation.setEnabled(false);
1597 conservation.setFont(LABEL_FONT);
1598 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1599 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1600 conservation.setSelected(true);
1601 conservation.setText(MessageManager.getString("label.conservation"));
1602 identity.setEnabled(false);
1603 identity.setFont(LABEL_FONT);
1604 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1605 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1606 identity.setSelected(true);
1607 identity.setText(MessageManager.getString("label.consensus"));
1608 showOccupancy.setFont(LABEL_FONT);
1609 showOccupancy.setEnabled(false);
1610 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1611 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1612 showOccupancy.setSelected(true);
1613 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1615 JLabel showGroupbits = new JLabel();
1616 showGroupbits.setFont(LABEL_FONT);
1617 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1618 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1620 .setText(MessageManager.getString("action.show_group") + ":");
1621 JLabel showConsensbits = new JLabel();
1622 showConsensbits.setFont(LABEL_FONT);
1623 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1624 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1626 .setText(MessageManager.getString("label.consensus") + ":");
1627 showConsensHistogram.setEnabled(false);
1628 showConsensHistogram.setFont(LABEL_FONT);
1629 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1630 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1631 showConsensHistogram.setSelected(true);
1632 showConsensHistogram
1633 .setText(MessageManager.getString("label.histogram"));
1634 showConsensLogo.setEnabled(false);
1635 showConsensLogo.setFont(LABEL_FONT);
1636 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1637 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1638 showConsensLogo.setSelected(true);
1639 showConsensLogo.setText(MessageManager.getString("label.logo"));
1640 showGroupConsensus.setEnabled(false);
1641 showGroupConsensus.setFont(LABEL_FONT);
1642 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1643 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1644 showGroupConsensus.setSelected(true);
1645 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1646 showGroupConservation.setEnabled(false);
1647 showGroupConservation.setFont(LABEL_FONT);
1648 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1649 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1650 showGroupConservation.setSelected(true);
1651 showGroupConservation
1652 .setText(MessageManager.getString("label.conservation"));
1653 showNpTooltip.setEnabled(true);
1654 showNpTooltip.setFont(LABEL_FONT);
1655 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1656 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1657 showNpTooltip.setSelected(true);
1658 showNpTooltip.setText(
1659 MessageManager.getString("label.non_positional_features"));
1660 showDbRefTooltip.setEnabled(true);
1661 showDbRefTooltip.setFont(LABEL_FONT);
1662 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1663 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1664 showDbRefTooltip.setSelected(true);
1666 .setText(MessageManager.getString("label.database_references"));
1667 annotations.setFont(LABEL_FONT);
1668 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1669 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1670 annotations.setSelected(true);
1671 annotations.setText(MessageManager.getString("label.show_annotations"));
1672 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1673 annotations.addActionListener(new ActionListener()
1676 public void actionPerformed(ActionEvent e)
1678 annotations_actionPerformed(e);
1681 identity.addActionListener(new ActionListener()
1684 public void actionPerformed(ActionEvent e)
1686 annotations_actionPerformed(e);
1689 showGroupConsensus.addActionListener(new ActionListener()
1692 public void actionPerformed(ActionEvent e)
1694 annotations_actionPerformed(e);
1697 showUnconserved.setFont(LABEL_FONT);
1698 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1699 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1700 showUnconserved.setSelected(true);
1702 .setText(MessageManager.getString("action.show_unconserved"));
1703 showUnconserved.addActionListener(new ActionListener()
1706 public void actionPerformed(ActionEvent e)
1708 showunconserved_actionPerformed(e);
1712 // TODO these are not yet added to / action from Preferences
1713 // JCheckBox shareSelections = new JCheckBox();
1714 // shareSelections.setFont(verdana11);
1715 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1716 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1717 // shareSelections.setSelected(true);
1718 // shareSelections.setText(MessageManager
1719 // .getString("label.share_selection_across_views"));
1720 // JCheckBox followHighlight = new JCheckBox();
1721 // followHighlight.setFont(verdana11);
1722 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1723 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1724 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1725 // followHighlight.setSelected(true);
1726 // followHighlight.setText(MessageManager
1727 // .getString("label.scroll_highlighted_regions"));
1729 seqLimit.setFont(LABEL_FONT);
1730 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1731 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1732 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1733 smoothFont.setFont(LABEL_FONT);
1734 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1735 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1736 smoothFont.setText(MessageManager.getString("label.smooth_font"));
1737 scaleProteinToCdna.setFont(LABEL_FONT);
1738 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1739 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1740 scaleProteinToCdna.setText(
1741 MessageManager.getString("label.scale_protein_to_cdna"));
1742 scaleProteinToCdna.setToolTipText(
1743 MessageManager.getString("label.scale_protein_to_cdna_tip"));
1744 JLabel gapLabel = new JLabel();
1745 gapLabel.setFont(LABEL_FONT);
1746 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1747 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1748 JLabel fontLabel = new JLabel();
1749 fontLabel.setFont(LABEL_FONT);
1750 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1751 fontLabel.setText(MessageManager.getString("label.font"));
1752 fontSizeCB.setFont(LABEL_FONT);
1753 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
1754 fontStyleCB.setFont(LABEL_FONT);
1755 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
1756 fontNameCB.setFont(LABEL_FONT);
1757 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
1758 gapSymbolCB.setFont(LABEL_FONT);
1759 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
1760 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1761 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1762 gapSymbolCB.setRenderer(dlcr);
1764 startupCheckbox.setText(MessageManager.getString("action.open_file"));
1765 startupCheckbox.setFont(LABEL_FONT);
1766 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1767 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1768 startupCheckbox.setSelected(true);
1769 startupFileTextfield.setFont(LABEL_FONT);
1770 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
1771 final String tooltip = JvSwingUtils.wrapTooltip(true,
1772 MessageManager.getString("label.double_click_to_browse"));
1773 startupFileTextfield.setToolTipText(tooltip);
1774 startupFileTextfield.addMouseListener(new MouseAdapter()
1777 public void mouseClicked(MouseEvent e)
1779 if (e.getClickCount() > 1)
1781 startupFileTextfield_mouseClicked();
1786 sortby.setFont(LABEL_FONT);
1787 sortby.setBounds(new Rectangle(172, 260, 155, 21));
1788 JLabel sortLabel = new JLabel();
1789 sortLabel.setFont(LABEL_FONT);
1790 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1791 sortLabel.setText(MessageManager.getString("label.sort_by"));
1792 sortAnnBy.setFont(LABEL_FONT);
1793 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
1794 JLabel sortAnnLabel = new JLabel();
1795 sortAnnLabel.setFont(LABEL_FONT);
1796 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1797 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
1798 sortAutocalc.setFont(LABEL_FONT);
1799 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
1801 JPanel annsettingsPanel = new JPanel();
1802 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
1803 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1804 annsettingsPanel.setBorder(new EtchedBorder());
1805 visualTab.add(annsettingsPanel);
1806 Border jb = new EmptyBorder(1, 1, 4, 5);
1807 annotations.setBorder(jb);
1808 showOccupancy.setBorder(jb);
1809 quality.setBorder(jb);
1810 conservation.setBorder(jb);
1811 identity.setBorder(jb);
1812 showConsensbits.setBorder(jb);
1813 showGroupbits.setBorder(jb);
1814 showGroupConsensus.setBorder(jb);
1815 showGroupConservation.setBorder(jb);
1816 showConsensHistogram.setBorder(jb);
1817 showConsensLogo.setBorder(jb);
1819 JPanel autoAnnotSettings = new JPanel();
1820 annsettingsPanel.add(autoAnnotSettings);
1821 autoAnnotSettings.setLayout(new GridLayout(0, 2));
1822 autoAnnotSettings.add(annotations);
1823 autoAnnotSettings.add(quality);
1824 // second row of autoannotation box
1825 autoAnnotSettings = new JPanel();
1826 annsettingsPanel.add(autoAnnotSettings);
1828 autoAnnotSettings.setLayout(new GridLayout(0, 3));
1829 autoAnnotSettings.add(conservation);
1830 autoAnnotSettings.add(identity);
1831 autoAnnotSettings.add(showOccupancy);
1832 autoAnnotSettings.add(showGroupbits);
1833 autoAnnotSettings.add(showGroupConservation);
1834 autoAnnotSettings.add(showGroupConsensus);
1835 autoAnnotSettings.add(showConsensbits);
1836 autoAnnotSettings.add(showConsensHistogram);
1837 autoAnnotSettings.add(showConsensLogo);
1839 JPanel tooltipSettings = new JPanel();
1840 tooltipSettings.setBorder(new TitledBorder(
1841 MessageManager.getString("label.sequence_id_tooltip")));
1842 tooltipSettings.setBounds(173, 140, 220, 62);
1843 tooltipSettings.setLayout(new GridLayout(2, 1));
1844 tooltipSettings.add(showDbRefTooltip);
1845 tooltipSettings.add(showNpTooltip);
1846 visualTab.add(tooltipSettings);
1848 wrap.setFont(LABEL_FONT);
1849 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
1850 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
1851 wrap.setText(MessageManager.getString("label.wrap_alignment"));
1852 rightAlign.setFont(LABEL_FONT);
1853 rightAlign.setForeground(Color.black);
1854 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
1855 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
1856 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
1857 idItalics.setFont(LABEL_FONT_ITALIC);
1858 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
1859 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
1861 MessageManager.getString("label.sequence_name_italics"));
1862 openoverv.setFont(LABEL_FONT);
1863 openoverv.setActionCommand(
1864 MessageManager.getString("label.open_overview"));
1865 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
1866 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
1867 openoverv.setText(MessageManager.getString("label.open_overview"));
1868 JPanel jPanel2 = new JPanel();
1869 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
1870 jPanel2.setLayout(new GridLayout(14, 1));
1871 jPanel2.add(fullScreen);
1872 jPanel2.add(openoverv);
1873 jPanel2.add(seqLimit);
1874 jPanel2.add(rightAlign);
1875 jPanel2.add(fontLabel);
1876 jPanel2.add(showUnconserved);
1877 jPanel2.add(idItalics);
1878 jPanel2.add(smoothFont);
1879 jPanel2.add(scaleProteinToCdna);
1880 jPanel2.add(gapLabel);
1882 jPanel2.add(sortLabel);
1883 jPanel2.add(sortAnnLabel);
1884 jPanel2.add(startupCheckbox);
1885 visualTab.add(jPanel2);
1886 visualTab.add(startupFileTextfield);
1887 visualTab.add(sortby);
1888 visualTab.add(sortAnnBy);
1889 visualTab.add(sortAutocalc);
1890 visualTab.add(gapSymbolCB);
1891 visualTab.add(fontNameCB);
1892 visualTab.add(fontSizeCB);
1893 visualTab.add(fontStyleCB);
1898 * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
1901 protected void loadLastSavedBackupsOptions()
1903 BackupFilesPresetEntry savedPreset = BackupFilesPresetEntry
1904 .getSavedBackupEntry();
1906 .setSelected(Cache.getDefault(BackupFiles.ENABLED, true));
1908 BackupFilesPresetEntry backupfilesCustomEntry = BackupFilesPresetEntry
1909 .createBackupFilesPresetEntry(Cache
1910 .getDefault(BackupFilesPresetEntry.CUSTOMCONFIG, null));
1911 if (backupfilesCustomEntry == null)
1913 backupfilesCustomEntry = BackupFilesPresetEntry.backupfilesPresetEntriesValues
1914 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT);
1916 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
1917 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM,
1918 backupfilesCustomEntry);
1920 setComboIntStringKey(backupfilesPresetsCombo,
1921 Cache.getDefault(BackupFiles.NS + "_PRESET",
1922 BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT));
1924 backupsSetOptions(savedPreset);
1926 backupsOptionsSetEnabled();
1927 updateBackupFilesExampleLabel();
1930 private boolean warnAboutSuffixReverseChange()
1932 BackupFilesPresetEntry bfpe = BackupFilesPresetEntry
1933 .getSavedBackupEntry();
1934 boolean savedSuffixReverse = bfpe.reverse;
1935 int savedSuffixDigits = bfpe.digits;
1936 String savedSuffixTemplate = bfpe.suffix;
1938 boolean nowSuffixReverse = suffixReverse.isSelected();
1939 int nowSuffixDigits = getSpinnerInt(suffixDigitsSpinner, 3);
1940 String nowSuffixTemplate = suffixTemplate.getText();
1941 return nowSuffixReverse != savedSuffixReverse
1942 && nowSuffixDigits == savedSuffixDigits
1943 && nowSuffixTemplate != null
1944 && nowSuffixTemplate.equals(savedSuffixTemplate);
1948 * Initialises the Backups tabbed panel.
1952 private JPanel initBackupsTab()
1954 JPanel backupsTab = new JPanel();
1955 backupsTab.setBorder(new TitledBorder(
1956 MessageManager.getString("label.backup_files")));
1957 backupsTab.setLayout(new GridBagLayout());
1959 GridBagConstraints gbc = new GridBagConstraints();
1962 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1963 gbc.fill = GridBagConstraints.NONE;
1965 initBackupsTabPresetsPanel();
1966 initBackupsTabSuffixPanel();
1967 initBackupsTabKeepFilesPanel();
1968 initBackupsTabFilenameExamplesPanel();
1970 enableBackupFiles.setFont(LABEL_FONT_BOLD);
1972 .setText(MessageManager.getString("label.enable_backupfiles"));
1973 enableBackupFiles.addActionListener(new ActionListener()
1976 public void actionPerformed(ActionEvent e)
1978 // enable other options only when the first is checked
1979 backupsOptionsSetEnabled();
1983 // enable checkbox 1 col
1987 gbc.gridy = 0; // row 0
1988 backupsTab.add(enableBackupFiles, gbc);
1990 // summary of scheme box (over two rows)
1994 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
1995 gbc.fill = GridBagConstraints.BOTH;
1996 backupsTab.add(exampleFilesPanel, gbc);
1998 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1999 gbc.fill = GridBagConstraints.NONE;
2001 // fill empty space on right
2004 backupsTab.add(new JPanel(), gbc);
2009 gbc.gridy++; // row 1
2010 backupsTab.add(presetsPanel, gbc);
2012 // now using whole row
2017 gbc.gridy++; // row 2
2018 backupsTab.add(keepfilesPanel, gbc);
2020 // filename strategy box
2021 gbc.gridy++; // row 3
2022 backupsTab.add(suffixPanel, gbc);
2025 gbc.gridy++; // row 4
2027 backupsTab.add(new JPanel(), gbc);
2029 backupsOptionsSetEnabled();
2033 private JPanel initBackupsTabPresetsPanel()
2036 String title = MessageManager.getString("label.schemes");
2038 presetsPanel.setLayout(new GridBagLayout());
2040 GridBagConstraints gbc = new GridBagConstraints();
2043 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
2044 gbc.fill = GridBagConstraints.NONE;
2052 presetsComboLabel = new JLabel(title + ":");
2053 presetsPanel.add(presetsComboLabel, gbc);
2055 List<Object> entries = Arrays.asList(
2056 (Object[]) BackupFilesPresetEntry.backupfilesPresetEntries);
2057 List<String> tooltips = Arrays.asList(
2058 BackupFilesPresetEntry.backupfilesPresetEntryDescriptions);
2059 backupfilesPresetsCombo = JvSwingUtils.buildComboWithTooltips(entries,
2062 for (int i = 0; i < BackupFilesPresetEntry.backupfilesPresetEntries.length; i++)
2064 backupfilesPresetsCombo
2065 .addItem(BackupFilesPresetEntry.backupfilesPresetEntries[i]);
2069 backupfilesPresetsCombo.addActionListener(new ActionListener()
2072 public void actionPerformed(ActionEvent e)
2074 int key = getComboIntStringKey(backupfilesPresetsCombo);
2075 if (!customiseCheckbox.isSelected())
2077 backupfilesPresetsComboLastSelected = key;
2079 if (key == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
2081 if (customiseCheckbox.isSelected())
2083 // got here by clicking on customiseCheckbox so don't change the
2085 backupfilesCustomOptionsSetEnabled();
2089 backupsTabUpdatePresets();
2090 backupfilesCustomOptionsSetEnabled();
2095 customiseCheckbox.setSelected(false);
2096 backupsTabUpdatePresets();
2097 backupfilesCustomOptionsSetEnabled();
2102 // dropdown list of preset schemes
2104 presetsPanel.add(backupfilesPresetsCombo, gbc);
2106 revertButton.setText(MessageManager.getString("label.cancel_changes"));
2107 revertButton.setToolTipText(
2108 MessageManager.getString("label.cancel_changes_description"));
2109 revertButton.addActionListener(new ActionListener()
2112 public void actionPerformed(ActionEvent e)
2115 BackupFilesPresetEntry.backupfilesPresetEntriesValues.get(
2116 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM));
2117 backupfilesCustomOptionsSetEnabled();
2121 revertButton.setFont(LABEL_FONT);
2123 customiseCheckbox.setFont(LABEL_FONT);
2124 customiseCheckbox.setText(MessageManager.getString("label.customise"));
2125 customiseCheckbox.addActionListener(new ActionListener()
2128 public void actionPerformed(ActionEvent e)
2130 int currently = getComboIntStringKey(backupfilesPresetsCombo);
2131 if (customiseCheckbox.isSelected())
2133 backupfilesPresetsComboLastSelected = currently;
2134 setComboIntStringKey(backupfilesPresetsCombo,
2135 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2139 setComboIntStringKey(backupfilesPresetsCombo,
2140 backupfilesPresetsComboLastSelected);
2143 backupfilesCustomOptionsSetEnabled();
2146 customiseCheckbox.setToolTipText(
2147 MessageManager.getString("label.customise_description"));
2149 // customise checkbox
2152 presetsPanel.add(customiseCheckbox, gbc);
2154 // "Cancel changes" button (aligned with combo box above)
2156 presetsPanel.add(revertButton, gbc);
2158 return presetsPanel;
2161 private JPanel initBackupsTabFilenameExamplesPanel()
2163 String title = MessageManager.getString("label.scheme_examples");
2164 TitledBorder tb = new TitledBorder(title);
2165 exampleFilesPanel.setBorder(tb);
2166 exampleFilesPanel.setLayout(new GridBagLayout());
2168 backupfilesExampleLabel.setEditable(false);
2169 backupfilesExampleLabel
2170 .setBackground(exampleFilesPanel.getBackground());
2172 updateBackupFilesExampleLabel();
2174 GridBagConstraints gbc = new GridBagConstraints();
2177 gbc.fill = GridBagConstraints.NONE;
2178 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
2180 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
2181 return exampleFilesPanel;
2184 private void backupsTabUpdatePresets()
2186 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
2189 String value = entry.v;
2191 if (BackupFilesPresetEntry.backupfilesPresetEntriesValues
2195 BackupFilesPresetEntry.backupfilesPresetEntriesValues
2201 "Preset '" + value + "' [key:" + key + "] not implemented");
2204 // Custom options will now be enabled when the customiseCheckbox is checked
2205 // (performed above)
2206 // backupfilesCustomOptionsSetEnabled();
2207 updateBackupFilesExampleLabel();
2210 protected int getComboIntStringKey(
2211 JComboBox<Object> backupfilesPresetsCombo2)
2213 IntKeyStringValueEntry e;
2216 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2
2218 } catch (Exception ex)
2221 "Problem casting Combo entry to IntKeyStringValueEntry.");
2224 return e != null ? e.k : 0;
2227 protected void setComboIntStringKey(
2228 JComboBox<Object> backupfilesPresetsCombo2, int key)
2230 for (int i = 0; i < backupfilesPresetsCombo2.getItemCount(); i++)
2232 IntKeyStringValueEntry e;
2235 e = (IntKeyStringValueEntry) backupfilesPresetsCombo2.getItemAt(i);
2236 } catch (Exception ex)
2239 "Problem casting Combo entry to IntKeyStringValueEntry. Skipping item. ");
2244 backupfilesPresetsCombo2.setSelectedIndex(i);
2248 // backupsTabUpdatePresets();
2251 private JPanel initBackupsTabSuffixPanel()
2253 suffixPanel.setBorder(new TitledBorder(
2254 MessageManager.getString("label.backup_filename_strategy")));
2255 suffixPanel.setLayout(new GridBagLayout());
2258 .setText(MessageManager.getString("label.append_to_filename"));
2259 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
2260 suffixTemplateLabel.setFont(LABEL_FONT);
2262 final String tooltip = JvSwingUtils.wrapTooltip(true,
2263 MessageManager.getString("label.append_to_filename_tooltip"));
2264 suffixTemplate.setToolTipText(tooltip);
2265 suffixTemplate.addActionListener(new ActionListener()
2268 public void actionPerformed(ActionEvent e)
2270 updateBackupFilesExampleLabel();
2271 backupfilesCustomOptionsSetEnabled();
2272 backupfilesRevertButtonSetEnabled(true);
2276 suffixTemplate.addKeyListener(new KeyListener()
2279 public void keyReleased(KeyEvent e)
2281 updateBackupFilesExampleLabel();
2282 backupfilesCustomOptionsSetEnabled();
2283 backupfilesRevertButtonSetEnabled(true);
2287 public void keyPressed(KeyEvent e)
2291 // disable use of ':' or '/' or '\'
2293 public void keyTyped(KeyEvent e)
2295 char c = e.getKeyChar();
2296 if (c == ':' || c == '/' || c == '\\')
2298 // don't process ':' or '/' or '\'
2307 .setText(MessageManager.getString("label.index_digits"));
2308 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
2309 suffixDigitsLabel.setFont(LABEL_FONT);
2310 ChangeListener c = new ChangeListener()
2313 public void stateChanged(ChangeEvent e)
2315 backupfilesRevertButtonSetEnabled(true);
2316 updateBackupFilesExampleLabel();
2320 setIntegerSpinner(suffixDigitsSpinner, BackupFilesPresetEntry.DIGITSMIN,
2321 BackupFilesPresetEntry.DIGITSMAX, 3, c);
2323 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
2324 MessageManager.getString("label.increment_index"));
2325 suffixReverse.addActionListener(new ActionListener()
2328 public void actionPerformed(ActionEvent e)
2330 boolean okay = true;
2331 if (warnAboutSuffixReverseChange())
2334 okay = confirmSuffixReverseChange();
2338 backupfilesRevertButtonSetEnabled(true);
2339 updateBackupFilesExampleLabel();
2343 boolean savedSuffixReverse = BackupFilesPresetEntry
2344 .getSavedBackupEntry().reverse;
2345 suffixReverse.setSelected(savedSuffixReverse);
2350 GridBagConstraints sgbc = new GridBagConstraints();
2352 // first row (template text box)
2353 sgbc.anchor = GridBagConstraints.WEST;
2357 sgbc.gridheight = 1;
2360 sgbc.fill = GridBagConstraints.NONE;
2361 suffixPanel.add(suffixTemplateLabel, sgbc);
2364 sgbc.fill = GridBagConstraints.HORIZONTAL;
2365 suffixPanel.add(suffixTemplate, sgbc);
2367 // second row (number of digits spinner)
2371 sgbc.fill = GridBagConstraints.NONE;
2372 suffixPanel.add(suffixDigitsLabel, sgbc);
2375 sgbc.fill = GridBagConstraints.HORIZONTAL;
2376 suffixPanel.add(suffixDigitsSpinner, sgbc);
2378 // third row (forward order radio selection)
2381 sgbc.gridwidth = GridBagConstraints.REMAINDER;
2382 sgbc.fill = GridBagConstraints.HORIZONTAL;
2383 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
2385 // fourth row (reverse order radio selection)
2387 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
2391 private boolean confirmSuffixReverseChange()
2393 boolean ret = false;
2394 String warningMessage = MessageManager
2395 .getString("label.warning_confirm_change_reverse");
2396 int confirm = JvOptionPane.showConfirmDialog(Desktop.desktop,
2398 MessageManager.getString("label.change_increment_decrement"),
2399 JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE);
2401 ret = (confirm == JvOptionPane.YES_OPTION);
2405 private JPanel initBackupsTabKeepFilesPanel()
2407 keepfilesPanel.setBorder(
2408 new TitledBorder(MessageManager.getString("label.keep_files")));
2409 keepfilesPanel.setLayout(new GridBagLayout());
2411 backupfilesKeepAll.setLabels(
2412 MessageManager.getString("label.keep_all_backup_files"),
2413 MessageManager.getString(
2414 "label.keep_only_this_number_of_backup_files"));
2415 backupfilesKeepAll.addTrueActionListener(new ActionListener()
2418 public void actionPerformed(ActionEvent e)
2420 backupfilesRevertButtonSetEnabled(true);
2421 updateBackupFilesExampleLabel();
2424 backupfilesKeepAll.addActionListener(new ActionListener()
2427 public void actionPerformed(ActionEvent e)
2429 backupfilesRevertButtonSetEnabled(true);
2430 keepRollMaxOptionsEnabled();
2431 updateBackupFilesExampleLabel();
2435 ChangeListener c = new ChangeListener()
2438 public void stateChanged(ChangeEvent e)
2440 backupfilesRevertButtonSetEnabled(true);
2441 updateBackupFilesExampleLabel();
2445 setIntegerSpinner(backupfilesRollMaxSpinner,
2446 BackupFilesPresetEntry.ROLLMAXMIN,
2447 BackupFilesPresetEntry.ROLLMAXMAX, 4, true, c);
2449 backupfilesConfirmDelete.setLabels(
2450 MessageManager.getString("label.always_ask"),
2451 MessageManager.getString("label.auto_delete"));
2452 backupfilesConfirmDelete.addActionListener(new ActionListener()
2455 public void actionPerformed(ActionEvent e)
2457 backupfilesRevertButtonSetEnabled(true);
2460 // update the enabled section
2461 keepRollMaxOptionsEnabled();
2463 GridBagConstraints kgbc = new GridBagConstraints();
2465 // first row (template text box)
2466 kgbc.anchor = GridBagConstraints.WEST;
2469 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2470 kgbc.gridheight = 1;
2473 kgbc.fill = GridBagConstraints.HORIZONTAL;
2474 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
2480 kgbc.gridwidth = GridBagConstraints.RELATIVE;
2481 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
2484 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2485 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
2487 // third row (indented)
2489 kgbc.insets = new Insets(0, 20, 0, 0);
2492 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2493 kgbc.fill = GridBagConstraints.HORIZONTAL;
2496 JPanel jp = new JPanel();
2497 jp.setLayout(new FlowLayout());
2498 oldBackupFilesLabel.setText(
2499 MessageManager.getString("label.autodelete_old_backup_files"));
2500 oldBackupFilesLabel.setFont(LABEL_FONT);
2501 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
2502 jp.add(oldBackupFilesLabel);
2503 jp.add(backupfilesConfirmDelete.getTrueButton());
2504 jp.add(backupfilesConfirmDelete.getFalseButton());
2505 keepfilesPanel.add(jp, kgbc);
2507 return keepfilesPanel;
2510 protected void updateBackupFilesExampleLabel()
2512 int exampleindex = 12;
2513 String base = MessageManager.getString("label.filename") + ".fa";
2514 if (base == null || base.length() == 0)
2516 base = "file_name.fa";
2519 boolean reverse = suffixReverse.isSelected();
2520 boolean keepAll = backupfilesKeepAll.isSelected();
2522 String suffix = suffixTemplate.getText();
2525 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
2526 if (suffix == null || suffix.length() == 0)
2528 backupfilesExampleLabel
2529 .setText(MessageManager.getString("label.no_backup_files"));
2530 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
2534 rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 4);
2535 rollMax = rollMax < 1 ? 1 : rollMax;
2537 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
2542 digits = getSpinnerInt(suffixDigitsSpinner, 3);
2543 digits = digits < 1 ? 1 : digits;
2545 int lowersurround = 2;
2546 int uppersurround = 0;
2547 StringBuilder exampleSB = new StringBuilder();
2548 boolean firstLine = true;
2554 int max = keepAll ? exampleindex : rollMax;
2555 for (int index = min; index <= max; index++)
2557 if (index == min + lowersurround && index < max - uppersurround - 1)
2559 exampleSB.append("\n...");
2562 else if (index > min + lowersurround && index < max - uppersurround)
2574 exampleSB.append("\n");
2577 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2578 base, suffix, digits));
2581 // no extra text needed
2583 else if (index == min)
2585 String newest = MessageManager.getString("label.braced_newest");
2586 if (newest != null && newest.length() > 0)
2588 exampleSB.append(" " + newest);
2591 else if (index == max)
2593 String oldest = MessageManager.getString("label.braced_oldest");
2594 if (oldest != null && oldest.length() > 0)
2596 exampleSB.append(" " + oldest);
2605 int min = (keepAll || exampleindex - rollMax < 0) ? 1
2606 : exampleindex - rollMax + 1;
2607 int max = exampleindex;
2609 for (int index = min; index <= max; index++)
2612 if (index == min + lowersurround && index < max - uppersurround - 1)
2614 exampleSB.append("\n...");
2617 else if (index > min + lowersurround && index < max - uppersurround)
2629 exampleSB.append("\n");
2632 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2633 base, suffix, digits));
2636 // no extra text needed
2638 else if (index == min)
2640 String oldest = MessageManager.getString("label.braced_oldest");
2641 if (oldest != null && oldest.length() > 0)
2643 exampleSB.append(" " + oldest);
2646 else if (index == max)
2648 String newest = MessageManager.getString("label.braced_newest");
2649 if (newest != null && newest.length() > 0)
2651 exampleSB.append(" " + newest);
2659 // add some extra empty lines to pad out the example files box. ugh, please
2661 // me how to do this better
2662 int remainingLines = lowersurround + uppersurround + 1 - lineNumber;
2663 if (remainingLines > 0)
2665 for (int i = 0; i < remainingLines; i++)
2667 exampleSB.append("\n ");
2672 backupfilesExampleLabel.setText(exampleSB.toString());
2675 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2676 boolean useExistingVal, ChangeListener c)
2683 i = ((Integer) s.getValue()).intValue();
2684 } catch (Exception e)
2687 "Exception casting the initial value of s.getValue()");
2691 setIntegerSpinner(s, min, max, i, c);
2694 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2697 // integer spinner for number of digits
2706 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
2709 s.addChangeListener(c);
2713 protected static int getSpinnerInt(JSpinner s, int def)
2719 i = (Integer) s.getValue();
2720 } catch (Exception e)
2722 Cache.log.error("Failed casting (Integer) JSpinner s.getValue()");
2727 private void keepRollMaxOptionsEnabled()
2729 boolean enabled = backupfilesKeepAll.isEnabled()
2730 && !backupfilesKeepAll.isSelected();
2731 oldBackupFilesLabel.setEnabled(enabled);
2732 backupfilesRollMaxSpinner.setEnabled(enabled);
2733 backupfilesConfirmDelete.setEnabled(enabled);
2736 private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
2738 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2739 && customiseCheckbox.isSelected() && suffixTemplate.getText()
2740 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2741 keepfilesPanel.setEnabled(enabled);
2742 backupfilesKeepAll.setEnabled(enabled);
2743 oldBackupFilesLabel.setEnabled(enabled);
2744 keepRollMaxOptionsEnabled();
2747 private void backupfilesSuffixTemplateDigitsSetEnabled()
2749 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
2750 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2751 suffixDigitsLabel.setEnabled(enabled);
2752 suffixDigitsSpinner.setEnabled(enabled);
2753 suffixReverse.setEnabled(enabled);
2756 private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
2758 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2759 && customiseCheckbox.isSelected();
2760 suffixPanel.setEnabled(enabled);
2761 suffixTemplateLabel.setEnabled(enabled);
2762 suffixTemplate.setEnabled(enabled);
2763 backupfilesSuffixTemplateDigitsSetEnabled();
2766 private void backupfilesRevertButtonSetEnabled(boolean tryEnabled)
2768 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2769 && customiseCheckbox.isSelected() && backupfilesCustomChanged();
2770 revertButton.setEnabled(enabled);
2773 private boolean backupfilesCustomChanged()
2775 BackupFilesPresetEntry custom = BackupFilesPresetEntry.backupfilesPresetEntriesValues
2776 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2777 BackupFilesPresetEntry current = getBackupfilesCurrentEntry();
2778 return !custom.equals(current);
2781 protected BackupFilesPresetEntry getBackupfilesCurrentEntry()
2783 String suffix = suffixTemplate.getText();
2784 int digits = getSpinnerInt(suffixDigitsSpinner, 3);
2785 boolean reverse = suffixReverse.isSelected();
2786 boolean keepAll = backupfilesKeepAll.isSelected();
2787 int rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 3);
2788 boolean confirmDelete = backupfilesConfirmDelete.isSelected();
2790 BackupFilesPresetEntry bfpe = new BackupFilesPresetEntry(suffix, digits,
2791 reverse, keepAll, rollMax, confirmDelete);
2796 protected void backupfilesCustomOptionsSetEnabled()
2798 boolean enabled = customiseCheckbox.isSelected();
2800 backupfilesRevertButtonSetEnabled(enabled);
2801 backupfilesSuffixTemplateSetEnabled(enabled);
2802 backupfilesKeepAllSetEnabled(enabled);
2805 private void backupfilesSummarySetEnabled()
2807 boolean enabled = enableBackupFiles.isSelected();
2808 backupfilesExampleLabel.setEnabled(enabled);
2809 exampleFilesPanel.setEnabled(enabled);
2812 private void backupfilesPresetsSetEnabled()
2814 boolean enabled = enableBackupFiles.isSelected();
2815 presetsPanel.setEnabled(enabled);
2816 presetsComboLabel.setEnabled(enabled);
2817 backupfilesPresetsCombo.setEnabled(enabled);
2818 customiseCheckbox.setEnabled(enabled);
2819 revertButton.setEnabled(enabled);
2822 protected void backupsOptionsSetEnabled()
2824 backupfilesPresetsSetEnabled();
2825 backupfilesSummarySetEnabled();
2826 backupfilesCustomOptionsSetEnabled();
2829 protected void backupsSetOptions(String suffix, int digits,
2830 boolean reverse, boolean keepAll, int rollMax,
2831 boolean confirmDelete)
2833 suffixTemplate.setText(suffix);
2834 suffixDigitsSpinner.setValue(digits);
2835 suffixReverse.setSelected(reverse);
2836 backupfilesKeepAll.setSelected(keepAll);
2837 backupfilesRollMaxSpinner.setValue(rollMax);
2838 backupfilesConfirmDelete.setSelected(confirmDelete);
2841 protected void backupsSetOptions(BackupFilesPresetEntry p)
2843 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
2847 protected void autoIdWidth_actionPerformed()
2849 // TODO Auto-generated method stub
2853 protected void userIdWidth_actionPerformed()
2855 // TODO Auto-generated method stub
2859 protected void maxColour_actionPerformed(JPanel panel)
2863 protected void minColour_actionPerformed(JPanel panel)
2867 protected void gapColour_actionPerformed(JPanel panel)
2871 protected void hiddenColour_actionPerformed(JPanel panel)
2875 protected void showunconserved_actionPerformed(ActionEvent e)
2877 // TODO Auto-generated method stub
2881 protected void useLegacyGaps_actionPerformed(ActionEvent e)
2885 protected void resetOvDefaults_actionPerformed(ActionEvent e)
2895 public void ok_actionPerformed(ActionEvent e)
2905 public void cancel_actionPerformed(ActionEvent e)
2915 public void annotations_actionPerformed(ActionEvent e)
2922 public void startupFileTextfield_mouseClicked()
2926 public void newLink_actionPerformed(ActionEvent e)
2931 public void editLink_actionPerformed(ActionEvent e)
2936 public void deleteLink_actionPerformed(ActionEvent e)
2941 public void defaultBrowser_mouseClicked(MouseEvent e)
2946 public void linkURLList_keyTyped(KeyEvent e)
2951 public void setProxyAuthEnabled()
2953 boolean enabled = proxyAuth.isSelected() && proxyAuth.isEnabled();
2954 proxyAuthUsernameLabel.setEnabled(enabled);
2955 proxyAuthPasswordLabel.setEnabled(enabled);
2956 proxyAuthUsernameTB.setEnabled(enabled);
2957 proxyAuthPasswordTB.setEnabled(enabled);
2960 public void setCustomProxyEnabled()
2962 boolean enabled = customProxy.isSelected();
2963 portLabel.setEnabled(enabled);
2964 serverLabel.setEnabled(enabled);
2965 portLabel2.setEnabled(enabled);
2966 serverLabel2.setEnabled(enabled);
2967 httpLabel.setEnabled(enabled);
2968 httpsLabel.setEnabled(enabled);
2969 proxyServerHttpTB.setEnabled(enabled);
2970 proxyPortHttpTB.setEnabled(enabled);
2971 proxyServerHttpsTB.setEnabled(enabled);
2972 proxyPortHttpsTB.setEnabled(enabled);
2973 proxyAuth.setEnabled(enabled);
2974 setProxyAuthEnabled();
2977 public void proxyType_actionPerformed()
2979 setCustomProxyEnabled();
2982 public void proxyAuth_actionPerformed()
2984 setProxyAuthEnabled();
2988 * Customer renderer for JTable: supports column of radio buttons
2990 public class RadioButtonRenderer extends JRadioButton
2991 implements TableCellRenderer
2993 public RadioButtonRenderer()
2995 setHorizontalAlignment(CENTER);
2996 setToolTipText(MessageManager.getString("label.urltooltip"));
3000 public Component getTableCellRendererComponent(JTable table,
3001 Object value, boolean isSelected, boolean hasFocus, int row,
3004 setSelected((boolean) value);
3006 // set colours to match rest of table
3009 setBackground(table.getSelectionBackground());
3010 setForeground(table.getSelectionForeground());
3014 setBackground(table.getBackground());
3015 setForeground(table.getForeground());
3022 * Customer cell editor for JTable: supports column of radio buttons in
3023 * conjunction with renderer
3025 public class RadioButtonEditor extends AbstractCellEditor
3026 implements TableCellEditor
3028 private JRadioButton button = new JRadioButton();
3030 public RadioButtonEditor()
3032 button.setHorizontalAlignment(SwingConstants.CENTER);
3033 this.button.addActionListener(new ActionListener()
3036 public void actionPerformed(ActionEvent e)
3038 fireEditingStopped();
3044 public Component getTableCellEditorComponent(JTable table, Object value,
3045 boolean isSelected, int row, int column)
3047 button.setSelected((boolean) value);
3052 public Object getCellEditorValue()
3054 return button.isSelected();