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.
23 import java.awt.BorderLayout;
24 import java.awt.Color;
25 import java.awt.Component;
26 import java.awt.Dimension;
28 import java.awt.event.ActionEvent;
29 import java.awt.event.ActionListener;
30 import java.awt.event.FocusAdapter;
31 import java.awt.event.FocusEvent;
32 import java.awt.event.MouseEvent;
34 import java.util.ArrayList;
35 import java.util.List;
36 import java.util.concurrent.CompletableFuture;
38 import javax.help.HelpSetException;
39 import javax.swing.JComboBox;
40 import javax.swing.JFileChooser;
41 import javax.swing.JInternalFrame;
42 import javax.swing.JPanel;
43 import javax.swing.JTextField;
44 import javax.swing.ListSelectionModel;
45 import javax.swing.RowFilter;
46 import javax.swing.RowSorter;
47 import javax.swing.SortOrder;
48 import javax.swing.event.DocumentEvent;
49 import javax.swing.event.DocumentListener;
50 import javax.swing.event.ListSelectionEvent;
51 import javax.swing.event.ListSelectionListener;
52 import javax.swing.table.TableCellRenderer;
53 import javax.swing.table.TableColumn;
54 import javax.swing.table.TableModel;
55 import javax.swing.table.TableRowSorter;
57 import jalview.hmmer.HmmerCommand;
58 import jalview.util.FileUtils;
59 import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
60 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
61 import jalview.bin.ApplicationSingletonProvider;
62 import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI;
63 import jalview.bin.Cache;
64 import jalview.bin.Console;
65 import jalview.bin.MemorySetting;
66 import jalview.ext.pymol.PymolManager;
67 import jalview.gui.Help.HelpId;
68 import jalview.gui.StructureViewer.ViewerType;
69 import jalview.io.BackupFiles;
70 import jalview.io.BackupFilesPresetEntry;
71 import jalview.io.FileFormatI;
72 import jalview.io.JalviewFileChooser;
73 import jalview.io.JalviewFileView;
74 import jalview.jbgui.GPreferences;
75 import jalview.jbgui.GSequenceLink;
76 import jalview.schemes.ColourSchemeI;
77 import jalview.schemes.ColourSchemes;
78 import jalview.schemes.ResidueColourScheme;
79 import jalview.urls.UrlLinkTableModel;
80 import jalview.urls.api.UrlProviderFactoryI;
81 import jalview.urls.api.UrlProviderI;
82 import jalview.urls.desktop.DesktopUrlProviderFactory;
83 import jalview.util.MessageManager;
84 import jalview.util.Platform;
85 import jalview.util.UrlConstants;
86 import jalview.ws.sifts.SiftsSettings;
94 public class Preferences extends GPreferences implements ApplicationSingletonI
96 // suggested list delimiter character
97 public static final String COMMA = ",";
99 public static final String HMMSEARCH_SEQCOUNT = "HMMSEARCH_SEQCOUNT";
101 public static final String HMMINFO_GLOBAL_BACKGROUND = "HMMINFO_GLOBAL_BACKGROUND";
103 public static final String HMMALIGN_TRIM_TERMINI = "HMMALIGN_TRIM_TERMINI";
105 public static final String ADD_SS_ANN = "ADD_SS_ANN";
107 public static final String ADD_TEMPFACT_ANN = "ADD_TEMPFACT_ANN";
109 public static final String ALLOW_UNPUBLISHED_PDB_QUERYING = "ALLOW_UNPUBLISHED_PDB_QUERYING";
111 public static final String ANNOTATIONCOLOUR_MAX = "ANNOTATIONCOLOUR_MAX";
113 public static final String ANNOTATIONCOLOUR_MIN = "ANNOTATIONCOLOUR_MIN";
115 public static final String ANTI_ALIAS = "ANTI_ALIAS";
117 public static final String AUTO_CALC_CONSENSUS = "AUTO_CALC_CONSENSUS";
119 public static final String AUTOASSOCIATE_PDBANDSEQS = "AUTOASSOCIATE_PDBANDSEQS";
121 public static final String BLOSUM62_PCA_FOR_NUCLEOTIDE = "BLOSUM62_PCA_FOR_NUCLEOTIDE";
123 public static final String CENTRE_COLUMN_LABELS = "CENTRE_COLUMN_LABELS";
125 public static final String CHIMERA_PATH = "CHIMERA_PATH";
127 public static final String CHIMERAX_PATH = "CHIMERAX_PATH";
129 public static final String DBREFFETCH_USEPICR = "DBREFFETCH_USEPICR";
131 public static final String DEFAULT_COLOUR = "DEFAULT_COLOUR";
133 public static final String DEFAULT_COLOUR_NUC = "DEFAULT_COLOUR_NUC";
134 public static final String DEFAULT_COLOUR_PROT = "DEFAULT_COLOUR_PROT";
136 public static final String ENABLE_SPLIT_FRAME = "ENABLE_SPLIT_FRAME";
138 public static final String FIGURE_AUTOIDWIDTH = "FIGURE_AUTOIDWIDTH";
140 public static final String FIGURE_FIXEDIDWIDTH = "FIGURE_FIXEDIDWIDTH";
142 public static final String FOLLOW_SELECTIONS = "FOLLOW_SELECTIONS";
144 public static final String FONT_NAME = "FONT_NAME";
146 public static final String FONT_SIZE = "FONT_SIZE";
148 public static final String FONT_STYLE = "FONT_STYLE";
150 public static final String HMMER_PATH = "HMMER_PATH";
152 public static final String CYGWIN_PATH = "CYGWIN_PATH";
154 public static final String HMMSEARCH_DBS = "HMMSEARCH_DBS";
156 public static final String GAP_COLOUR = "GAP_COLOUR";
158 public static final String GAP_SYMBOL = "GAP_SYMBOL";
160 public static final String HIDDEN_COLOUR = "HIDDEN_COLOUR";
162 public static final String HIDE_INTRONS = "HIDE_INTRONS";
164 public static final String ID_ITALICS = "ID_ITALICS";
166 public static final String ID_ORG_HOSTURL = "ID_ORG_HOSTURL";
168 public static final String MAP_WITH_SIFTS = "MAP_WITH_SIFTS";
170 public static final String NOQUESTIONNAIRES = "NOQUESTIONNAIRES";
172 public static final String NORMALISE_CONSENSUS_LOGO = "NORMALISE_CONSENSUS_LOGO";
174 public static final String NORMALISE_LOGO = "NORMALISE_LOGO";
176 public static final String PAD_GAPS = "PAD_GAPS";
178 public static final String PDB_DOWNLOAD_FORMAT = "PDB_DOWNLOAD_FORMAT";
179 public static final String PYMOL_PATH = "PYMOL_PATH";
181 public static final String QUESTIONNAIRE = "QUESTIONNAIRE";
183 public static final String RELAXEDSEQIDMATCHING = "RELAXEDSEQIDMATCHING";
185 public static final String RIGHT_ALIGN_IDS = "RIGHT_ALIGN_IDS";
187 public static final String SCALE_PROTEIN_TO_CDNA = "SCALE_PROTEIN_TO_CDNA";
189 public static final String SHOW_ANNOTATIONS = "SHOW_ANNOTATIONS";
191 public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE";
193 public static final String SHOW_CONSENSUS = "SHOW_CONSENSUS";
195 public static final String SHOW_CONSENSUS_HISTOGRAM = "SHOW_CONSENSUS_HISTOGRAM";
197 public static final String SHOW_CONSENSUS_LOGO = "SHOW_CONSENSUS_LOGO";
199 public static final String SHOW_CONSERVATION = "SHOW_CONSERVATION";
201 public static final String SHOW_DBREFS_TOOLTIP = "SHOW_DBREFS_TOOLTIP";
203 public static final String SHOW_GROUP_CONSENSUS = "SHOW_GROUP_CONSENSUS";
205 public static final String SHOW_GROUP_CONSERVATION = "SHOW_GROUP_CONSERVATION";
207 public static final String SHOW_JVSUFFIX = "SHOW_JVSUFFIX";
209 public static final String SHOW_NPFEATS_TOOLTIP = "SHOW_NPFEATS_TOOLTIP";
210 public static final String SHOW_OCCUPANCY = "SHOW_OCCUPANCY";
212 public static final String SHOW_OV_HIDDEN_AT_START = "SHOW_OV_HIDDEN_AT_START";
214 public static final String SHOW_OVERVIEW = "SHOW_OVERVIEW";
216 public static final String SHOW_QUALITY = "SHOW_QUALITY";
218 public static final String SHOW_UNCONSERVED = "SHOW_UNCONSERVED";
220 public static final String SORT_ALIGNMENT = "SORT_ALIGNMENT";
222 public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS";
224 public static final String SORT_BY_TREE = "SORT_BY_TREE";
226 public static final String STRUCT_FROM_PDB = "STRUCT_FROM_PDB";
228 public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY";
230 public static final String STRUCTURE_DIMENSIONS = "STRUCTURE_DIMENSIONS";
232 public static final String UNIPROT_DOMAIN = "UNIPROT_DOMAIN";
234 public static final String USE_FULL_SO = "USE_FULL_SO";
235 public static final String USE_LEGACY_GAP = "USE_LEGACY_GAP";
237 public static final String USE_RNAVIEW = "USE_RNAVIEW";
239 public static final String USER_DEFINED_COLOURS = "USER_DEFINED_COLOURS";
241 public static final String WRAP_ALIGNMENT = "WRAP_ALIGNMENT";
243 private static final int MIN_FONT_SIZE = 1;
245 private static final int MAX_FONT_SIZE = 30;
247 private String previousProxyType;
249 private static Preferences INSTANCE = null; // add "final"
252 * Holds name and link separated with | character. Sequence ID must be
253 * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$
255 public static UrlProviderI sequenceUrlLinks;
257 public static UrlLinkTableModel dataModel;
260 * Holds name and link separated with | character. Sequence IDS and Sequences
261 * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and $SEQUENCES$
262 * or $SEQUENCES=/.possible | chars ./=$ and separation character for first and
263 * second token specified after a pipe character at end |,|. (TODO: proper
264 * escape for using | to separate ids or sequences
267 public static List<String> groupURLLinks;
270 // get links selected to be in the menu (SEQUENCE_LINKS)
271 // and links entered by the user but not selected (STORED_LINKS)
272 String inMenuString = Cache.getDefault("SEQUENCE_LINKS", "");
273 String notInMenuString = Cache.getDefault("STORED_LINKS", "");
274 String defaultUrl = Cache.getDefault("DEFAULT_URL",
275 UrlConstants.DEFAULT_LABEL);
277 // if both links lists are empty, add the DEFAULT_URL link
278 // otherwise we assume the default link is in one of the lists
279 if (inMenuString.isEmpty() && notInMenuString.isEmpty())
281 inMenuString = UrlConstants.DEFAULT_STRING;
283 UrlProviderFactoryI factory = new DesktopUrlProviderFactory(defaultUrl,
284 inMenuString, notInMenuString);
285 sequenceUrlLinks = factory.createUrlProvider();
286 dataModel = new UrlLinkTableModel(sequenceUrlLinks);
289 * TODO: reformulate groupURL encoding so two or more can be stored in the
290 * .properties file as '|' separated strings
293 groupURLLinks = new ArrayList<>();
296 JInternalFrame frame;
298 private WsPreferences wsPrefs;
300 private SlivkaPreferences slivkaPrefs;
301 private OptionsParam promptEachTimeOpt = new OptionsParam(
302 MessageManager.getString("label.prompt_each_time"),
305 private OptionsParam lineArtOpt = new OptionsParam(
306 MessageManager.getString("label.lineart"), "Lineart");
308 private OptionsParam textOpt = new OptionsParam(
309 MessageManager.getString("action.text"), "Text");
311 // get singleton Preferences instance
312 public static Preferences getInstance()
314 if (INSTANCE == null || INSTANCE.frame == null
315 || INSTANCE.frame.isClosed())
317 INSTANCE = new Preferences();
322 * Replace code with the following for Jalvew-JS
323 Preferences INSTANCE = ApplicationSingletonProvider.getInstance(Preferences.class);
324 if (INSTANCE == null || INSTANCE.frame == null
325 || INSTANCE.frame.isClosed())
327 ApplicationSingletonProvider.remove(Preferences.class);
328 INSTANCE = ApplicationSingletonProvider.getInstance(Preferences.class);
334 public static void openPreferences()
336 openPreferences(null, null);
339 public static void openPreferences(TabRef selectTab, String message)
341 Preferences p = getInstance();
342 if (selectTab != null)
343 p.selectTab(selectTab, message);
345 p.frame.moveToFront();
349 public void selectTab(TabRef selectTab, String message)
351 this.selectTab(selectTab);
353 this.setMessage(message);
358 * Creates a new Preferences object.
360 private Preferences()
363 frame = new JInternalFrame();
364 frame.setContentPane(this);
365 if (!Platform.isJS())
372 wsPrefs = new WsPreferences();
373 wsTab.add(wsPrefs, BorderLayout.CENTER);
376 slivkaPrefs = new SlivkaPreferences();
377 slivkaTab.add(slivkaPrefs, BorderLayout.CENTER);
379 int width = 500, height = 450;
380 if (Platform.isAMacAndNotJS())
386 Desktop.addInternalFrame(frame,
387 MessageManager.getString("label.preferences"), width, height);
388 frame.setMinimumSize(new Dimension(width, height));
391 * Set HMMER tab defaults
393 hmmrTrimTermini.setSelected(Cache.getDefault(HMMALIGN_TRIM_TERMINI, false));
394 if (Cache.getDefault(HMMINFO_GLOBAL_BACKGROUND, false))
396 hmmerBackgroundUniprot.setSelected(true);
400 hmmerBackgroundAlignment.setSelected(true);
403 .setText(Cache.getProperty(HMMSEARCH_SEQCOUNT));
404 hmmerPath.setText(Cache.getProperty(HMMER_PATH));
405 hmmerPath.addActionListener(new ActionListener()
408 public void actionPerformed(ActionEvent e)
413 hmmerPath.addFocusListener(new FocusAdapter()
416 public void focusLost(FocusEvent e)
421 if (cygwinPath != null)
423 String path = Cache.getProperty(CYGWIN_PATH);
426 path = FileUtils.getPathTo("bash");
428 cygwinPath.setText(path);
429 cygwinPath.addActionListener(new ActionListener()
432 public void actionPerformed(ActionEvent e)
434 validateCygwinPath();
437 cygwinPath.addFocusListener(new FocusAdapter()
440 public void focusLost(FocusEvent e)
442 validateCygwinPath();
448 * Set Visual tab defaults
450 seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true));
451 rightAlign.setSelected(Cache.getDefault("RIGHT_ALIGN_IDS", false));
452 fullScreen.setSelected(Cache.getDefault("SHOW_FULLSCREEN", false));
453 annotations.setSelected(Cache.getDefault("SHOW_ANNOTATIONS", true));
455 conservation.setSelected(Cache.getDefault("SHOW_CONSERVATION", true));
456 quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));
457 identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
458 openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false));
460 .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
461 showOccupancy.setSelected(Cache.getDefault(SHOW_OCCUPANCY, false));
463 .setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS", false));
464 showGroupConservation.setSelected(
465 Cache.getDefault("SHOW_GROUP_CONSERVATION", false));
466 showConsensHistogram.setSelected(
467 Cache.getDefault("SHOW_CONSENSUS_HISTOGRAM", true));
469 .setSelected(Cache.getDefault("SHOW_CONSENSUS_LOGO", false));
470 showInformationHistogram.setSelected(
471 Cache.getDefault("SHOW_INFORMATION_HISTOGRAM", true));
472 showHMMLogo.setSelected(Cache.getDefault("SHOW_HMM_LOGO", false));
474 .setSelected(Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true));
476 .setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP", true));
478 String[] fonts = java.awt.GraphicsEnvironment
479 .getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
480 for (int i = 0; i < fonts.length; i++)
482 fontNameCB.addItem(fonts[i]);
485 for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++)
487 fontSizeCB.addItem(i + "");
490 fontStyleCB.addItem("plain");
491 fontStyleCB.addItem("bold");
492 fontStyleCB.addItem("italic");
494 fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif"));
495 fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10"));
496 fontStyleCB.setSelectedItem(
497 Cache.getDefault("FONT_STYLE", Font.PLAIN + ""));
499 smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", true));
501 .setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA, false));
503 idItalics.setSelected(Cache.getDefault("ID_ITALICS", true));
505 wrap.setSelected(Cache.getDefault("WRAP_ALIGNMENT", false));
507 gapSymbolCB.addItem("-");
508 gapSymbolCB.addItem(".");
510 gapSymbolCB.setSelectedItem(Cache.getDefault("GAP_SYMBOL", "-"));
512 sortby.addItem("No sort");
513 sortby.addItem("Id");
514 sortby.addItem("Pairwise Identity");
515 sortby.setSelectedItem(Cache.getDefault("SORT_ALIGNMENT", "No sort"));
517 sortAnnBy.addItem(SequenceAnnotationOrder.NONE.toString());
519 .addItem(SequenceAnnotationOrder.SEQUENCE_AND_LABEL.toString());
521 .addItem(SequenceAnnotationOrder.LABEL_AND_SEQUENCE.toString());
522 SequenceAnnotationOrder savedSort = SequenceAnnotationOrder
523 .valueOf(Cache.getDefault(SORT_ANNOTATIONS,
524 SequenceAnnotationOrder.NONE.name()));
525 sortAnnBy.setSelectedItem(savedSort.toString());
527 sortAutocalc.addItem("Autocalculated first");
528 sortAutocalc.addItem("Autocalculated last");
529 final boolean showAbove = Cache.getDefault(SHOW_AUTOCALC_ABOVE, true);
530 sortAutocalc.setSelectedItem(showAbove ? sortAutocalc.getItemAt(0)
531 : sortAutocalc.getItemAt(1));
533 .setSelected(Cache.getDefault("SHOW_STARTUP_FILE", true));
534 startupFileTextfield.setText(Cache.getDefault("STARTUP_FILE",
535 Cache.getDefault("www.jalview.org", "https://www.jalview.org")
536 + "/examples/exampleFile_2_7.jvp"));
539 * Set Colours tab defaults
541 protColour.addItem(ResidueColourScheme.NONE);
542 nucColour.addItem(ResidueColourScheme.NONE);
543 for (ColourSchemeI cs : ColourSchemes.getInstance().getColourSchemes())
545 String name = cs.getSchemeName();
546 protColour.addItem(name);
547 nucColour.addItem(name);
549 String oldProp = Cache.getDefault(DEFAULT_COLOUR,
550 ResidueColourScheme.NONE);
551 String newProp = Cache.getDefault(DEFAULT_COLOUR_PROT, null);
552 protColour.setSelectedItem(newProp != null ? newProp : oldProp);
553 newProp = Cache.getDefault(DEFAULT_COLOUR_NUC, null);
554 nucColour.setSelectedItem(newProp != null ? newProp : oldProp);
555 minColour.setBackground(
556 Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN", Color.orange));
557 maxColour.setBackground(
558 Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX", Color.red));
561 * Set overview panel defaults
563 gapColour.setBackground(Cache.getDefaultColour(GAP_COLOUR,
564 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP));
565 hiddenColour.setBackground(Cache.getDefaultColour(HIDDEN_COLOUR,
566 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_HIDDEN));
567 useLegacyGap.setSelected(Cache.getDefault(USE_LEGACY_GAP, false));
568 gapLabel.setEnabled(!useLegacyGap.isSelected());
569 gapColour.setEnabled(!useLegacyGap.isSelected());
571 .setSelected(Cache.getDefault(SHOW_OV_HIDDEN_AT_START, false));
574 * Set Structure tab defaults
576 final boolean structSelected = Cache.getDefault(STRUCT_FROM_PDB, true);
577 structFromPdb.setSelected(structSelected);
578 addSecondaryStructure.setSelected(Cache.getDefault(ADD_SS_ANN, true));
579 addSecondaryStructure.setEnabled(structSelected);
580 addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, true));
581 addTempFactor.setEnabled(structSelected);
584 * set choice of structure viewer, and path if saved as a preference;
585 * default to Jmol (first choice) if an unexpected value is found
587 String viewerType = ViewerType.JMOL.name();
588 if (!Platform.isJS())
590 Cache.getDefault(STRUCTURE_DISPLAY,
591 ViewerType.JMOL.name());
593 // TODO - disable external viewers for JS
594 structViewer.setSelectedItem(viewerType);
595 String viewerPath = "";
596 ViewerType type = null;
599 type = ViewerType.valueOf(viewerType);
605 viewerPath = Cache.getDefault(CHIMERA_PATH, "");
608 viewerPath = Cache.getDefault(CHIMERAX_PATH, "");
611 viewerPath = Cache.getDefault(PYMOL_PATH, "");
614 } catch (IllegalArgumentException e)
616 Console.error("Unknown structure viewer type: " + viewerType
617 + ", defaulting to Jmol");
618 type = ViewerType.JMOL;
620 structureViewerPath.setText(viewerPath);
622 structureViewerPath.addActionListener(new ActionListener()
625 public void actionPerformed(ActionEvent e)
627 if (validateViewerPath())
629 String path = structureViewerPath.getText();
632 ViewerType type = ViewerType.valueOf(viewerType);
638 Cache.setProperty(CHIMERA_PATH, path);
641 Cache.setProperty(CHIMERAX_PATH, path);
644 Cache.setProperty(PYMOL_PATH, path);
647 } catch (IllegalArgumentException x)
649 Console.error("Failed to set path - unknown viewer type", x);
655 if (Cache.getDefault("MAP_WITH_SIFTS", false))
657 siftsMapping.setSelected(true);
661 nwMapping.setSelected(true);
665 .setMapWithSifts(Cache.getDefault("MAP_WITH_SIFTS", false));
668 * Set Connections tab defaults
672 linkUrlTable.setModel(dataModel);
673 final TableRowSorter<TableModel> sorter = new TableRowSorter<>(
674 linkUrlTable.getModel());
675 linkUrlTable.setRowSorter(sorter);
676 List<RowSorter.SortKey> sortKeys = new ArrayList<>();
678 UrlLinkTableModel m = (UrlLinkTableModel) linkUrlTable.getModel();
679 sortKeys.add(new RowSorter.SortKey(m.getPrimaryColumn(),
680 SortOrder.DESCENDING));
681 sortKeys.add(new RowSorter.SortKey(m.getSelectedColumn(),
682 SortOrder.DESCENDING));
684 new RowSorter.SortKey(m.getNameColumn(), SortOrder.ASCENDING));
686 sorter.setSortKeys(sortKeys);
687 // BH 2018 setSortKeys will do the sort
691 ActionListener onReset;
692 onReset = new ActionListener()
695 public void actionPerformed(ActionEvent e)
697 filterTB.setText("");
698 sorter.setRowFilter(RowFilter.regexFilter(""));
702 doReset.addActionListener(onReset);
704 // filter to display only custom urls
705 final RowFilter<TableModel, Object> customUrlFilter = new RowFilter<TableModel, Object>()
708 public boolean include(
709 Entry<? extends TableModel, ? extends Object> entry)
711 return ((UrlLinkTableModel) entry.getModel()).isUserEntry(entry);
715 final TableRowSorter<TableModel> customSorter = new TableRowSorter<>(
716 linkUrlTable.getModel());
717 customSorter.setRowFilter(customUrlFilter);
719 ActionListener onCustomOnly;
720 onCustomOnly = new ActionListener()
723 public void actionPerformed(ActionEvent e)
725 filterTB.setText("");
726 sorter.setRowFilter(customUrlFilter);
729 userOnly.addActionListener(onCustomOnly);
731 filterTB.getDocument().addDocumentListener(new DocumentListener()
733 String caseInsensitiveFlag = "(?i)";
736 public void changedUpdate(DocumentEvent e)
738 sorter.setRowFilter(RowFilter
739 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
743 public void removeUpdate(DocumentEvent e)
745 sorter.setRowFilter(RowFilter
746 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
750 public void insertUpdate(DocumentEvent e)
752 sorter.setRowFilter(RowFilter
753 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
757 // set up list selection functionality
758 linkUrlTable.getSelectionModel()
759 .addListSelectionListener(new UrlListSelectionHandler());
761 // set up radio buttons
762 int onClickCol = ((UrlLinkTableModel) linkUrlTable.getModel())
764 String onClickName = linkUrlTable.getColumnName(onClickCol);
765 linkUrlTable.getColumn(onClickName)
766 .setCellRenderer(new RadioButtonRenderer());
767 linkUrlTable.getColumn(onClickName)
768 .setCellEditor(new RadioButtonEditor());
770 // get boolean columns and resize those to min possible
771 for (int column = 0; column < linkUrlTable.getColumnCount(); column++)
773 if (linkUrlTable.getModel().getColumnClass(column)
774 .equals(Boolean.class))
776 TableColumn tableColumn = linkUrlTable.getColumnModel()
778 int preferredWidth = tableColumn.getMinWidth();
780 TableCellRenderer cellRenderer = linkUrlTable.getCellRenderer(0,
782 Component c = linkUrlTable.prepareRenderer(cellRenderer, 0, column);
783 int cwidth = c.getPreferredSize().width
784 + linkUrlTable.getIntercellSpacing().width;
785 preferredWidth = Math.max(preferredWidth, cwidth);
787 tableColumn.setPreferredWidth(preferredWidth);
791 String proxyTypeString = Cache.getDefault("USE_PROXY", "false");
792 previousProxyType = proxyTypeString;
793 switch (proxyTypeString)
795 case Cache.PROXYTYPE_NONE:
796 proxyType.setSelected(noProxy.getModel(), true);
798 case Cache.PROXYTYPE_SYSTEM:
799 proxyType.setSelected(systemProxy.getModel(), true);
801 case Cache.PROXYTYPE_CUSTOM:
802 proxyType.setSelected(customProxy.getModel(), true);
806 "Incorrect PROXY_TYPE - should be 'none' (clear proxy properties), 'false' (system settings), 'true' (custom settings): "
809 proxyServerHttpTB.setText(Cache.getDefault("PROXY_SERVER", ""));
810 proxyPortHttpTB.setText(Cache.getDefault("PROXY_PORT", ""));
811 proxyServerHttpsTB.setText(Cache.getDefault("PROXY_SERVER_HTTPS", ""));
812 proxyPortHttpsTB.setText(Cache.getDefault("PROXY_PORT_HTTPS", ""));
813 proxyAuth.setSelected(Cache.getDefault("PROXY_AUTH", false));
815 .setText(Cache.getDefault("PROXY_AUTH_USERNAME", ""));
816 // we are not storing or retrieving proxy password from .jalview_properties
817 proxyAuthPasswordPB.setText(Cache.proxyAuthPassword == null ? ""
818 : new String(Cache.proxyAuthPassword));
819 setCustomProxyEnabled();
820 applyProxyButtonEnabled(false);
822 defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
824 usagestats.setSelected(Cache.getDefault("USAGESTATS", false));
825 // note antisense here: default is true
827 .setSelected(Cache.getProperty("NOQUESTIONNAIRES") == null);
828 versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true));
831 * Set Output tab defaults
833 setupOutputCombo(epsRendering, "EPS_RENDERING");
834 setupOutputCombo(htmlRendering, "HTML_RENDERING");
835 setupOutputCombo(svgRendering, "SVG_RENDERING");
836 autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
837 userIdWidth.setEnabled(!autoIdWidth.isSelected());
838 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
839 Integer wi = Cache.getIntegerProperty("FIGURE_FIXEDIDWIDTH");
840 userIdWidth.setText(wi == null ? "" : wi.toString());
841 // TODO: refactor to use common enum via FormatAdapter and allow extension
842 // for new flat file formats
843 blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
844 clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
845 fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
846 msfjv.setSelected(Cache.getDefault("MSF_JVSUFFIX", true));
847 pfamjv.setSelected(Cache.getDefault("PFAM_JVSUFFIX", true));
848 pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true));
849 pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true));
850 modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false));
852 .setSelected(Cache.getDefault("EXPORT_EMBBED_BIOJSON", true));
855 * Set Editing tab defaults
857 autoCalculateConsCheck
858 .setSelected(Cache.getDefault("AUTO_CALC_CONSENSUS", true));
859 padGaps.setSelected(Cache.getDefault("PAD_GAPS", false));
860 sortByTree.setSelected(Cache.getDefault("SORT_BY_TREE", false));
862 annotations_actionPerformed(null); // update the display of the annotation
868 * Set Backups tab defaults
870 loadLastSavedBackupsOptions();
874 * A helper method that sets the items and initial selection in a character
875 * rendering option list (Prompt each time/Lineart/Text)
880 protected void setupOutputCombo(JComboBox<Object> comboBox,
883 comboBox.addItem(promptEachTimeOpt);
884 comboBox.addItem(lineArtOpt);
885 comboBox.addItem(textOpt);
889 * JalviewJS doesn't support Lineart so force it to Text
891 String defaultOption = Platform.isJS() ? "Text"
892 : Cache.getDefault(propertyKey, "Prompt each time");
893 if (defaultOption.equalsIgnoreCase("Text"))
895 comboBox.setSelectedItem(textOpt);
897 else if (defaultOption.equalsIgnoreCase("Lineart"))
899 comboBox.setSelectedItem(lineArtOpt);
903 comboBox.setSelectedItem(promptEachTimeOpt);
908 * Save user selections on the Preferences tabs to the Cache and write out to
914 public void ok_actionPerformed(ActionEvent e)
916 if (!validateSettings())
922 * Set proxy settings first (to be before web services refresh)
927 * Save Visual settings
929 Cache.setPropertyNoSave("SHOW_JVSUFFIX",
930 Boolean.toString(seqLimit.isSelected()));
931 Cache.setPropertyNoSave("RIGHT_ALIGN_IDS",
932 Boolean.toString(rightAlign.isSelected()));
933 Cache.setPropertyNoSave("SHOW_FULLSCREEN",
934 Boolean.toString(fullScreen.isSelected()));
935 Cache.setPropertyNoSave("SHOW_OVERVIEW",
936 Boolean.toString(openoverv.isSelected()));
937 Cache.setPropertyNoSave("SHOW_ANNOTATIONS",
938 Boolean.toString(annotations.isSelected()));
939 Cache.setPropertyNoSave("SHOW_CONSERVATION",
940 Boolean.toString(conservation.isSelected()));
941 Cache.setPropertyNoSave("SHOW_QUALITY",
942 Boolean.toString(quality.isSelected()));
943 Cache.setPropertyNoSave("SHOW_IDENTITY",
944 Boolean.toString(identity.isSelected()));
946 Cache.setPropertyNoSave("GAP_SYMBOL",
947 gapSymbolCB.getSelectedItem().toString());
949 Cache.setPropertyNoSave("FONT_NAME",
950 fontNameCB.getSelectedItem().toString());
951 Cache.setPropertyNoSave("FONT_STYLE",
952 fontStyleCB.getSelectedItem().toString());
953 Cache.setPropertyNoSave("FONT_SIZE",
954 fontSizeCB.getSelectedItem().toString());
956 Cache.setPropertyNoSave("ID_ITALICS",
957 Boolean.toString(idItalics.isSelected()));
958 Cache.setPropertyNoSave("SHOW_UNCONSERVED",
959 Boolean.toString(showUnconserved.isSelected()));
960 Cache.setPropertyNoSave(SHOW_OCCUPANCY,
961 Boolean.toString(showOccupancy.isSelected()));
962 Cache.setPropertyNoSave("SHOW_GROUP_CONSENSUS",
963 Boolean.toString(showGroupConsensus.isSelected()));
964 Cache.setPropertyNoSave("SHOW_GROUP_CONSERVATION",
965 Boolean.toString(showGroupConservation.isSelected()));
966 Cache.setPropertyNoSave("SHOW_CONSENSUS_HISTOGRAM",
967 Boolean.toString(showConsensHistogram.isSelected()));
968 Cache.setPropertyNoSave("SHOW_CONSENSUS_LOGO",
969 Boolean.toString(showConsensLogo.isSelected()));
970 Cache.setPropertyNoSave("SHOW_INFORMATION_HISTOGRAM",
971 Boolean.toString(showConsensHistogram.isSelected()));
972 Cache.setPropertyNoSave("SHOW_HMM_LOGO",
973 Boolean.toString(showHMMLogo.isSelected()));
974 Cache.setPropertyNoSave("ANTI_ALIAS",
975 Boolean.toString(smoothFont.isSelected()));
976 Cache.setPropertyNoSave(SCALE_PROTEIN_TO_CDNA,
977 Boolean.toString(scaleProteinToCdna.isSelected()));
978 Cache.setPropertyNoSave("SHOW_NPFEATS_TOOLTIP",
979 Boolean.toString(showNpTooltip.isSelected()));
980 Cache.setPropertyNoSave("SHOW_DBREFS_TOOLTIP",
981 Boolean.toString(showDbRefTooltip.isSelected()));
983 Cache.setPropertyNoSave("WRAP_ALIGNMENT",
984 Boolean.toString(wrap.isSelected()));
986 Cache.setPropertyNoSave("STARTUP_FILE",
987 startupFileTextfield.getText());
988 Cache.setPropertyNoSave("SHOW_STARTUP_FILE",
989 Boolean.toString(startupCheckbox.isSelected()));
991 Cache.setPropertyNoSave("SORT_ALIGNMENT",
992 sortby.getSelectedItem().toString());
994 // convert description of sort order to enum name for save
995 SequenceAnnotationOrder annSortOrder = SequenceAnnotationOrder
996 .forDescription(sortAnnBy.getSelectedItem().toString());
997 if (annSortOrder != null)
999 Cache.setPropertyNoSave(SORT_ANNOTATIONS,
1000 annSortOrder.name());
1003 final boolean showAutocalcFirst = sortAutocalc.getSelectedIndex() == 0;
1004 Cache.setPropertyNoSave(SHOW_AUTOCALC_ABOVE,
1005 Boolean.valueOf(showAutocalcFirst).toString());
1008 * Save Colours settings
1010 Cache.setPropertyNoSave(DEFAULT_COLOUR_PROT,
1011 protColour.getSelectedItem().toString());
1012 Cache.setPropertyNoSave(DEFAULT_COLOUR_NUC,
1013 nucColour.getSelectedItem().toString());
1014 Cache.setColourPropertyNoSave("ANNOTATIONCOLOUR_MIN",
1015 minColour.getBackground());
1016 Cache.setColourPropertyNoSave("ANNOTATIONCOLOUR_MAX",
1017 maxColour.getBackground());
1020 * Save HMMER settings
1022 Cache.setPropertyNoSave(HMMALIGN_TRIM_TERMINI,
1023 Boolean.toString(hmmrTrimTermini.isSelected()));
1024 Cache.setPropertyNoSave(HMMINFO_GLOBAL_BACKGROUND,
1025 Boolean.toString(hmmerBackgroundUniprot.isSelected()));
1026 Cache.setPropertyNoSave(HMMSEARCH_SEQCOUNT,
1027 hmmerSequenceCount.getText());
1028 Cache.setOrRemove(HMMER_PATH, hmmerPath.getText());
1029 if (cygwinPath != null)
1031 Cache.setOrRemove(CYGWIN_PATH, cygwinPath.getText());
1033 AlignFrame[] frames = Desktop.getAlignFrames();
1034 if (frames != null && frames.length > 0)
1036 for (AlignFrame f : frames)
1038 f.updateHMMERStatus();
1042 hmmrTrimTermini.setSelected(Cache.getDefault(HMMALIGN_TRIM_TERMINI, false));
1043 if (Cache.getDefault(HMMINFO_GLOBAL_BACKGROUND, false))
1045 hmmerBackgroundUniprot.setSelected(true);
1049 hmmerBackgroundAlignment.setSelected(true);
1052 .setText(Cache.getProperty(HMMSEARCH_SEQCOUNT));
1053 hmmerPath.setText(Cache.getProperty(HMMER_PATH));
1056 * Save Overview settings
1058 Cache.setColourPropertyNoSave(GAP_COLOUR, gapColour.getBackground());
1059 Cache.setColourPropertyNoSave(HIDDEN_COLOUR, hiddenColour.getBackground());
1060 Cache.setPropertyNoSave(USE_LEGACY_GAP,
1061 Boolean.toString(useLegacyGap.isSelected()));
1062 Cache.setPropertyNoSave(SHOW_OV_HIDDEN_AT_START,
1063 Boolean.toString(showHiddenAtStart.isSelected()));
1066 * Save Structure settings
1068 Cache.setPropertyNoSave(ADD_TEMPFACT_ANN,
1069 Boolean.toString(addTempFactor.isSelected()));
1070 Cache.setPropertyNoSave(ADD_SS_ANN,
1071 Boolean.toString(addSecondaryStructure.isSelected()));
1072 Cache.setPropertyNoSave(STRUCT_FROM_PDB,
1073 Boolean.toString(structFromPdb.isSelected()));
1074 if (!Platform.isJS()) {
1075 String viewer = structViewer.getSelectedItem().toString();
1076 String viewerPath = structureViewerPath.getText();
1077 Cache.setPropertyNoSave(STRUCTURE_DISPLAY, viewer);
1078 if (viewer.equals(ViewerType.CHIMERA.name()))
1080 Cache.setOrRemove(CHIMERA_PATH, viewerPath);
1082 else if (viewer.equals(ViewerType.CHIMERAX.name()))
1084 Cache.setOrRemove(CHIMERAX_PATH, viewerPath);
1086 else if (viewer.equals(ViewerType.PYMOL.name()))
1088 Cache.setOrRemove(PYMOL_PATH, viewerPath);
1091 Cache.setPropertyNoSave("MAP_WITH_SIFTS",
1092 Boolean.toString(siftsMapping.isSelected()));
1093 SiftsSettings.setMapWithSifts(siftsMapping.isSelected());
1096 * Save Output settings
1098 Cache.setPropertyNoSave("EPS_RENDERING",
1099 ((OptionsParam) epsRendering.getSelectedItem()).getCode());
1100 Cache.setPropertyNoSave("HTML_RENDERING",
1101 ((OptionsParam) htmlRendering.getSelectedItem()).getCode());
1102 Cache.setPropertyNoSave("SVG_RENDERING",
1103 ((OptionsParam) svgRendering.getSelectedItem()).getCode());
1106 * Save Connections settings
1108 // Proxy settings were already set first (to catch web services)
1109 Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
1111 jalview.util.BrowserLauncher.resetBrowser();
1113 // save user-defined and selected links
1114 String menuLinks = sequenceUrlLinks.writeUrlsAsString(true);
1115 if (menuLinks.isEmpty())
1117 Cache.removePropertyNoSave("SEQUENCE_LINKS");
1121 Cache.setPropertyNoSave("SEQUENCE_LINKS",
1122 menuLinks.toString());
1125 String nonMenuLinks = sequenceUrlLinks.writeUrlsAsString(false);
1126 if (nonMenuLinks.isEmpty())
1128 Cache.removePropertyNoSave("STORED_LINKS");
1132 Cache.setPropertyNoSave("STORED_LINKS",
1133 nonMenuLinks.toString());
1136 Cache.setPropertyNoSave("DEFAULT_URL",
1137 sequenceUrlLinks.getPrimaryUrlId());
1139 Cache.setProperty("VERSION_CHECK",
1140 Boolean.toString(versioncheck.isSelected()));
1141 if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
1143 // default is false - we only set this if the user has actively agreed
1144 Cache.setProperty("USAGESTATS",
1145 Boolean.toString(usagestats.isSelected()));
1147 if (!questionnaire.isSelected())
1149 Cache.setProperty("NOQUESTIONNAIRES", "true");
1153 // special - made easy to edit a property file to disable questionnaires
1154 // by just adding the given line
1155 Cache.removeProperty("NOQUESTIONNAIRES");
1159 * Save Output settings
1161 Cache.setPropertyNoSave("BLC_JVSUFFIX",
1162 Boolean.toString(blcjv.isSelected()));
1163 Cache.setPropertyNoSave("CLUSTAL_JVSUFFIX",
1164 Boolean.toString(clustaljv.isSelected()));
1165 Cache.setPropertyNoSave("FASTA_JVSUFFIX",
1166 Boolean.toString(fastajv.isSelected()));
1167 Cache.setPropertyNoSave("MSF_JVSUFFIX",
1168 Boolean.toString(msfjv.isSelected()));
1169 Cache.setPropertyNoSave("PFAM_JVSUFFIX",
1170 Boolean.toString(pfamjv.isSelected()));
1171 Cache.setPropertyNoSave("PILEUP_JVSUFFIX",
1172 Boolean.toString(pileupjv.isSelected()));
1173 Cache.setPropertyNoSave("PIR_JVSUFFIX",
1174 Boolean.toString(pirjv.isSelected()));
1175 Cache.setPropertyNoSave("PIR_MODELLER",
1176 Boolean.toString(modellerOutput.isSelected()));
1177 Cache.setPropertyNoSave("EXPORT_EMBBED_BIOJSON",
1178 Boolean.toString(embbedBioJSON.isSelected()));
1179 jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
1181 Cache.setPropertyNoSave("FIGURE_AUTOIDWIDTH",
1182 Boolean.toString(autoIdWidth.isSelected()));
1183 userIdWidth_actionPerformed();
1184 Cache.setPropertyNoSave("FIGURE_FIXEDIDWIDTH",
1185 userIdWidth.getText());
1188 * Save Editing settings
1190 Cache.setPropertyNoSave("AUTO_CALC_CONSENSUS",
1191 Boolean.toString(autoCalculateConsCheck.isSelected()));
1192 Cache.setPropertyNoSave("SORT_BY_TREE",
1193 Boolean.toString(sortByTree.isSelected()));
1194 Cache.setPropertyNoSave("PAD_GAPS",
1195 Boolean.toString(padGaps.isSelected()));
1197 if (!Platform.isJS())
1199 wsPrefs.updateAndRefreshWsMenuConfig(false);
1203 * Save Backups settings
1205 Cache.setPropertyNoSave(BackupFiles.ENABLED,
1206 Boolean.toString(enableBackupFiles.isSelected()));
1207 int preset = getComboIntStringKey(backupfilesPresetsCombo);
1208 Cache.setPropertyNoSave(BackupFiles.NS + "_PRESET", Integer.toString(preset));
1210 if (preset == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
1212 BackupFilesPresetEntry customBFPE = getBackupfilesCurrentEntry();
1213 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
1214 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM, customBFPE);
1215 Cache.setPropertyNoSave(BackupFilesPresetEntry.CUSTOMCONFIG,
1216 customBFPE.toString());
1219 BackupFilesPresetEntry savedBFPE = BackupFilesPresetEntry.backupfilesPresetEntriesValues
1221 Cache.setPropertyNoSave(
1222 BackupFilesPresetEntry.SAVEDCONFIG, savedBFPE.toString());
1225 * Save Memory Settings
1227 Cache.setPropertyNoSave(
1228 MemorySetting.CUSTOMISED_SETTINGS,
1229 Boolean.toString(customiseMemorySetting.isSelected()));
1230 Cache.setPropertyNoSave(MemorySetting.MEMORY_JVMMEMPC,
1231 Integer.toString(jvmMemoryPercentSlider.getValue()));
1232 Cache.setPropertyNoSave(MemorySetting.MEMORY_JVMMEMMAX,
1233 jvmMemoryMaxTextField.getText());
1236 * save and close Preferences
1238 Cache.saveProperties();
1239 Desktop.getInstance().doConfigureStructurePrefs();
1242 frame.setClosed(true);
1243 } catch (Exception ex)
1248 public void saveProxySettings()
1250 String newProxyType = customProxy.isSelected() ? Cache.PROXYTYPE_CUSTOM
1251 : noProxy.isSelected() ? Cache.PROXYTYPE_NONE
1252 : Cache.PROXYTYPE_SYSTEM;
1253 Cache.setPropertyNoSave("USE_PROXY", newProxyType);
1254 Cache.setOrRemove("PROXY_SERVER", proxyServerHttpTB.getText());
1255 Cache.setOrRemove("PROXY_PORT", proxyPortHttpTB.getText());
1256 Cache.setOrRemove("PROXY_SERVER_HTTPS", proxyServerHttpsTB.getText());
1257 Cache.setOrRemove("PROXY_PORT_HTTPS", proxyPortHttpsTB.getText());
1258 Cache.setOrRemove("PROXY_AUTH",
1259 Boolean.toString(proxyAuth.isSelected()));
1260 Cache.setOrRemove("PROXY_AUTH_USERNAME", proxyAuthUsernameTB.getText());
1261 Cache.proxyAuthPassword = proxyAuthPasswordPB.getPassword();
1262 Cache.setProxyPropertiesFromPreferences(previousProxyType);
1263 if (newProxyType.equals(Cache.PROXYTYPE_CUSTOM)
1264 || !newProxyType.equals(previousProxyType))
1266 // force a re-lookup of ws if proxytype is custom or has changed
1267 wsPrefs.refreshWs_actionPerformed(null);
1269 previousProxyType = newProxyType;
1272 public static void setAppletDefaults()
1275 // http://www.jalview.org/old/v2_8/examples/appletParameters.html
1277 // showConservation true or false Default is true.
1278 // showQuality true or false Default is true.
1279 // showConsensus true or false Default is true.
1280 // showFeatureSettings true or false Shows the feature settings window when
1282 // showTreeBootstraps true or false (default is true) show or hide branch
1284 // showTreeDistances true or false (default is true) show or hide branch
1286 // showUnlinkedTreeNodes true or false (default is false) indicate if
1287 // unassociated nodes should be highlighted in the tree view
1288 // showUnconserved true of false (default is false) When true, only gaps and
1289 // symbols different to the consensus sequence ions of the alignment
1290 // showGroupConsensus true of false (default is false) When true, shows
1291 // consensus annotation row for any groups on the alignment. (since 2.7)
1292 // showGroupConservation true of false (default is false) When true, shows
1293 // amino-acid property conservation annotation row for any groups on the
1294 // showConsensusHistogram true of false (default is true) When true, shows
1295 // the percentage occurence of the consensus symbol for each column as a
1296 // showSequenceLogo true of false (default is false) When true, shows a
1297 // sequence logo above the consensus sequence (overlaid above the Consensus
1299 Cache.setPropertyNoSave(SHOW_CONSERVATION, "true");
1300 Cache.setPropertyNoSave(SHOW_QUALITY, "false");
1301 Cache.setPropertyNoSave(SHOW_CONSENSUS, "true");
1302 Cache.setPropertyNoSave(SHOW_UNCONSERVED, "false");
1303 Cache.setPropertyNoSave(SHOW_GROUP_CONSERVATION, "false");
1304 Cache.setPropertyNoSave(SHOW_GROUP_CONSENSUS, "false");
1306 // TODO -- just a start here
1309 * Do any necessary validation before saving settings. Return focus to the
1310 * first tab which fails validation.
1314 private boolean validateSettings()
1316 if (!validateStructure())
1318 structureTab.requestFocusInWindow();
1325 protected boolean validateStructure()
1327 return validateViewerPath();
1335 public void startupFileTextfield_mouseClicked()
1337 // TODO: JAL-3048 not needed for Jalview-JS
1338 String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
1339 JalviewFileChooser chooser = JalviewFileChooser
1340 .forRead(Cache.getProperty("LAST_DIRECTORY"), fileFormat);
1341 chooser.setFileView(new JalviewFileView());
1342 chooser.setDialogTitle(
1343 MessageManager.getString("label.select_startup_file"));
1345 int value = chooser.showOpenDialog(this);
1347 if (value == JalviewFileChooser.APPROVE_OPTION)
1349 FileFormatI format = chooser.getSelectedFormat();
1352 Cache.setPropertyNoSave("DEFAULT_FILE_FORMAT",
1355 startupFileTextfield
1356 .setText(chooser.getSelectedFile().getAbsolutePath());
1367 public void cancel_actionPerformed(ActionEvent e)
1371 if (!Platform.isJS())
1373 wsPrefs.updateWsMenuConfig(true);
1374 wsPrefs.refreshWs_actionPerformed(e);
1376 frame.setClosed(true);
1377 } catch (Exception ex)
1389 public void annotations_actionPerformed(ActionEvent e)
1391 conservation.setEnabled(annotations.isSelected());
1392 quality.setEnabled(annotations.isSelected());
1393 identity.setEnabled(annotations.isSelected());
1394 showOccupancy.setEnabled(annotations.isSelected());
1395 showGroupConsensus.setEnabled(annotations.isSelected());
1396 showGroupConservation.setEnabled(annotations.isSelected());
1397 showConsensHistogram.setEnabled(annotations.isSelected()
1398 && (identity.isSelected() || showGroupConsensus.isSelected()));
1399 showConsensLogo.setEnabled(annotations.isSelected()
1400 && (identity.isSelected() || showGroupConsensus.isSelected()));
1401 showInformationHistogram.setEnabled(annotations.isSelected());
1402 showHMMLogo.setEnabled(annotations.isSelected());
1406 public void newLink_actionPerformed(ActionEvent e)
1408 GSequenceLink link = new GSequenceLink();
1409 boolean valid = false;
1412 if (JvOptionPane.showInternalConfirmDialog(Desktop.getDesktopPane(), link,
1413 MessageManager.getString("label.new_sequence_url_link"),
1414 JvOptionPane.OK_CANCEL_OPTION, -1,
1415 null) == JvOptionPane.OK_OPTION)
1417 if (link.checkValid())
1419 if (((UrlLinkTableModel) linkUrlTable.getModel())
1420 .isUniqueName(link.getName()))
1422 ((UrlLinkTableModel) linkUrlTable.getModel())
1423 .insertRow(link.getName(), link.getURL());
1428 link.notifyDuplicate();
1441 public void editLink_actionPerformed(ActionEvent e)
1443 GSequenceLink link = new GSequenceLink();
1445 int index = linkUrlTable.getSelectedRow();
1448 // button no longer enabled if row is not selected
1449 Console.debug("Edit with no row selected in linkUrlTable");
1453 int nameCol = ((UrlLinkTableModel) linkUrlTable.getModel())
1455 int urlCol = ((UrlLinkTableModel) linkUrlTable.getModel())
1457 String oldName = linkUrlTable.getValueAt(index, nameCol).toString();
1458 link.setName(oldName);
1459 link.setURL(linkUrlTable.getValueAt(index, urlCol).toString());
1461 boolean valid = false;
1464 if (JvOptionPane.showInternalConfirmDialog(Desktop.getDesktopPane(), link,
1465 MessageManager.getString("label.edit_sequence_url_link"),
1466 JvOptionPane.OK_CANCEL_OPTION, -1,
1467 null) == JvOptionPane.OK_OPTION)
1469 if (link.checkValid())
1471 if ((oldName.equals(link.getName()))
1472 || (((UrlLinkTableModel) linkUrlTable.getModel())
1473 .isUniqueName(link.getName())))
1475 linkUrlTable.setValueAt(link.getName(), index, nameCol);
1476 linkUrlTable.setValueAt(link.getURL(), index, urlCol);
1481 link.notifyDuplicate();
1494 public void deleteLink_actionPerformed(ActionEvent e)
1496 int index = linkUrlTable.getSelectedRow();
1497 int modelIndex = -1;
1500 // button no longer enabled if row is not selected
1501 Console.debug("Delete with no row selected in linkUrlTable");
1506 modelIndex = linkUrlTable.convertRowIndexToModel(index);
1509 // make sure we use the model index to delete, and not the table index
1510 ((UrlLinkTableModel) linkUrlTable.getModel()).removeRow(modelIndex);
1514 public void defaultBrowser_mouseClicked(MouseEvent e)
1516 // TODO: JAL-3048 not needed for j2s
1517 if (!Platform.isJS()) // BH 2019
1524 JFileChooser chooser = new JFileChooser(".");
1525 chooser.setDialogTitle(
1526 MessageManager.getString("label.select_default_browser"));
1528 int value = chooser.showOpenDialog(this);
1530 if (value == JFileChooser.APPROVE_OPTION)
1532 defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath());
1541 * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event
1545 protected void showunconserved_actionPerformed(ActionEvent e)
1547 // TODO Auto-generated method stub
1548 super.showunconserved_actionPerformed(e);
1551 public static List<String> getGroupURLLinks()
1553 return groupURLLinks;
1557 public void minColour_actionPerformed(JPanel panel)
1559 JalviewColourChooser.showColourChooser(this,
1560 MessageManager.getString("label.select_colour_minimum_value"),
1565 public void maxColour_actionPerformed(JPanel panel)
1567 JalviewColourChooser.showColourChooser(this,
1568 MessageManager.getString("label.select_colour_maximum_value"),
1573 public void gapColour_actionPerformed(JPanel gap)
1575 if (!useLegacyGap.isSelected())
1577 JalviewColourChooser.showColourChooser(this,
1578 MessageManager.getString("label.select_gap_colour"),
1584 public void hiddenColour_actionPerformed(JPanel hidden)
1586 JalviewColourChooser.showColourChooser(this,
1587 MessageManager.getString("label.select_hidden_colour"),
1592 protected void useLegacyGaps_actionPerformed(ActionEvent e)
1594 boolean enabled = useLegacyGap.isSelected();
1597 gapColour.setBackground(
1598 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_LEGACY_GAP);
1602 gapColour.setBackground(
1603 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP);
1605 gapColour.setEnabled(!enabled);
1606 gapLabel.setEnabled(!enabled);
1610 protected void resetOvDefaults_actionPerformed(ActionEvent e)
1612 useLegacyGap.setSelected(false);
1613 useLegacyGaps_actionPerformed(null);
1614 showHiddenAtStart.setSelected(false);
1615 hiddenColour.setBackground(
1616 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_HIDDEN);
1620 protected void userIdWidth_actionPerformed()
1624 String val = userIdWidth.getText().trim();
1625 if (val.length() > 0)
1627 Integer iw = Integer.parseInt(val);
1628 if (iw.intValue() < 12)
1630 throw new NumberFormatException();
1632 userIdWidth.setText(iw.toString());
1634 } catch (NumberFormatException x)
1636 userIdWidth.setText("");
1637 JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
1639 .getString("warn.user_defined_width_requirements"),
1640 MessageManager.getString("label.invalid_id_column_width"),
1641 JvOptionPane.WARNING_MESSAGE);
1646 protected void autoIdWidth_actionPerformed()
1648 userIdWidth.setEnabled(!autoIdWidth.isSelected());
1649 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
1653 * Returns true if structure viewer path is to a valid executable, else shows an
1654 * error dialog. Does nothing if the path is empty, as is the case for Jmol
1655 * (built in to Jalview) or when Jalview is left to try default paths.
1657 private boolean validateViewerPath()
1659 if (structureViewerPath.getText().trim().length() > 0)
1661 File f = new File(structureViewerPath.getText());
1662 if (!f.canExecute())
1664 JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
1665 MessageManager.getString("label.invalid_viewer_path"),
1666 MessageManager.getString("label.invalid_viewer_path"),
1667 JvOptionPane.ERROR_MESSAGE);
1675 * Returns true if the given text field contains a path to a folder that
1676 * contains an executable with the given name, else false (after showing a
1677 * warning dialog). The executable name will be tried with .exe appended if not
1683 protected boolean validateExecutablePath(JTextField textField, String executable)
1685 String folder = textField.getText().trim();
1687 if (FileUtils.getExecutable(executable, folder) != null)
1691 if (folder.length() > 0)
1693 JvOptionPane.showInternalMessageDialog(Desktop.getInstance(),
1694 MessageManager.formatMessage("label.executable_not_found",
1696 MessageManager.getString("label.invalid_folder"),
1697 JvOptionPane.ERROR_MESSAGE);
1703 * Checks if a file can be executed
1706 * the path to the file
1709 public boolean canExecute(String path)
1711 File file = new File(path);
1712 if (!file.canExecute())
1714 file = new File(path + ".exe");
1716 if (!file.canExecute())
1726 * If Chimera or ChimeraX or Pymol is selected, check it can be found on default
1727 * or user-specified path, if not show a warning/help dialog
1730 protected void structureViewer_actionPerformed(String selectedItem)
1732 if (selectedItem.equals(ViewerType.JMOL.name()))
1734 structureViewerPath.setEnabled(false);
1735 structureViewerPathLabel.setEnabled(false);
1738 boolean found = false;
1739 structureViewerPath.setEnabled(true);
1740 structureViewerPathLabel.setEnabled(true);
1741 structureViewerPathLabel.setText(MessageManager
1742 .formatMessage("label.viewer_path", selectedItem));
1745 * Try user-specified and standard paths for structure viewer executable
1747 String viewerPath = "";
1748 List<String> paths = null;
1751 ViewerType viewerType = ViewerType.valueOf(selectedItem);
1758 viewerPath = Cache.getDefault(CHIMERA_PATH, "");
1759 paths = StructureManager.getChimeraPaths(false);
1762 viewerPath = Cache.getDefault(CHIMERAX_PATH, "");
1763 paths = StructureManager.getChimeraPaths(true);
1766 viewerPath = Cache.getDefault(PYMOL_PATH, "");
1767 paths = PymolManager.getPymolPaths();
1770 } catch (IllegalArgumentException e)
1772 // only valid entries should be in the drop-down
1774 structureViewerPath.setText(viewerPath);
1776 paths.add(0, structureViewerPath.getText());
1777 for (String path : paths)
1779 if (new File(path.trim()).canExecute())
1788 String[] options = { "OK", "Help" };
1789 int showHelp = JvOptionPane.showInternalOptionDialog(Desktop.getDesktopPane(),
1790 JvSwingUtils.wrapTooltip(true,
1791 MessageManager.getString("label.viewer_missing")),
1792 "", JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE,
1793 null, options, options[0]);
1795 if (showHelp == JvOptionPane.NO_OPTION)
1797 this.selectTab(Preferences.TabRef.STRUCTURE_TAB, null);
1800 Help.showHelpWindow(HelpId.StructureViewer);
1801 } catch (HelpSetException e)
1803 e.printStackTrace();
1806 else if (showHelp == JvOptionPane.OK_OPTION)
1808 this.selectTab(Preferences.TabRef.STRUCTURE_TAB, null);
1809 CompletableFuture<Void> cf = CompletableFuture.runAsync(() -> {
1812 for (int i = 0; i < 3; i++)
1814 structureViewerPath.setBackground(Color.PINK);
1816 structureViewerPath.setBackground(Color.WHITE);
1819 } catch (InterruptedException e)
1828 protected void validateHmmerPath()
1830 validateExecutablePath(hmmerPath, HmmerCommand.HMMBUILD);
1834 protected void validateCygwinPath()
1836 validateExecutablePath(cygwinPath, "run");
1839 public class OptionsParam
1841 private String name;
1843 private String code;
1845 public OptionsParam(String name, String code)
1851 public String getName()
1856 public void setName(String name)
1861 public String getCode()
1866 public void setCode(String code)
1872 public String toString()
1878 public boolean equals(Object that)
1880 if (!(that instanceof OptionsParam))
1884 return this.code.equalsIgnoreCase(((OptionsParam) that).code);
1888 public int hashCode()
1890 return name.hashCode() + code.hashCode();
1894 private class UrlListSelectionHandler implements ListSelectionListener
1898 public void valueChanged(ListSelectionEvent e)
1900 ListSelectionModel lsm = (ListSelectionModel) e.getSource();
1902 int index = lsm.getMinSelectionIndex();
1905 // no selection, so disable delete/edit buttons
1906 editLink.setEnabled(false);
1907 deleteLink.setEnabled(false);
1910 int modelIndex = linkUrlTable.convertRowIndexToModel(index);
1912 // enable/disable edit and delete link buttons
1913 if (((UrlLinkTableModel) linkUrlTable.getModel())
1914 .isRowDeletable(modelIndex))
1916 deleteLink.setEnabled(true);
1920 deleteLink.setEnabled(false);
1923 if (((UrlLinkTableModel) linkUrlTable.getModel())
1924 .isRowEditable(modelIndex))
1926 editLink.setEnabled(true);
1930 editLink.setEnabled(false);