2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.jbgui;
23 import jalview.bin.Cache;
24 import jalview.fts.core.FTSDataColumnPreferences;
25 import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource;
26 import jalview.fts.service.pdb.PDBFTSRestClient;
27 import jalview.gui.Desktop;
28 import jalview.gui.JalviewBooleanRadioButtons;
29 import jalview.gui.JvOptionPane;
30 import jalview.gui.JvSwingUtils;
31 import jalview.gui.StructureViewer.ViewerType;
32 import jalview.io.BackupFilenameParts;
33 import jalview.io.BackupFiles;
34 import jalview.io.BackupFilesPresetEntry;
35 import jalview.io.IntKeyStringValueEntry;
36 import jalview.util.MessageManager;
38 import java.awt.BorderLayout;
39 import java.awt.Color;
40 import java.awt.Component;
41 import java.awt.Dimension;
42 import java.awt.FlowLayout;
44 import java.awt.GridBagConstraints;
45 import java.awt.GridBagLayout;
46 import java.awt.GridLayout;
47 import java.awt.Insets;
48 import java.awt.Rectangle;
49 import java.awt.event.ActionEvent;
50 import java.awt.event.ActionListener;
51 import java.awt.event.FocusEvent;
52 import java.awt.event.KeyEvent;
53 import java.awt.event.KeyListener;
54 import java.awt.event.MouseAdapter;
55 import java.awt.event.MouseEvent;
57 import javax.swing.AbstractCellEditor;
58 import javax.swing.BorderFactory;
59 import javax.swing.ButtonGroup;
60 import javax.swing.DefaultListCellRenderer;
61 import javax.swing.JButton;
62 import javax.swing.JCheckBox;
63 import javax.swing.JComboBox;
64 import javax.swing.JFileChooser;
65 import javax.swing.JLabel;
66 import javax.swing.JPanel;
67 import javax.swing.JRadioButton;
68 import javax.swing.JScrollPane;
69 import javax.swing.JSpinner;
70 import javax.swing.JTabbedPane;
71 import javax.swing.JTable;
72 import javax.swing.JTextArea;
73 import javax.swing.JTextField;
74 import javax.swing.ListSelectionModel;
75 import javax.swing.SpinnerModel;
76 import javax.swing.SpinnerNumberModel;
77 import javax.swing.SwingConstants;
78 import javax.swing.border.Border;
79 import javax.swing.border.EmptyBorder;
80 import javax.swing.border.EtchedBorder;
81 import javax.swing.border.TitledBorder;
82 import javax.swing.event.ChangeEvent;
83 import javax.swing.event.ChangeListener;
84 import javax.swing.table.TableCellEditor;
85 import javax.swing.table.TableCellRenderer;
88 * Base class for the Preferences panel.
93 public class GPreferences extends JPanel
95 private static final Font LABEL_FONT = JvSwingUtils.getLabelFont();
97 private static final Font LABEL_FONT_ITALIC = JvSwingUtils
98 .getLabelFont(false, true);
100 private static final Font LABEL_FONT_BOLD = JvSwingUtils
101 .getLabelFont(true, false);
104 * Visual tab components
106 protected JCheckBox fullScreen = new JCheckBox();
108 protected JCheckBox openoverv = new JCheckBox();
110 protected JCheckBox seqLimit = new JCheckBox();
112 protected JCheckBox rightAlign = new JCheckBox();
114 protected JComboBox<String> fontSizeCB = new JComboBox<>();
116 protected JComboBox<String> fontStyleCB = new JComboBox<>();
118 protected JComboBox<String> fontNameCB = new JComboBox<>();
120 protected JCheckBox showOccupancy = new JCheckBox();
122 protected JCheckBox showUnconserved = new JCheckBox();
124 protected JCheckBox idItalics = new JCheckBox();
126 protected JCheckBox smoothFont = new JCheckBox();
128 protected JCheckBox scaleProteinToCdna = new JCheckBox();
130 protected JComboBox<String> gapSymbolCB = new JComboBox<>();
132 protected JCheckBox wrap = new JCheckBox();
134 protected JComboBox<String> sortby = new JComboBox<>();
136 protected JComboBox<String> sortAnnBy = new JComboBox<>();
138 protected JComboBox<String> sortAutocalc = new JComboBox<>();
140 protected JCheckBox startupCheckbox = new JCheckBox();
142 protected JTextField startupFileTextfield = new JTextField();
144 // below are in the 'second column'
145 protected JCheckBox annotations = new JCheckBox();
147 protected JCheckBox quality = new JCheckBox();
149 protected JCheckBox conservation = new JCheckBox();
151 protected JCheckBox identity = new JCheckBox();
153 protected JCheckBox showGroupConsensus = new JCheckBox();
155 protected JCheckBox showGroupConservation = new JCheckBox();
157 protected JCheckBox showConsensHistogram = new JCheckBox();
159 protected JCheckBox showConsensLogo = new JCheckBox();
161 protected JCheckBox showDbRefTooltip = new JCheckBox();
163 protected JCheckBox showNpTooltip = new JCheckBox();
166 * Structure tab and components
168 protected JPanel structureTab;
170 protected JCheckBox structFromPdb = new JCheckBox();
172 protected JCheckBox useRnaView = new JCheckBox();
174 protected JCheckBox addSecondaryStructure = new JCheckBox();
176 protected JCheckBox addTempFactor = new JCheckBox();
178 protected JComboBox<String> structViewer = new JComboBox<>();
180 protected JTextField chimeraPath = new JTextField();
182 protected ButtonGroup mappingMethod = new ButtonGroup();
184 protected JRadioButton siftsMapping = new JRadioButton();
186 protected JRadioButton nwMapping = new JRadioButton();
189 * Colours tab components
191 protected JPanel minColour = new JPanel();
193 protected JPanel maxColour = new JPanel();
195 protected JComboBox<String> protColour = new JComboBox<>();
197 protected JComboBox<String> nucColour = new JComboBox<>();
200 * Overview tab components
202 protected JPanel gapColour = new JPanel();
204 protected JPanel hiddenColour = new JPanel();
206 protected JCheckBox useLegacyGap;
208 protected JCheckBox showHiddenAtStart;
210 protected JLabel gapLabel;
213 * Connections tab components
215 protected JTable linkUrlTable = new JTable();
217 protected JButton editLink = new JButton();
219 protected JButton deleteLink = new JButton();
221 protected JTextField filterTB = new JTextField();
223 protected JButton doReset = new JButton();
225 protected JButton userOnly = new JButton();
227 protected JLabel portLabel = new JLabel();
229 protected JLabel serverLabel = new JLabel();
231 protected JTextField proxyServerTB = new JTextField();
233 protected JTextField proxyPortTB = new JTextField();
235 protected JTextField defaultBrowser = new JTextField();
237 protected JCheckBox useProxy = new JCheckBox();
239 protected JCheckBox usagestats = new JCheckBox();
241 protected JCheckBox questionnaire = new JCheckBox();
243 protected JCheckBox versioncheck = new JCheckBox();
246 * Output tab components
248 protected JComboBox<Object> epsRendering = new JComboBox<>();
250 protected JLabel userIdWidthlabel = new JLabel();
252 protected JCheckBox autoIdWidth = new JCheckBox();
254 protected JTextField userIdWidth = new JTextField();
256 protected JCheckBox blcjv = new JCheckBox();
258 protected JCheckBox pileupjv = new JCheckBox();
260 protected JCheckBox clustaljv = new JCheckBox();
262 protected JCheckBox msfjv = new JCheckBox();
264 protected JCheckBox fastajv = new JCheckBox();
266 protected JCheckBox pfamjv = new JCheckBox();
268 protected JCheckBox pirjv = new JCheckBox();
270 protected JCheckBox modellerOutput = new JCheckBox();
272 protected JCheckBox embbedBioJSON = new JCheckBox();
275 * Editing tab components
277 protected JCheckBox autoCalculateConsCheck = new JCheckBox();
279 protected JCheckBox padGaps = new JCheckBox();
281 protected JCheckBox sortByTree = new JCheckBox();
286 protected JPanel wsTab = new JPanel();
289 * Backups tab components
290 * a lot of these are member variables instead of local variables only so that they
291 * can be enabled/disabled easily in one go
294 protected JCheckBox enableBackupFiles = new JCheckBox();
296 protected JPanel presetsPanel = new JPanel();
298 protected JLabel presetsComboLabel = new JLabel();
300 protected JCheckBox customiseCheckbox = new JCheckBox();
302 protected JButton revertButton = new JButton();
304 protected JComboBox<IntKeyStringValueEntry> backupfilesPresetsCombo = new JComboBox<>();
306 private int backupfilesPresetsComboLastSelected = 0;
308 protected JPanel suffixPanel = new JPanel();
310 protected JPanel keepfilesPanel = new JPanel();
312 protected JPanel exampleFilesPanel = new JPanel();
314 protected JTextField suffixTemplate = new JTextField(null, 8);
316 protected JLabel suffixTemplateLabel = new JLabel();
318 protected JLabel suffixDigitsLabel = new JLabel();
320 protected JSpinner suffixDigitsSpinner = new JSpinner();
322 protected JalviewBooleanRadioButtons suffixReverse = new JalviewBooleanRadioButtons();
324 protected JalviewBooleanRadioButtons backupfilesKeepAll = new JalviewBooleanRadioButtons();
326 public JSpinner backupfilesRollMaxSpinner = new JSpinner();
328 protected JLabel oldBackupFilesLabel = new JLabel();
330 protected JalviewBooleanRadioButtons backupfilesConfirmDelete = new JalviewBooleanRadioButtons();
332 protected JTextArea backupfilesExampleLabel = new JTextArea();
335 * Creates a new GPreferences object.
337 public GPreferences()
342 } catch (Exception ex)
344 ex.printStackTrace();
349 * Construct the panel and its tabbed sub-panels.
353 private void jbInit() throws Exception
355 final JTabbedPane tabbedPane = new JTabbedPane();
356 this.setLayout(new BorderLayout());
357 JPanel okCancelPanel = initOkCancelPanel();
358 this.add(tabbedPane, BorderLayout.CENTER);
359 this.add(okCancelPanel, BorderLayout.SOUTH);
361 tabbedPane.add(initVisualTab(),
362 MessageManager.getString("label.visual"));
364 tabbedPane.add(initColoursTab(),
365 MessageManager.getString("label.colours"));
367 tabbedPane.add(initOverviewTab(),
368 MessageManager.getString("label.overview"));
370 tabbedPane.add(initStructureTab(),
371 MessageManager.getString("label.structure"));
373 tabbedPane.add(initConnectionsTab(),
374 MessageManager.getString("label.connections"));
376 tabbedPane.add(initBackupsTab(),
377 MessageManager.getString("label.backups"));
379 tabbedPane.add(initLinksTab(),
380 MessageManager.getString("label.urllinks"));
382 tabbedPane.add(initOutputTab(),
383 MessageManager.getString("label.output"));
385 tabbedPane.add(initEditingTab(),
386 MessageManager.getString("label.editing"));
389 * See WsPreferences for the real work of configuring this tab.
391 wsTab.setLayout(new BorderLayout());
392 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
395 * Handler to validate a tab before leaving it - currently only for
398 tabbedPane.addChangeListener(new ChangeListener()
400 private Component lastTab;
403 public void stateChanged(ChangeEvent e)
405 if (lastTab == structureTab
406 && tabbedPane.getSelectedComponent() != structureTab)
408 if (!validateStructure())
410 tabbedPane.setSelectedComponent(structureTab);
414 lastTab = tabbedPane.getSelectedComponent();
421 * Initialises the Editing tabbed panel.
425 private JPanel initEditingTab()
427 JPanel editingTab = new JPanel();
428 editingTab.setLayout(null);
429 autoCalculateConsCheck.setFont(LABEL_FONT);
430 autoCalculateConsCheck.setText(
431 MessageManager.getString("label.autocalculate_consensus"));
432 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
433 padGaps.setFont(LABEL_FONT);
435 MessageManager.getString("label.pad_gaps_when_editing"));
436 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
437 sortByTree.setFont(LABEL_FONT);
439 .setText(MessageManager.getString("label.sort_with_new_tree"));
440 sortByTree.setToolTipText(MessageManager.getString(
441 "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
442 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
443 editingTab.add(autoCalculateConsCheck);
444 editingTab.add(padGaps);
445 editingTab.add(sortByTree);
450 * Initialises the Output tabbed panel.
454 private JPanel initOutputTab()
456 JPanel outputTab = new JPanel();
457 outputTab.setLayout(null);
458 JLabel epsLabel = new JLabel();
459 epsLabel.setFont(LABEL_FONT);
460 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
461 epsLabel.setText(MessageManager.getString("label.eps_rendering_style"));
462 epsLabel.setBounds(new Rectangle(9, 31, 140, 24));
463 epsRendering.setFont(LABEL_FONT);
464 epsRendering.setBounds(new Rectangle(154, 34, 187, 21));
465 JLabel jLabel1 = new JLabel();
466 jLabel1.setFont(LABEL_FONT);
467 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
468 jLabel1.setText(MessageManager.getString("label.append_start_end"));
469 jLabel1.setFont(LABEL_FONT);
470 fastajv.setFont(LABEL_FONT);
471 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
472 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
473 blcjv.setText(MessageManager.getString("label.blc") + " ");
474 fastajv.setText(MessageManager.getString("label.fasta") + " ");
475 msfjv.setText(MessageManager.getString("label.msf") + " ");
476 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
477 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
478 msfjv.setFont(LABEL_FONT);
479 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
480 pirjv.setText(MessageManager.getString("label.pir") + " ");
481 JPanel jPanel11 = new JPanel();
482 jPanel11.setFont(LABEL_FONT);
483 TitledBorder titledBorder2 = new TitledBorder(
484 MessageManager.getString("label.file_output"));
485 jPanel11.setBorder(titledBorder2);
486 jPanel11.setBounds(new Rectangle(30, 72, 196, 182));
487 GridLayout gridLayout3 = new GridLayout();
488 jPanel11.setLayout(gridLayout3);
489 gridLayout3.setRows(8);
490 blcjv.setFont(LABEL_FONT);
491 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
492 clustaljv.setFont(LABEL_FONT);
493 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
494 pfamjv.setFont(LABEL_FONT);
495 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
496 pileupjv.setFont(LABEL_FONT);
497 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
498 pirjv.setFont(LABEL_FONT);
499 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
500 autoIdWidth.setFont(LABEL_FONT);
502 MessageManager.getString("label.automatically_set_id_width"));
503 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
504 .getString("label.adjusts_width_generated_eps_png")));
505 autoIdWidth.setBounds(new Rectangle(228, 96, 188, 23));
506 autoIdWidth.addActionListener(new ActionListener()
510 public void actionPerformed(ActionEvent e)
512 autoIdWidth_actionPerformed();
515 userIdWidthlabel.setFont(LABEL_FONT);
516 userIdWidthlabel.setText(
517 MessageManager.getString("label.figure_id_column_width"));
518 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
519 .getString("label.manually_specify_width_left_column")));
520 userIdWidthlabel.setToolTipText(
521 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
522 "label.manually_specify_width_left_column")));
523 userIdWidthlabel.setBounds(new Rectangle(236, 120, 168, 23));
524 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
525 userIdWidth.setText("");
526 userIdWidth.setBounds(new Rectangle(232, 144, 84, 23));
527 userIdWidth.addActionListener(new ActionListener()
531 public void actionPerformed(ActionEvent e)
533 userIdWidth_actionPerformed();
536 modellerOutput.setFont(LABEL_FONT);
538 .setText(MessageManager.getString("label.use_modeller_output"));
539 modellerOutput.setBounds(new Rectangle(228, 226, 168, 23));
540 embbedBioJSON.setFont(LABEL_FONT);
541 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
542 embbedBioJSON.setBounds(new Rectangle(228, 200, 250, 23));
544 jPanel11.add(jLabel1);
546 jPanel11.add(clustaljv);
547 jPanel11.add(fastajv);
549 jPanel11.add(pfamjv);
550 jPanel11.add(pileupjv);
552 outputTab.add(autoIdWidth);
553 outputTab.add(userIdWidth);
554 outputTab.add(userIdWidthlabel);
555 outputTab.add(modellerOutput);
556 outputTab.add(embbedBioJSON);
557 outputTab.add(epsLabel);
558 outputTab.add(epsRendering);
559 outputTab.add(jPanel11);
564 * Initialises the Connections tabbed panel.
568 private JPanel initConnectionsTab()
570 JPanel connectTab = new JPanel();
571 connectTab.setLayout(new GridBagLayout());
573 // Label for browser text box
574 JLabel browserLabel = new JLabel();
575 browserLabel.setFont(LABEL_FONT);
576 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
577 browserLabel.setText(
578 MessageManager.getString("label.default_browser_unix"));
579 defaultBrowser.setFont(LABEL_FONT);
580 defaultBrowser.setText("");
581 final String tooltip = JvSwingUtils.wrapTooltip(true,
582 MessageManager.getString("label.double_click_to_browse"));
583 defaultBrowser.setToolTipText(tooltip);
584 defaultBrowser.addMouseListener(new MouseAdapter()
587 public void mouseClicked(MouseEvent e)
589 if (e.getClickCount() > 1)
591 defaultBrowser_mouseClicked(e);
596 JPanel proxyPanel = initConnTabProxyPanel();
597 initConnTabCheckboxes();
599 // Add default Browser text box
600 connectTab.add(browserLabel,
601 new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
602 GridBagConstraints.WEST, GridBagConstraints.NONE,
603 new Insets(10, 0, 5, 5), 5, 1));
604 defaultBrowser.setFont(LABEL_FONT);
605 defaultBrowser.setText("");
607 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
608 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
609 new Insets(10, 0, 5, 10), 30, 1));
611 // Add proxy server panel
612 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
613 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
614 new Insets(10, 0, 5, 12), 4, 10));
616 // Add usage stats, version check and questionnaire checkboxes
617 connectTab.add(usagestats,
618 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
619 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
620 new Insets(0, 2, 5, 5), 70, 1));
621 connectTab.add(questionnaire,
622 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
623 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
624 new Insets(0, 2, 5, 10), 70, 1));
625 connectTab.add(versioncheck,
626 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
627 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
628 new Insets(0, 2, 5, 5), 70, 1));
630 // Add padding so the panel doesn't look ridiculous
631 JPanel spacePanel = new JPanel();
632 connectTab.add(spacePanel,
633 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
634 GridBagConstraints.WEST, GridBagConstraints.BOTH,
635 new Insets(0, 0, 0, 5), 70, 1));
641 * Initialises the Links tabbed panel.
645 private JPanel initLinksTab()
647 JPanel linkTab = new JPanel();
648 linkTab.setLayout(new GridBagLayout());
650 // Set up table for Url links
651 linkUrlTable.getTableHeader().setReorderingAllowed(false);
652 linkUrlTable.setFillsViewportHeight(true);
653 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
654 linkUrlTable.setAutoCreateRowSorter(true);
655 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
657 // adjust row height so radio buttons actually fit
658 // don't do this in the renderer, it causes the awt thread to activate
660 JRadioButton temp = new JRadioButton();
661 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
663 // Table in scrollpane so that the table is given a scrollbar
664 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
665 linkScrollPane.setBorder(null);
667 // Panel for links functionality
668 JPanel linkPanel = new JPanel(new GridBagLayout());
669 linkPanel.setBorder(new TitledBorder(
670 MessageManager.getString("label.url_linkfrom_sequence_id")));
672 // Put the Url links panel together
674 // Buttons go at top right, resizing only resizes the blank space vertically
675 JPanel buttonPanel = initLinkTabUrlButtons();
676 GridBagConstraints linkConstraints1 = new GridBagConstraints();
677 linkConstraints1.insets = new Insets(0, 0, 5, 0);
678 linkConstraints1.gridx = 0;
679 linkConstraints1.gridy = 0;
680 linkConstraints1.weightx = 1.0;
681 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
682 linkTab.add(buttonPanel, linkConstraints1);
684 // Links table goes at top left, resizing resizes the table
685 GridBagConstraints linkConstraints2 = new GridBagConstraints();
686 linkConstraints2.insets = new Insets(0, 0, 5, 5);
687 linkConstraints2.gridx = 0;
688 linkConstraints2.gridy = 1;
689 linkConstraints2.weightx = 1.0;
690 linkConstraints2.weighty = 1.0;
691 linkConstraints2.fill = GridBagConstraints.BOTH;
692 linkTab.add(linkScrollPane, linkConstraints2);
694 // Filter box and buttons goes at bottom left, resizing resizes the text box
695 JPanel filterPanel = initLinkTabFilterPanel();
696 GridBagConstraints linkConstraints3 = new GridBagConstraints();
697 linkConstraints3.insets = new Insets(0, 0, 0, 5);
698 linkConstraints3.gridx = 0;
699 linkConstraints3.gridy = 2;
700 linkConstraints3.weightx = 1.0;
701 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
702 linkTab.add(filterPanel, linkConstraints3);
707 private JPanel initLinkTabFilterPanel()
709 // Filter textbox and reset button
710 JLabel filterLabel = new JLabel(
711 MessageManager.getString("label.filter"));
712 filterLabel.setFont(LABEL_FONT);
713 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
714 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
716 filterTB.setFont(LABEL_FONT);
717 filterTB.setText("");
719 doReset.setText(MessageManager.getString("action.showall"));
720 userOnly.setText(MessageManager.getString("action.customfilter"));
722 // Panel for filter functionality
723 JPanel filterPanel = new JPanel(new GridBagLayout());
724 filterPanel.setBorder(new TitledBorder("Filter"));
725 GridBagConstraints gbc = new GridBagConstraints();
728 gbc.fill = GridBagConstraints.NONE;
729 gbc.anchor = GridBagConstraints.WEST;
731 filterPanel.add(filterLabel, gbc);
733 GridBagConstraints gbc1 = new GridBagConstraints();
736 gbc1.fill = GridBagConstraints.HORIZONTAL;
737 gbc1.anchor = GridBagConstraints.WEST;
739 filterPanel.add(filterTB, gbc1);
741 GridBagConstraints gbc2 = new GridBagConstraints();
743 gbc2.fill = GridBagConstraints.NONE;
744 gbc2.anchor = GridBagConstraints.WEST;
745 filterPanel.add(doReset, gbc2);
747 GridBagConstraints gbc3 = new GridBagConstraints();
749 gbc3.fill = GridBagConstraints.NONE;
750 gbc3.anchor = GridBagConstraints.WEST;
751 filterPanel.add(userOnly, gbc3);
756 private JPanel initLinkTabUrlButtons()
758 // Buttons for new / edit / delete Url links
759 JButton newLink = new JButton();
760 newLink.setText(MessageManager.getString("action.new"));
762 editLink.setText(MessageManager.getString("action.edit"));
764 deleteLink.setText(MessageManager.getString("action.delete"));
766 // no current selection, so initially disable delete/edit buttons
767 editLink.setEnabled(false);
768 deleteLink.setEnabled(false);
770 newLink.addActionListener(new java.awt.event.ActionListener()
773 public void actionPerformed(ActionEvent e)
775 newLink_actionPerformed(e);
779 editLink.setText(MessageManager.getString("action.edit"));
780 editLink.addActionListener(new java.awt.event.ActionListener()
783 public void actionPerformed(ActionEvent e)
785 editLink_actionPerformed(e);
789 deleteLink.setText(MessageManager.getString("action.delete"));
790 deleteLink.addActionListener(new java.awt.event.ActionListener()
793 public void actionPerformed(ActionEvent e)
795 deleteLink_actionPerformed(e);
799 JPanel buttonPanel = new JPanel(new GridBagLayout());
800 buttonPanel.setBorder(new TitledBorder("Edit links"));
801 GridBagConstraints gbc = new GridBagConstraints();
804 gbc.fill = GridBagConstraints.NONE;
805 buttonPanel.add(newLink, gbc);
807 GridBagConstraints gbc1 = new GridBagConstraints();
810 gbc1.fill = GridBagConstraints.NONE;
811 buttonPanel.add(editLink, gbc1);
813 GridBagConstraints gbc2 = new GridBagConstraints();
816 gbc2.fill = GridBagConstraints.NONE;
817 buttonPanel.add(deleteLink, gbc2);
819 GridBagConstraints gbc3 = new GridBagConstraints();
822 gbc3.fill = GridBagConstraints.HORIZONTAL;
824 JPanel spacePanel = new JPanel();
825 spacePanel.setBorder(null);
826 buttonPanel.add(spacePanel, gbc3);
832 * Initialises the proxy server panel in the Connections tab
834 * @return the proxy server panel
836 private JPanel initConnTabProxyPanel()
838 // Label for server text box
839 serverLabel.setText(MessageManager.getString("label.address"));
840 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
841 serverLabel.setFont(LABEL_FONT);
843 // Proxy server and port text boxes
844 proxyServerTB.setFont(LABEL_FONT);
845 proxyPortTB.setFont(LABEL_FONT);
847 // Label for Port text box
848 portLabel.setFont(LABEL_FONT);
849 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
850 portLabel.setText(MessageManager.getString("label.port"));
852 // Use proxy server checkbox
853 useProxy.setFont(LABEL_FONT);
854 useProxy.setHorizontalAlignment(SwingConstants.RIGHT);
855 useProxy.setHorizontalTextPosition(SwingConstants.LEADING);
856 useProxy.setText(MessageManager.getString("label.use_proxy_server"));
857 useProxy.addActionListener(new ActionListener()
860 public void actionPerformed(ActionEvent e)
862 useProxy_actionPerformed();
866 // Make proxy server panel
867 JPanel proxyPanel = new JPanel();
868 TitledBorder titledBorder1 = new TitledBorder(
869 MessageManager.getString("label.proxy_server"));
870 proxyPanel.setBorder(titledBorder1);
871 proxyPanel.setLayout(new GridBagLayout());
872 proxyPanel.add(serverLabel,
873 new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
874 GridBagConstraints.WEST, GridBagConstraints.NONE,
875 new Insets(0, 2, 2, 0), 5, 0));
876 proxyPanel.add(portLabel,
877 new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
878 GridBagConstraints.WEST, GridBagConstraints.NONE,
879 new Insets(0, 0, 2, 0), 11, 0));
880 proxyPanel.add(useProxy,
881 new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
882 GridBagConstraints.WEST, GridBagConstraints.NONE,
883 new Insets(0, 2, 5, 185), 2, -4));
884 proxyPanel.add(proxyPortTB,
885 new GridBagConstraints(3, 1, 1, 1, 1.0, 0.0,
886 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
887 new Insets(0, 2, 2, 2), 54, 1));
888 proxyPanel.add(proxyServerTB,
889 new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0,
890 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
891 new Insets(0, 2, 2, 0), 263, 1));
897 * Initialises the checkboxes in the Connections tab
899 private void initConnTabCheckboxes()
901 // Usage stats checkbox label
903 MessageManager.getString("label.send_usage_statistics"));
904 usagestats.setFont(LABEL_FONT);
905 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
906 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
908 // Questionnaire checkbox label
909 questionnaire.setText(
910 MessageManager.getString("label.check_for_questionnaires"));
911 questionnaire.setFont(LABEL_FONT);
912 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
913 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
915 // Check for latest version checkbox label
916 versioncheck.setText(
917 MessageManager.getString("label.check_for_latest_version"));
918 versioncheck.setFont(LABEL_FONT);
919 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
920 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
924 * Initialises the parent panel which contains the tabbed sections.
928 private JPanel initOkCancelPanel()
930 JButton ok = new JButton();
931 ok.setText(MessageManager.getString("action.ok"));
932 ok.addActionListener(new ActionListener()
935 public void actionPerformed(ActionEvent e)
937 ok_actionPerformed(e);
940 JButton cancel = new JButton();
941 cancel.setText(MessageManager.getString("action.cancel"));
942 cancel.addActionListener(new ActionListener()
945 public void actionPerformed(ActionEvent e)
947 cancel_actionPerformed(e);
950 JPanel okCancelPanel = new JPanel();
951 okCancelPanel.add(ok);
952 okCancelPanel.add(cancel);
953 return okCancelPanel;
957 * Initialises the Colours tabbed panel.
961 private JPanel initColoursTab()
963 JPanel coloursTab = new JPanel();
964 coloursTab.setBorder(new TitledBorder(
965 MessageManager.getString("action.open_new_alignment")));
966 coloursTab.setLayout(new FlowLayout());
967 JLabel mincolourLabel = new JLabel();
968 mincolourLabel.setFont(LABEL_FONT);
969 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
970 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
971 minColour.setFont(LABEL_FONT);
972 minColour.setBorder(BorderFactory.createEtchedBorder());
973 minColour.setPreferredSize(new Dimension(40, 20));
974 minColour.addMouseListener(new MouseAdapter()
977 public void mousePressed(MouseEvent e)
979 minColour_actionPerformed(minColour);
982 JLabel maxcolourLabel = new JLabel();
983 maxcolourLabel.setFont(LABEL_FONT);
984 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
985 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
986 maxColour.setFont(LABEL_FONT);
987 maxColour.setBorder(BorderFactory.createEtchedBorder());
988 maxColour.setPreferredSize(new Dimension(40, 20));
989 maxColour.addMouseListener(new MouseAdapter()
992 public void mousePressed(MouseEvent e)
994 maxColour_actionPerformed(maxColour);
998 protColour.setFont(LABEL_FONT);
999 protColour.setBounds(new Rectangle(172, 225, 155, 21));
1000 JLabel protColourLabel = new JLabel();
1001 protColourLabel.setFont(LABEL_FONT);
1002 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1003 protColourLabel.setText(
1004 MessageManager.getString("label.prot_alignment_colour") + " ");
1005 JvSwingUtils.addtoLayout(coloursTab,
1007 .getString("label.default_colour_scheme_for_alignment"),
1008 protColourLabel, protColour);
1010 nucColour.setFont(LABEL_FONT);
1011 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1012 JLabel nucColourLabel = new JLabel();
1013 nucColourLabel.setFont(LABEL_FONT);
1014 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1015 nucColourLabel.setText(
1016 MessageManager.getString("label.nuc_alignment_colour") + " ");
1017 JvSwingUtils.addtoLayout(coloursTab,
1019 .getString("label.default_colour_scheme_for_alignment"),
1020 nucColourLabel, nucColour);
1022 JPanel annotationShding = new JPanel();
1023 annotationShding.setBorder(new TitledBorder(
1024 MessageManager.getString("label.annotation_shading_default")));
1025 annotationShding.setLayout(new GridLayout(1, 2));
1026 JvSwingUtils.addtoLayout(annotationShding,
1027 MessageManager.getString(
1028 "label.default_minimum_colour_annotation_shading"),
1029 mincolourLabel, minColour);
1030 JvSwingUtils.addtoLayout(annotationShding,
1031 MessageManager.getString(
1032 "label.default_maximum_colour_annotation_shading"),
1033 maxcolourLabel, maxColour);
1034 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1039 * Initialises the Overview tabbed panel.
1043 private JPanel initOverviewTab()
1045 JPanel overviewPanel = new JPanel();
1046 overviewPanel.setBorder(new TitledBorder(
1047 MessageManager.getString("label.overview_settings")));
1049 gapColour.setFont(LABEL_FONT);
1050 // fixing the border colours stops apparent colour bleed from the panel
1051 gapColour.setBorder(
1052 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1053 gapColour.setPreferredSize(new Dimension(40, 20));
1054 gapColour.addMouseListener(new MouseAdapter()
1057 public void mousePressed(MouseEvent e)
1059 gapColour_actionPerformed(gapColour);
1063 hiddenColour.setFont(LABEL_FONT);
1064 // fixing the border colours stops apparent colour bleed from the panel
1065 hiddenColour.setBorder(
1066 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1067 hiddenColour.setPreferredSize(new Dimension(40, 20));
1068 hiddenColour.addMouseListener(new MouseAdapter()
1071 public void mousePressed(MouseEvent e)
1073 hiddenColour_actionPerformed(hiddenColour);
1077 useLegacyGap = new JCheckBox(
1078 MessageManager.getString("label.ov_legacy_gap"));
1079 useLegacyGap.setFont(LABEL_FONT);
1080 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1081 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1082 gapLabel = new JLabel(MessageManager.getString("label.gap_colour"));
1083 gapLabel.setFont(LABEL_FONT);
1084 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1085 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1086 showHiddenAtStart = new JCheckBox(
1087 MessageManager.getString("label.ov_show_hide_default"));
1088 showHiddenAtStart.setFont(LABEL_FONT);
1089 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1090 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1091 JLabel hiddenLabel = new JLabel(
1092 MessageManager.getString("label.hidden_colour"));
1093 hiddenLabel.setFont(LABEL_FONT);
1094 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1095 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1097 useLegacyGap.addActionListener(new ActionListener()
1100 public void actionPerformed(ActionEvent e)
1102 useLegacyGaps_actionPerformed(e);
1106 overviewPanel.setLayout(new GridBagLayout());
1107 GridBagConstraints c1 = new GridBagConstraints();
1109 c1.fill = GridBagConstraints.HORIZONTAL;
1114 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1115 overviewPanel.add(useLegacyGap, c1);
1117 GridBagConstraints c2 = new GridBagConstraints();
1118 c2.fill = GridBagConstraints.HORIZONTAL;
1121 c2.insets = new Insets(0, 15, 0, 10);
1122 overviewPanel.add(gapLabel, c2);
1124 GridBagConstraints c3 = new GridBagConstraints();
1125 c3.fill = GridBagConstraints.HORIZONTAL;
1128 c3.insets = new Insets(0, 0, 0, 15);
1129 overviewPanel.add(gapColour, c3);
1131 GridBagConstraints c4 = new GridBagConstraints();
1132 c4.fill = GridBagConstraints.HORIZONTAL;
1136 overviewPanel.add(showHiddenAtStart, c4);
1138 GridBagConstraints c5 = new GridBagConstraints();
1139 c5.fill = GridBagConstraints.HORIZONTAL;
1142 c5.insets = new Insets(0, 15, 0, 10);
1143 overviewPanel.add(hiddenLabel, c5);
1145 GridBagConstraints c6 = new GridBagConstraints();
1146 c6.fill = GridBagConstraints.HORIZONTAL;
1149 c6.insets = new Insets(0, 0, 0, 15);
1150 overviewPanel.add(hiddenColour, c6);
1152 JButton resetButton = new JButton(
1153 MessageManager.getString("label.reset_to_defaults"));
1155 resetButton.addActionListener(new ActionListener()
1158 public void actionPerformed(ActionEvent e)
1160 resetOvDefaults_actionPerformed(e);
1164 GridBagConstraints c7 = new GridBagConstraints();
1165 c7.fill = GridBagConstraints.NONE;
1168 c7.insets = new Insets(10, 0, 0, 0);
1169 c7.anchor = GridBagConstraints.WEST;
1170 overviewPanel.add(resetButton, c7);
1172 // Add padding so the panel doesn't look ridiculous
1173 JPanel spacePanel = new JPanel();
1174 overviewPanel.add(spacePanel,
1175 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1176 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1177 new Insets(0, 0, 0, 5), 0, 0));
1179 return overviewPanel;
1183 * Initialises the Structure tabbed panel.
1187 private JPanel initStructureTab()
1189 structureTab = new JPanel();
1191 structureTab.setBorder(new TitledBorder(
1192 MessageManager.getString("label.structure_options")));
1193 structureTab.setLayout(null);
1194 final int width = 400;
1195 final int height = 22;
1196 final int lineSpacing = 25;
1199 structFromPdb.setFont(LABEL_FONT);
1201 .setText(MessageManager.getString("label.struct_from_pdb"));
1202 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1203 structFromPdb.addActionListener(new ActionListener()
1206 public void actionPerformed(ActionEvent e)
1208 boolean selected = structFromPdb.isSelected();
1209 // enable other options only when the first is checked
1210 useRnaView.setEnabled(selected);
1211 addSecondaryStructure.setEnabled(selected);
1212 addTempFactor.setEnabled(selected);
1215 structureTab.add(structFromPdb);
1217 // indent checkboxes that are conditional on the first one
1218 ypos += lineSpacing;
1219 useRnaView.setFont(LABEL_FONT);
1220 useRnaView.setText(MessageManager.getString("label.use_rnaview"));
1221 useRnaView.setBounds(new Rectangle(25, ypos, width, height));
1222 structureTab.add(useRnaView);
1224 ypos += lineSpacing;
1225 addSecondaryStructure.setFont(LABEL_FONT);
1226 addSecondaryStructure
1227 .setText(MessageManager.getString("label.autoadd_secstr"));
1228 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1229 structureTab.add(addSecondaryStructure);
1231 ypos += lineSpacing;
1232 addTempFactor.setFont(LABEL_FONT);
1233 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1234 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1235 structureTab.add(addTempFactor);
1237 ypos += lineSpacing;
1238 JLabel viewerLabel = new JLabel();
1239 viewerLabel.setFont(LABEL_FONT);
1240 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1241 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1242 viewerLabel.setBounds(new Rectangle(10, ypos, 200, height));
1243 structureTab.add(viewerLabel);
1245 structViewer.setFont(LABEL_FONT);
1246 structViewer.setBounds(new Rectangle(160, ypos, 120, height));
1247 structViewer.addItem(ViewerType.JMOL.name());
1248 structViewer.addItem(ViewerType.CHIMERA.name());
1249 structViewer.addActionListener(new ActionListener()
1252 public void actionPerformed(ActionEvent e)
1254 structureViewer_actionPerformed(
1255 (String) structViewer.getSelectedItem());
1258 structureTab.add(structViewer);
1260 ypos += lineSpacing;
1261 JLabel pathLabel = new JLabel();
1262 pathLabel.setFont(new java.awt.Font("SansSerif", 0, 11));
1263 pathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1264 pathLabel.setText(MessageManager.getString("label.chimera_path"));
1265 pathLabel.setBounds(new Rectangle(10, ypos, 140, height));
1266 structureTab.add(pathLabel);
1268 chimeraPath.setFont(LABEL_FONT);
1269 chimeraPath.setText("");
1270 final String tooltip = JvSwingUtils.wrapTooltip(true,
1271 MessageManager.getString("label.chimera_path_tip"));
1272 chimeraPath.setToolTipText(tooltip);
1273 chimeraPath.setBounds(new Rectangle(160, ypos, 300, height));
1274 chimeraPath.addMouseListener(new MouseAdapter()
1277 public void mouseClicked(MouseEvent e)
1279 if (e.getClickCount() == 2)
1281 String chosen = openFileChooser();
1284 chimeraPath.setText(chosen);
1289 structureTab.add(chimeraPath);
1291 ypos += lineSpacing;
1292 nwMapping.setFont(LABEL_FONT);
1293 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1294 siftsMapping.setFont(LABEL_FONT);
1295 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1296 mappingMethod.add(nwMapping);
1297 mappingMethod.add(siftsMapping);
1298 JPanel mappingPanel = new JPanel();
1299 mappingPanel.setFont(LABEL_FONT);
1300 TitledBorder mmTitledBorder = new TitledBorder(
1301 MessageManager.getString("label.mapping_method"));
1302 mmTitledBorder.setTitleFont(LABEL_FONT);
1303 mappingPanel.setBorder(mmTitledBorder);
1304 mappingPanel.setBounds(new Rectangle(10, ypos, 452, 45));
1305 // GridLayout mappingLayout = new GridLayout();
1306 mappingPanel.setLayout(new GridLayout());
1307 mappingPanel.add(nwMapping);
1308 mappingPanel.add(siftsMapping);
1309 structureTab.add(mappingPanel);
1311 ypos += lineSpacing;
1312 ypos += lineSpacing;
1313 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1314 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1315 docFieldPref.setBounds(new Rectangle(10, ypos, 450, 120));
1316 structureTab.add(docFieldPref);
1318 return structureTab;
1322 * Action on choosing a structure viewer from combobox options.
1324 * @param selectedItem
1326 protected void structureViewer_actionPerformed(String selectedItem)
1331 * Show a dialog for the user to choose a file. Returns the chosen path, or
1336 protected String openFileChooser()
1338 String choice = null;
1339 JFileChooser chooser = new JFileChooser();
1341 // chooser.setFileView(new JalviewFileView());
1342 chooser.setDialogTitle(
1343 MessageManager.getString("label.open_local_file"));
1344 chooser.setToolTipText(MessageManager.getString("action.open"));
1346 int value = chooser.showOpenDialog(this);
1348 if (value == JFileChooser.APPROVE_OPTION)
1350 choice = chooser.getSelectedFile().getPath();
1356 * Validate the structure tab preferences; if invalid, set focus on this tab.
1360 protected boolean validateStructure(FocusEvent e)
1362 if (!validateStructure())
1364 e.getComponent().requestFocusInWindow();
1370 protected boolean validateStructure()
1376 * Initialises the Visual tabbed panel.
1380 private JPanel initVisualTab()
1382 JPanel visualTab = new JPanel();
1383 visualTab.setBorder(new TitledBorder(
1384 MessageManager.getString("action.open_new_alignment")));
1385 visualTab.setLayout(null);
1386 fullScreen.setFont(LABEL_FONT);
1387 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1388 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1389 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1390 quality.setEnabled(false);
1391 quality.setFont(LABEL_FONT);
1392 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1393 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1394 quality.setSelected(true);
1395 quality.setText(MessageManager.getString("label.quality"));
1396 conservation.setEnabled(false);
1397 conservation.setFont(LABEL_FONT);
1398 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1399 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1400 conservation.setSelected(true);
1401 conservation.setText(MessageManager.getString("label.conservation"));
1402 identity.setEnabled(false);
1403 identity.setFont(LABEL_FONT);
1404 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1405 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1406 identity.setSelected(true);
1407 identity.setText(MessageManager.getString("label.consensus"));
1408 showOccupancy.setFont(LABEL_FONT);
1409 showOccupancy.setEnabled(false);
1410 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1411 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1412 showOccupancy.setSelected(true);
1413 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1415 JLabel showGroupbits = new JLabel();
1416 showGroupbits.setFont(LABEL_FONT);
1417 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1418 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1420 .setText(MessageManager.getString("action.show_group") + ":");
1421 JLabel showConsensbits = new JLabel();
1422 showConsensbits.setFont(LABEL_FONT);
1423 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1424 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1426 .setText(MessageManager.getString("label.consensus") + ":");
1427 showConsensHistogram.setEnabled(false);
1428 showConsensHistogram.setFont(LABEL_FONT);
1429 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1430 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1431 showConsensHistogram.setSelected(true);
1432 showConsensHistogram
1433 .setText(MessageManager.getString("label.histogram"));
1434 showConsensLogo.setEnabled(false);
1435 showConsensLogo.setFont(LABEL_FONT);
1436 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1437 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1438 showConsensLogo.setSelected(true);
1439 showConsensLogo.setText(MessageManager.getString("label.logo"));
1440 showGroupConsensus.setEnabled(false);
1441 showGroupConsensus.setFont(LABEL_FONT);
1442 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1443 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1444 showGroupConsensus.setSelected(true);
1445 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1446 showGroupConservation.setEnabled(false);
1447 showGroupConservation.setFont(LABEL_FONT);
1448 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1449 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1450 showGroupConservation.setSelected(true);
1451 showGroupConservation
1452 .setText(MessageManager.getString("label.conservation"));
1453 showNpTooltip.setEnabled(true);
1454 showNpTooltip.setFont(LABEL_FONT);
1455 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1456 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1457 showNpTooltip.setSelected(true);
1458 showNpTooltip.setText(
1459 MessageManager.getString("label.non_positional_features"));
1460 showDbRefTooltip.setEnabled(true);
1461 showDbRefTooltip.setFont(LABEL_FONT);
1462 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1463 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1464 showDbRefTooltip.setSelected(true);
1466 .setText(MessageManager.getString("label.database_references"));
1467 annotations.setFont(LABEL_FONT);
1468 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1469 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1470 annotations.setSelected(true);
1471 annotations.setText(MessageManager.getString("label.show_annotations"));
1472 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1473 annotations.addActionListener(new ActionListener()
1476 public void actionPerformed(ActionEvent e)
1478 annotations_actionPerformed(e);
1481 identity.addActionListener(new ActionListener()
1484 public void actionPerformed(ActionEvent e)
1486 annotations_actionPerformed(e);
1489 showGroupConsensus.addActionListener(new ActionListener()
1492 public void actionPerformed(ActionEvent e)
1494 annotations_actionPerformed(e);
1497 showUnconserved.setFont(LABEL_FONT);
1498 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1499 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1500 showUnconserved.setSelected(true);
1502 .setText(MessageManager.getString("action.show_unconserved"));
1503 showUnconserved.addActionListener(new ActionListener()
1506 public void actionPerformed(ActionEvent e)
1508 showunconserved_actionPerformed(e);
1512 // TODO these are not yet added to / action from Preferences
1513 // JCheckBox shareSelections = new JCheckBox();
1514 // shareSelections.setFont(verdana11);
1515 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1516 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1517 // shareSelections.setSelected(true);
1518 // shareSelections.setText(MessageManager
1519 // .getString("label.share_selection_across_views"));
1520 // JCheckBox followHighlight = new JCheckBox();
1521 // followHighlight.setFont(verdana11);
1522 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1523 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1524 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1525 // followHighlight.setSelected(true);
1526 // followHighlight.setText(MessageManager
1527 // .getString("label.scroll_highlighted_regions"));
1529 seqLimit.setFont(LABEL_FONT);
1530 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1531 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1532 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1533 smoothFont.setFont(LABEL_FONT);
1534 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1535 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1536 smoothFont.setText(MessageManager.getString("label.smooth_font"));
1537 scaleProteinToCdna.setFont(LABEL_FONT);
1538 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1539 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1540 scaleProteinToCdna.setText(
1541 MessageManager.getString("label.scale_protein_to_cdna"));
1542 scaleProteinToCdna.setToolTipText(
1543 MessageManager.getString("label.scale_protein_to_cdna_tip"));
1544 JLabel gapLabel = new JLabel();
1545 gapLabel.setFont(LABEL_FONT);
1546 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1547 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1548 JLabel fontLabel = new JLabel();
1549 fontLabel.setFont(LABEL_FONT);
1550 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1551 fontLabel.setText(MessageManager.getString("label.font"));
1552 fontSizeCB.setFont(LABEL_FONT);
1553 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
1554 fontStyleCB.setFont(LABEL_FONT);
1555 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
1556 fontNameCB.setFont(LABEL_FONT);
1557 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
1558 gapSymbolCB.setFont(LABEL_FONT);
1559 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
1560 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1561 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1562 gapSymbolCB.setRenderer(dlcr);
1564 startupCheckbox.setText(MessageManager.getString("action.open_file"));
1565 startupCheckbox.setFont(LABEL_FONT);
1566 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1567 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1568 startupCheckbox.setSelected(true);
1569 startupFileTextfield.setFont(LABEL_FONT);
1570 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
1571 final String tooltip = JvSwingUtils.wrapTooltip(true,
1572 MessageManager.getString("label.double_click_to_browse"));
1573 startupFileTextfield.setToolTipText(tooltip);
1574 startupFileTextfield.addMouseListener(new MouseAdapter()
1577 public void mouseClicked(MouseEvent e)
1579 if (e.getClickCount() > 1)
1581 startupFileTextfield_mouseClicked();
1586 sortby.setFont(LABEL_FONT);
1587 sortby.setBounds(new Rectangle(172, 260, 155, 21));
1588 JLabel sortLabel = new JLabel();
1589 sortLabel.setFont(LABEL_FONT);
1590 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1591 sortLabel.setText(MessageManager.getString("label.sort_by"));
1592 sortAnnBy.setFont(LABEL_FONT);
1593 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
1594 JLabel sortAnnLabel = new JLabel();
1595 sortAnnLabel.setFont(LABEL_FONT);
1596 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1597 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
1598 sortAutocalc.setFont(LABEL_FONT);
1599 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
1601 JPanel annsettingsPanel = new JPanel();
1602 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
1603 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1604 annsettingsPanel.setBorder(new EtchedBorder());
1605 visualTab.add(annsettingsPanel);
1606 Border jb = new EmptyBorder(1, 1, 4, 5);
1607 annotations.setBorder(jb);
1608 showOccupancy.setBorder(jb);
1609 quality.setBorder(jb);
1610 conservation.setBorder(jb);
1611 identity.setBorder(jb);
1612 showConsensbits.setBorder(jb);
1613 showGroupbits.setBorder(jb);
1614 showGroupConsensus.setBorder(jb);
1615 showGroupConservation.setBorder(jb);
1616 showConsensHistogram.setBorder(jb);
1617 showConsensLogo.setBorder(jb);
1619 JPanel autoAnnotSettings = new JPanel();
1620 annsettingsPanel.add(autoAnnotSettings);
1621 autoAnnotSettings.setLayout(new GridLayout(0, 2));
1622 autoAnnotSettings.add(annotations);
1623 autoAnnotSettings.add(quality);
1624 // second row of autoannotation box
1625 autoAnnotSettings = new JPanel();
1626 annsettingsPanel.add(autoAnnotSettings);
1628 autoAnnotSettings.setLayout(new GridLayout(0, 3));
1629 autoAnnotSettings.add(conservation);
1630 autoAnnotSettings.add(identity);
1631 autoAnnotSettings.add(showOccupancy);
1632 autoAnnotSettings.add(showGroupbits);
1633 autoAnnotSettings.add(showGroupConservation);
1634 autoAnnotSettings.add(showGroupConsensus);
1635 autoAnnotSettings.add(showConsensbits);
1636 autoAnnotSettings.add(showConsensHistogram);
1637 autoAnnotSettings.add(showConsensLogo);
1639 JPanel tooltipSettings = new JPanel();
1640 tooltipSettings.setBorder(new TitledBorder(
1641 MessageManager.getString("label.sequence_id_tooltip")));
1642 tooltipSettings.setBounds(173, 140, 220, 62);
1643 tooltipSettings.setLayout(new GridLayout(2, 1));
1644 tooltipSettings.add(showDbRefTooltip);
1645 tooltipSettings.add(showNpTooltip);
1646 visualTab.add(tooltipSettings);
1648 wrap.setFont(LABEL_FONT);
1649 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
1650 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
1651 wrap.setText(MessageManager.getString("label.wrap_alignment"));
1652 rightAlign.setFont(LABEL_FONT);
1653 rightAlign.setForeground(Color.black);
1654 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
1655 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
1656 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
1657 idItalics.setFont(LABEL_FONT_ITALIC);
1658 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
1659 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
1661 MessageManager.getString("label.sequence_name_italics"));
1662 openoverv.setFont(LABEL_FONT);
1663 openoverv.setActionCommand(
1664 MessageManager.getString("label.open_overview"));
1665 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
1666 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
1667 openoverv.setText(MessageManager.getString("label.open_overview"));
1668 JPanel jPanel2 = new JPanel();
1669 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
1670 jPanel2.setLayout(new GridLayout(14, 1));
1671 jPanel2.add(fullScreen);
1672 jPanel2.add(openoverv);
1673 jPanel2.add(seqLimit);
1674 jPanel2.add(rightAlign);
1675 jPanel2.add(fontLabel);
1676 jPanel2.add(showUnconserved);
1677 jPanel2.add(idItalics);
1678 jPanel2.add(smoothFont);
1679 jPanel2.add(scaleProteinToCdna);
1680 jPanel2.add(gapLabel);
1682 jPanel2.add(sortLabel);
1683 jPanel2.add(sortAnnLabel);
1684 jPanel2.add(startupCheckbox);
1685 visualTab.add(jPanel2);
1686 visualTab.add(startupFileTextfield);
1687 visualTab.add(sortby);
1688 visualTab.add(sortAnnBy);
1689 visualTab.add(sortAutocalc);
1690 visualTab.add(gapSymbolCB);
1691 visualTab.add(fontNameCB);
1692 visualTab.add(fontSizeCB);
1693 visualTab.add(fontStyleCB);
1698 * Load the saved Backups options EXCEPT "Enabled" and "Scheme"
1701 protected void loadLastSavedBackupsOptions()
1703 BackupFilesPresetEntry savedPreset = BackupFilesPresetEntry
1704 .getSavedBackupEntry();
1706 .setSelected(Cache.getDefault(BackupFiles.ENABLED, true));
1708 BackupFilesPresetEntry backupfilesCustomEntry = BackupFilesPresetEntry
1709 .createBackupFilesPresetEntry(Cache
1710 .getDefault(BackupFilesPresetEntry.CUSTOMCONFIG, null));
1711 if (backupfilesCustomEntry == null)
1713 backupfilesCustomEntry = BackupFilesPresetEntry.backupfilesPresetEntriesValues
1714 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT);
1716 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
1717 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM,
1718 backupfilesCustomEntry);
1720 setComboIntStringKey(backupfilesPresetsCombo,
1721 Cache.getDefault(BackupFiles.NS + "_PRESET",
1722 BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT));
1723 // backupsTabUpdatePresets();
1726 .println("LOADLASTSAVEDBACKUPSOPTIONS SETTING BACKUPS OPTIONS");
1727 backupsSetOptions(savedPreset);
1729 backupsOptionsSetEnabled();
1730 updateBackupFilesExampleLabel();
1733 private void setBackupfilesCustomPreset()
1735 if (customiseCheckbox.isSelected() && getComboIntStringKey(
1736 backupfilesPresetsCombo) == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
1738 BackupFilesPresetEntry.backupfilesPresetEntriesValues
1739 .put(BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM,
1740 getBackupfilesCurrentEntry());
1744 private boolean warnAboutSuffixReverseChange()
1746 BackupFilesPresetEntry bfpe = BackupFilesPresetEntry
1747 .getSavedBackupEntry();
1748 boolean savedSuffixReverse = bfpe.reverse;
1749 int savedSuffixDigits = bfpe.digits;
1750 String savedSuffixTemplate = bfpe.suffix;
1752 boolean nowSuffixReverse = suffixReverse.isSelected();
1753 int nowSuffixDigits = getSpinnerInt(suffixDigitsSpinner, 3);
1754 String nowSuffixTemplate = suffixTemplate.getText();
1755 return nowSuffixReverse != savedSuffixReverse
1756 && nowSuffixDigits == savedSuffixDigits
1757 && nowSuffixTemplate != null
1758 && nowSuffixTemplate.equals(savedSuffixTemplate);
1762 * Initialises the Backups tabbed panel.
1766 private JPanel initBackupsTab()
1768 JPanel backupsTab = new JPanel();
1769 backupsTab.setBorder(new TitledBorder(
1770 MessageManager.getString("label.backup_files")));
1771 backupsTab.setLayout(new GridBagLayout());
1773 GridBagConstraints gbc = new GridBagConstraints();
1776 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1777 gbc.fill = GridBagConstraints.NONE;
1779 initBackupsTabPresetsPanel();
1780 initBackupsTabSuffixPanel();
1781 initBackupsTabKeepFilesPanel();
1782 initBackupsTabFilenameExamplesPanel();
1784 enableBackupFiles.setFont(LABEL_FONT_BOLD);
1786 .setText(MessageManager.getString("label.enable_backupfiles"));
1787 enableBackupFiles.addActionListener(new ActionListener()
1790 public void actionPerformed(ActionEvent e)
1792 // enable other options only when the first is checked
1793 backupsOptionsSetEnabled();
1798 // enable checkbox 1 col
1802 gbc.gridy = 0; // row 0
1803 backupsTab.add(enableBackupFiles, gbc);
1805 // summary of scheme box (over two rows)
1809 gbc.anchor = GridBagConstraints.FIRST_LINE_END;
1810 gbc.fill = GridBagConstraints.BOTH;
1811 backupsTab.add(exampleFilesPanel, gbc);
1813 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1814 gbc.fill = GridBagConstraints.NONE;
1816 // fill empty space on right
1819 backupsTab.add(new JPanel(), gbc);
1824 gbc.gridy++; // row 1
1825 backupsTab.add(presetsPanel, gbc);
1827 // gbc.anchor = GridBagConstraints.NORTHWEST;
1828 // now using whole row
1833 gbc.gridy++; // row 2
1834 backupsTab.add(keepfilesPanel, gbc);
1836 // filename strategy box
1837 gbc.gridy++; // row 3
1838 backupsTab.add(suffixPanel, gbc);
1841 gbc.gridy++; // row 4
1843 backupsTab.add(new JPanel(), gbc);
1845 backupsOptionsSetEnabled();
1849 private JPanel initBackupsTabPresetsPanel()
1852 String title = MessageManager.getString("label.schemes");
1853 // TitledBorder tb = new TitledBorder(new EmptyBorder(0, 0, 0, 0), title);
1854 // TitledBorder tb = new TitledBorder(title);
1855 // tb.setTitleFont(LABEL_FONT);
1856 // presetsPanel.setBorder(tb);
1858 presetsPanel.setLayout(new GridBagLayout());
1860 GridBagConstraints gbc = new GridBagConstraints();
1863 gbc.anchor = GridBagConstraints.BASELINE_LEADING;
1864 gbc.fill = GridBagConstraints.NONE;
1872 presetsComboLabel = new JLabel(title + ":");
1873 presetsPanel.add(presetsComboLabel, gbc);
1875 for (int i = 0; i < BackupFilesPresetEntry.backupfilesPresetEntries.length; i++)
1877 backupfilesPresetsCombo
1878 .addItem(BackupFilesPresetEntry.backupfilesPresetEntries[i]);
1881 backupfilesPresetsCombo.addActionListener(new ActionListener()
1884 public void actionPerformed(ActionEvent e)
1886 int key = getComboIntStringKey(backupfilesPresetsCombo);
1887 if (!customiseCheckbox.isSelected())
1889 backupfilesPresetsComboLastSelected = key;
1891 if (key == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
1893 if (customiseCheckbox.isSelected())
1895 // got here by clicking on customiseCheckbox so don't change the values
1896 backupfilesCustomOptionsSetEnabled();
1900 backupsTabUpdatePresets();
1901 backupfilesCustomOptionsSetEnabled();
1906 customiseCheckbox.setSelected(false);
1907 backupsTabUpdatePresets();
1908 backupfilesCustomOptionsSetEnabled();
1913 // dropdown list of preset schemes
1915 presetsPanel.add(backupfilesPresetsCombo, gbc);
1917 revertButton.setText(MessageManager.getString("label.cancel_changes"));
1918 revertButton.addActionListener(new ActionListener()
1921 public void actionPerformed(ActionEvent e)
1924 BackupFilesPresetEntry.backupfilesPresetEntriesValues.get(
1925 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM));
1926 backupfilesCustomOptionsSetEnabled();
1930 revertButton.setFont(LABEL_FONT);
1932 customiseCheckbox.setFont(LABEL_FONT);
1933 customiseCheckbox.setText(MessageManager.getString("label.customise"));
1934 customiseCheckbox.addActionListener(new ActionListener()
1937 public void actionPerformed(ActionEvent e)
1939 int currently = getComboIntStringKey(backupfilesPresetsCombo);
1940 if (customiseCheckbox.isSelected())
1942 backupfilesPresetsComboLastSelected = currently;
1943 setComboIntStringKey(backupfilesPresetsCombo,
1944 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
1948 setComboIntStringKey(backupfilesPresetsCombo,
1949 backupfilesPresetsComboLastSelected);
1952 backupfilesCustomOptionsSetEnabled();
1956 // customise checkbox
1959 presetsPanel.add(customiseCheckbox, gbc);
1961 // "Cancel changes" button (aligned with combo box above)
1963 presetsPanel.add(revertButton, gbc);
1965 return presetsPanel;
1968 private JPanel initBackupsTabFilenameExamplesPanel()
1970 String title = MessageManager
1971 .getString("label.summary_of_backups_scheme");
1972 TitledBorder tb = new TitledBorder(title);
1973 exampleFilesPanel.setBorder(tb);
1974 exampleFilesPanel.setLayout(new GridBagLayout());
1977 backupfilesExampleLabel.setEditable(false);
1978 backupfilesExampleLabel
1979 .setBackground(exampleFilesPanel.getBackground());
1981 updateBackupFilesExampleLabel();
1983 GridBagConstraints gbc = new GridBagConstraints();
1986 gbc.fill = GridBagConstraints.NONE;
1987 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
1989 exampleFilesPanel.add(backupfilesExampleLabel, gbc);
1990 return exampleFilesPanel;
1993 private void backupsTabUpdatePresets()
1995 IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
1997 int key = entry.getKey();
1998 String value = entry.getValue();
2000 if (BackupFilesPresetEntry.backupfilesPresetEntriesValues
2004 BackupFilesPresetEntry.backupfilesPresetEntriesValues
2010 "Preset '" + value + "' [key:" + key + "] not implemented");
2013 // Custom options will now be enabled when the customiseCheckbox is checked
2014 // (performed above)
2015 // backupfilesCustomOptionsSetEnabled();
2016 updateBackupFilesExampleLabel();
2019 protected int getComboIntStringKey(JComboBox<IntKeyStringValueEntry> c)
2021 IntKeyStringValueEntry e = (IntKeyStringValueEntry) c.getSelectedItem();
2022 return e != null ? e.getKey() : 0;
2025 protected void setComboIntStringKey(JComboBox<IntKeyStringValueEntry> c,
2028 for (int i = 0; i < c.getItemCount(); i++)
2030 IntKeyStringValueEntry e = c.getItemAt(i);
2031 if (e.getKey() == key)
2033 c.setSelectedIndex(i);
2037 // backupsTabUpdatePresets();
2040 private JPanel initBackupsTabSuffixPanel()
2042 suffixPanel.setBorder(new TitledBorder(
2043 MessageManager.getString("label.backup_filename_strategy")));
2044 suffixPanel.setLayout(new GridBagLayout());
2047 .setText(MessageManager.getString("label.append_to_filename"));
2048 suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
2049 suffixTemplateLabel.setFont(LABEL_FONT);
2051 final String tooltip = JvSwingUtils.wrapTooltip(true,
2052 MessageManager.getString("label.append_to_filename_tooltip"));
2053 suffixTemplate.setToolTipText(tooltip);
2054 suffixTemplate.addActionListener(new ActionListener()
2057 public void actionPerformed(ActionEvent e)
2059 updateBackupFilesExampleLabel();
2060 backupfilesCustomOptionsSetEnabled();
2061 backupfilesRevertButtonSetEnabled(true);
2065 suffixTemplate.addKeyListener(new KeyListener()
2068 public void keyReleased(KeyEvent e)
2070 updateBackupFilesExampleLabel();
2071 backupfilesCustomOptionsSetEnabled();
2072 backupfilesRevertButtonSetEnabled(true);
2076 public void keyPressed(KeyEvent e)
2080 // disable use of ':' or '/' or '\'
2082 public void keyTyped(KeyEvent e)
2085 char c = e.getKeyChar();
2086 if (c == ':' || c == '/' || c == '\\')
2088 // don't process ':' or '/' or '\'
2097 .setText(MessageManager.getString("label.index_digits"));
2098 suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT);
2099 suffixDigitsLabel.setFont(LABEL_FONT);
2100 ChangeListener c = new ChangeListener()
2103 public void stateChanged(ChangeEvent e)
2105 backupfilesRevertButtonSetEnabled(true);
2106 updateBackupFilesExampleLabel();
2110 setIntegerSpinner(suffixDigitsSpinner, BackupFilesPresetEntry.DIGITSMIN,
2111 BackupFilesPresetEntry.DIGITSMAX, 3, c);
2113 suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"),
2114 MessageManager.getString("label.increment_index"));
2115 suffixReverse.addActionListener(new ActionListener()
2118 public void actionPerformed(ActionEvent e)
2120 boolean okay = true;
2121 if (warnAboutSuffixReverseChange())
2124 okay = confirmSuffixReverseChange();
2128 backupfilesRevertButtonSetEnabled(true);
2129 updateBackupFilesExampleLabel();
2133 boolean savedSuffixReverse = BackupFilesPresetEntry
2134 .getSavedBackupEntry().reverse;
2135 suffixReverse.setSelected(savedSuffixReverse);
2140 GridBagConstraints sgbc = new GridBagConstraints();
2142 // first row (template text box)
2143 sgbc.anchor = GridBagConstraints.WEST;
2147 sgbc.gridheight = 1;
2150 sgbc.fill = GridBagConstraints.NONE;
2151 suffixPanel.add(suffixTemplateLabel, sgbc);
2154 sgbc.fill = GridBagConstraints.HORIZONTAL;
2155 suffixPanel.add(suffixTemplate, sgbc);
2157 // second row (number of digits spinner)
2161 sgbc.fill = GridBagConstraints.NONE;
2162 suffixPanel.add(suffixDigitsLabel, sgbc);
2165 sgbc.fill = GridBagConstraints.HORIZONTAL;
2166 suffixPanel.add(suffixDigitsSpinner, sgbc);
2168 // third row (forward order radio selection)
2171 sgbc.gridwidth = GridBagConstraints.REMAINDER;
2172 sgbc.fill = GridBagConstraints.HORIZONTAL;
2173 suffixPanel.add(suffixReverse.getFalseButton(), sgbc);
2175 // fourth row (reverse order radio selection)
2177 suffixPanel.add(suffixReverse.getTrueButton(), sgbc);
2181 private boolean confirmSuffixReverseChange()
2183 boolean ret = false;
2184 String warningMessage = MessageManager
2185 .getString("label.warning_confirm_change_reverse");
2186 int confirm = JvOptionPane.showConfirmDialog(Desktop.desktop,
2188 MessageManager.getString("label.change_increment_decrement"),
2189 JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE);
2191 ret = (confirm == JvOptionPane.YES_OPTION);
2195 private JPanel initBackupsTabKeepFilesPanel()
2197 keepfilesPanel.setBorder(
2198 new TitledBorder(MessageManager.getString("label.keep_files")));
2199 keepfilesPanel.setLayout(new GridBagLayout());
2201 backupfilesKeepAll.setLabels(
2202 MessageManager.getString("label.keep_all_backup_files"),
2203 MessageManager.getString(
2204 "label.keep_only_this_number_of_backup_files"));
2205 backupfilesKeepAll.addTrueActionListener(new ActionListener()
2208 public void actionPerformed(ActionEvent e)
2210 backupfilesRevertButtonSetEnabled(true);
2211 updateBackupFilesExampleLabel();
2214 backupfilesKeepAll.addActionListener(new ActionListener()
2217 public void actionPerformed(ActionEvent e)
2219 backupfilesRevertButtonSetEnabled(true);
2220 keepRollMaxOptionsEnabled();
2221 updateBackupFilesExampleLabel();
2225 ChangeListener c = new ChangeListener()
2228 public void stateChanged(ChangeEvent e)
2230 backupfilesRevertButtonSetEnabled(true);
2231 updateBackupFilesExampleLabel();
2235 setIntegerSpinner(backupfilesRollMaxSpinner,
2236 BackupFilesPresetEntry.ROLLMAXMIN,
2237 BackupFilesPresetEntry.ROLLMAXMAX, 4, true, c);
2239 backupfilesConfirmDelete.setLabels(
2240 MessageManager.getString("label.always_ask"),
2241 MessageManager.getString("label.auto_delete"));
2242 backupfilesConfirmDelete.addActionListener(new ActionListener()
2245 public void actionPerformed(ActionEvent e)
2247 backupfilesRevertButtonSetEnabled(true);
2250 // update the enabled section
2251 keepRollMaxOptionsEnabled();
2253 GridBagConstraints kgbc = new GridBagConstraints();
2255 // first row (template text box)
2256 kgbc.anchor = GridBagConstraints.WEST;
2259 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2260 kgbc.gridheight = 1;
2263 kgbc.fill = GridBagConstraints.HORIZONTAL;
2264 keepfilesPanel.add(backupfilesKeepAll.getTrueButton(), kgbc);
2270 kgbc.gridwidth = GridBagConstraints.RELATIVE;
2271 keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
2274 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2275 keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
2277 // third row (indented)
2279 kgbc.insets = new Insets(0, 20, 0, 0);
2282 kgbc.gridwidth = GridBagConstraints.REMAINDER;
2283 kgbc.fill = GridBagConstraints.HORIZONTAL;
2286 keepfilesPanel.add(backupfilesConfirmDelete.getTrueButton(), kgbc);
2288 // fourth row (indented)
2290 keepfilesPanel.add(backupfilesConfirmDelete.getFalseButton(), kgbc);
2293 JPanel jp = new JPanel();
2294 jp.setLayout(new FlowLayout());
2296 .setText(MessageManager
2297 .getString("label.autodelete_old_backup_files"));
2298 oldBackupFilesLabel.setFont(LABEL_FONT);
2299 oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
2300 jp.add(oldBackupFilesLabel);
2301 jp.add(backupfilesConfirmDelete.getTrueButton());
2302 jp.add(backupfilesConfirmDelete.getFalseButton());
2303 keepfilesPanel.add(jp, kgbc);
2305 return keepfilesPanel;
2308 protected void updateBackupFilesExampleLabel()
2310 int exampleindex = 12;
2311 String base = MessageManager.getString("label.filename") + ".fa";
2312 if (base == null || base.length() == 0)
2314 base = "file_name.fa";
2317 boolean reverse = suffixReverse.isSelected();
2318 boolean keepAll = backupfilesKeepAll.isSelected();
2320 String suffix = suffixTemplate.getText();
2323 backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
2324 if (suffix == null || suffix.length() == 0)
2326 backupfilesExampleLabel
2327 .setText(MessageManager.getString("label.no_backup_files"));
2328 backupfilesExampleLabel.setFont(LABEL_FONT_BOLD);
2332 rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 4);
2333 rollMax = rollMax < 1 ? 1 : rollMax;
2335 if (suffix.indexOf(BackupFiles.NUM_PLACEHOLDER) == -1)
2340 digits = getSpinnerInt(suffixDigitsSpinner, 3);
2341 digits = digits < 1 ? 1 : digits;
2343 int lowersurround = 2;
2344 int uppersurround = 0;
2345 StringBuilder exampleSB = new StringBuilder();
2346 boolean firstLine = true;
2351 int max = keepAll ? exampleindex : rollMax;
2352 for (int index = min; index <= max; index++)
2354 if (index == min + lowersurround && index < max - uppersurround - 1)
2356 exampleSB.append("\n...");
2358 else if (index > min + lowersurround && index < max - uppersurround)
2370 exampleSB.append("\n");
2372 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2373 base, suffix, digits));
2376 // no extra text needed
2378 else if (index == min)
2380 String newest = MessageManager.getString("label.braced_newest");
2381 if (newest != null && newest.length() > 0)
2383 exampleSB.append(" " + newest);
2386 else if (index == max)
2388 String oldest = MessageManager.getString("label.braced_oldest");
2389 if (oldest != null && oldest.length() > 0)
2391 exampleSB.append(" " + oldest);
2400 int min = (keepAll || exampleindex - rollMax < 0) ? 1
2401 : exampleindex - rollMax + 1;
2402 int max = exampleindex;
2404 for (int index = min; index <= max; index++)
2407 if (index == min + lowersurround && index < max - uppersurround - 1)
2409 exampleSB.append("\n...");
2411 else if (index > min + lowersurround && index < max - uppersurround)
2423 exampleSB.append("\n");
2425 exampleSB.append(BackupFilenameParts.getBackupFilename(index,
2426 base, suffix, digits));
2429 // no extra text needed
2431 else if (index == min)
2433 String oldest = MessageManager.getString("label.braced_oldest");
2434 if (oldest != null && oldest.length() > 0)
2436 exampleSB.append(" " + oldest);
2439 else if (index == max)
2441 String newest = MessageManager.getString("label.braced_newest");
2442 if (newest != null && newest.length() > 0)
2444 exampleSB.append(" " + newest);
2452 backupfilesExampleLabel.setText(exampleSB.toString());
2455 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2456 boolean useExistingVal, ChangeListener c)
2463 i = Integer.parseInt((String) s.getValue());
2464 } catch (Exception e)
2467 "Exception casting the initial value of s.getValue()");
2471 setIntegerSpinner(s, min, max, i, c);
2474 protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
2477 // integer spinner for number of digits
2482 SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
2485 s.addChangeListener(c);
2489 protected static int getSpinnerInt(JSpinner s, int def)
2495 i = (Integer) s.getValue();
2496 } catch (Exception e)
2498 System.out.println("Failed casting (Integer) JSpinner s.getValue()");
2503 private void keepRollMaxOptionsEnabled()
2505 boolean enabled = backupfilesKeepAll.isEnabled()
2506 && !backupfilesKeepAll.isSelected();
2507 oldBackupFilesLabel.setEnabled(enabled);
2508 backupfilesRollMaxSpinner.setEnabled(enabled);
2509 backupfilesConfirmDelete.setEnabled(enabled);
2512 private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
2514 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2515 && customiseCheckbox.isSelected()
2516 && suffixTemplate.getText()
2517 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2518 keepfilesPanel.setEnabled(enabled);
2519 backupfilesKeepAll.setEnabled(enabled);
2520 oldBackupFilesLabel.setEnabled(enabled);
2521 keepRollMaxOptionsEnabled();
2524 private void backupfilesSuffixTemplateDigitsSetEnabled()
2526 boolean enabled = suffixTemplate.isEnabled() && suffixTemplate.getText()
2527 .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
2528 suffixDigitsLabel.setEnabled(enabled);
2529 suffixDigitsSpinner.setEnabled(enabled);
2530 suffixReverse.setEnabled(enabled);
2533 private void backupfilesSuffixTemplateSetEnabled(boolean tryEnabled)
2535 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2536 && customiseCheckbox.isSelected();
2537 suffixPanel.setEnabled(enabled);
2538 suffixTemplateLabel.setEnabled(enabled);
2539 suffixTemplate.setEnabled(enabled);
2540 backupfilesSuffixTemplateDigitsSetEnabled();
2543 private void backupfilesRevertButtonSetEnabled(boolean tryEnabled)
2545 boolean enabled = tryEnabled && enableBackupFiles.isSelected()
2546 && customiseCheckbox.isSelected() && backupfilesCustomChanged();
2547 revertButton.setEnabled(enabled);
2550 private boolean backupfilesCustomChanged()
2552 BackupFilesPresetEntry custom = BackupFilesPresetEntry.backupfilesPresetEntriesValues
2553 .get(BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM);
2554 BackupFilesPresetEntry current = getBackupfilesCurrentEntry();
2555 return !custom.equals(current);
2558 protected BackupFilesPresetEntry getBackupfilesCurrentEntry()
2560 String suffix = suffixTemplate.getText();
2561 int digits = getSpinnerInt(suffixDigitsSpinner, 3);
2562 boolean reverse = suffixReverse.isSelected();
2563 boolean keepAll = backupfilesKeepAll.isSelected();
2564 int rollMax = getSpinnerInt(backupfilesRollMaxSpinner, 3);
2565 boolean confirmDelete = backupfilesConfirmDelete.isSelected();
2567 BackupFilesPresetEntry bfpe = new BackupFilesPresetEntry(suffix, digits,
2568 reverse, keepAll, rollMax, confirmDelete);
2573 protected void backupfilesCustomOptionsSetEnabled()
2575 // int scheme = getComboIntStringKey(backupfilesPresetsCombo);
2576 // boolean enabled = scheme == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM &&
2577 // enableBackupFiles.isSelected();
2578 boolean enabled = customiseCheckbox.isSelected();
2579 //boolean enabled = customiseCheckbox.isSelected() && enableBackupFiles.isSelected();
2581 backupfilesRevertButtonSetEnabled(enabled);
2582 backupfilesSuffixTemplateSetEnabled(enabled);
2583 backupfilesKeepAllSetEnabled(enabled);
2586 private void backupfilesSummarySetEnabled()
2588 boolean enabled = enableBackupFiles.isSelected();
2589 backupfilesExampleLabel.setEnabled(enabled);
2590 exampleFilesPanel.setEnabled(enabled);
2593 private void backupfilesPresetsSetEnabled()
2595 boolean enabled = enableBackupFiles.isSelected();
2596 presetsPanel.setEnabled(enabled);
2597 presetsComboLabel.setEnabled(enabled);
2598 backupfilesPresetsCombo.setEnabled(enabled);
2599 customiseCheckbox.setEnabled(enabled);
2600 revertButton.setEnabled(enabled);
2603 protected void backupsOptionsSetEnabled()
2605 backupfilesPresetsSetEnabled();
2606 backupfilesSummarySetEnabled();
2607 backupfilesCustomOptionsSetEnabled();
2610 protected void backupsSetOptions(String suffix, int digits,
2611 boolean reverse, boolean keepAll, int rollMax,
2612 boolean confirmDelete)
2614 suffixTemplate.setText(suffix);
2615 suffixDigitsSpinner.setValue(digits);
2616 suffixReverse.setSelected(reverse);
2617 backupfilesKeepAll.setSelected(keepAll);
2618 backupfilesRollMaxSpinner.setValue(rollMax);
2619 backupfilesConfirmDelete.setSelected(confirmDelete);
2622 protected void backupsSetOptions(BackupFilesPresetEntry p)
2624 backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax,
2628 protected void autoIdWidth_actionPerformed()
2630 // TODO Auto-generated method stub
2634 protected void userIdWidth_actionPerformed()
2636 // TODO Auto-generated method stub
2640 protected void maxColour_actionPerformed(JPanel panel)
2644 protected void minColour_actionPerformed(JPanel panel)
2648 protected void gapColour_actionPerformed(JPanel panel)
2652 protected void hiddenColour_actionPerformed(JPanel panel)
2656 protected void showunconserved_actionPerformed(ActionEvent e)
2658 // TODO Auto-generated method stub
2662 protected void useLegacyGaps_actionPerformed(ActionEvent e)
2666 protected void resetOvDefaults_actionPerformed(ActionEvent e)
2676 public void ok_actionPerformed(ActionEvent e)
2686 public void cancel_actionPerformed(ActionEvent e)
2696 public void annotations_actionPerformed(ActionEvent e)
2703 public void startupFileTextfield_mouseClicked()
2707 public void newLink_actionPerformed(ActionEvent e)
2712 public void editLink_actionPerformed(ActionEvent e)
2717 public void deleteLink_actionPerformed(ActionEvent e)
2722 public void defaultBrowser_mouseClicked(MouseEvent e)
2727 public void linkURLList_keyTyped(KeyEvent e)
2732 public void useProxy_actionPerformed()
2734 boolean enabled = useProxy.isSelected();
2735 portLabel.setEnabled(enabled);
2736 serverLabel.setEnabled(enabled);
2737 proxyServerTB.setEnabled(enabled);
2738 proxyPortTB.setEnabled(enabled);
2742 * Customer renderer for JTable: supports column of radio buttons
2744 public class RadioButtonRenderer extends JRadioButton
2745 implements TableCellRenderer
2747 public RadioButtonRenderer()
2749 setHorizontalAlignment(CENTER);
2750 setToolTipText(MessageManager.getString("label.urltooltip"));
2754 public Component getTableCellRendererComponent(JTable table,
2755 Object value, boolean isSelected, boolean hasFocus, int row,
2758 setSelected((boolean) value);
2760 // set colours to match rest of table
2763 setBackground(table.getSelectionBackground());
2764 setForeground(table.getSelectionForeground());
2768 setBackground(table.getBackground());
2769 setForeground(table.getForeground());
2776 * Customer cell editor for JTable: supports column of radio buttons in
2777 * conjunction with renderer
2779 public class RadioButtonEditor extends AbstractCellEditor
2780 implements TableCellEditor
2782 private JRadioButton button = new JRadioButton();
2784 public RadioButtonEditor()
2786 button.setHorizontalAlignment(SwingConstants.CENTER);
2787 this.button.addActionListener(new ActionListener()
2790 public void actionPerformed(ActionEvent e)
2792 fireEditingStopped();
2798 public Component getTableCellEditorComponent(JTable table, Object value,
2799 boolean isSelected, int row, int column)
2801 button.setSelected((boolean) value);
2806 public Object getCellEditorValue()
2808 return button.isSelected();