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 jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
24 import jalview.bin.Cache;
25 import jalview.gui.Help.HelpId;
26 import jalview.gui.StructureViewer.ViewerType;
27 import jalview.io.BackupFiles;
28 import jalview.io.FileFormatI;
29 import jalview.io.JalviewFileChooser;
30 import jalview.io.JalviewFileView;
31 import jalview.jbgui.GPreferences;
32 import jalview.jbgui.GSequenceLink;
33 import jalview.schemes.ColourSchemeI;
34 import jalview.schemes.ColourSchemes;
35 import jalview.schemes.ResidueColourScheme;
36 import jalview.urls.UrlLinkTableModel;
37 import jalview.urls.api.UrlProviderFactoryI;
38 import jalview.urls.api.UrlProviderI;
39 import jalview.urls.desktop.DesktopUrlProviderFactory;
40 import jalview.util.BrowserLauncher;
41 import jalview.util.MessageManager;
42 import jalview.util.Platform;
43 import jalview.util.UrlConstants;
44 import jalview.ws.sifts.SiftsSettings;
46 import java.awt.BorderLayout;
47 import java.awt.Color;
48 import java.awt.Component;
49 import java.awt.Dimension;
51 import java.awt.event.ActionEvent;
52 import java.awt.event.ActionListener;
53 import java.awt.event.MouseEvent;
55 import java.util.ArrayList;
56 import java.util.List;
58 import javax.help.HelpSetException;
59 import javax.swing.JComboBox;
60 import javax.swing.JFileChooser;
61 import javax.swing.JInternalFrame;
62 import javax.swing.JPanel;
63 import javax.swing.ListSelectionModel;
64 import javax.swing.RowFilter;
65 import javax.swing.RowSorter;
66 import javax.swing.SortOrder;
67 import javax.swing.event.DocumentEvent;
68 import javax.swing.event.DocumentListener;
69 import javax.swing.event.ListSelectionEvent;
70 import javax.swing.event.ListSelectionListener;
71 import javax.swing.table.TableCellRenderer;
72 import javax.swing.table.TableColumn;
73 import javax.swing.table.TableModel;
74 import javax.swing.table.TableRowSorter;
76 import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
84 @SuppressWarnings("serial")
85 public class Preferences extends GPreferences
88 public static final String NOQUESTIONNAIRES = "NOQUESTIONNAIRES";
90 public static final String QUESTIONNAIRE = "QUESTIONNAIRE";
92 public static final String ANNOTATIONCOLOUR_MAX = "ANNOTATIONCOLOUR_MAX";
94 public static final String ANNOTATIONCOLOUR_MIN = "ANNOTATIONCOLOUR_MIN";
96 public static final String ENABLE_SPLIT_FRAME = "ENABLE_SPLIT_FRAME";
98 public static final String SCALE_PROTEIN_TO_CDNA = "SCALE_PROTEIN_TO_CDNA";
100 public static final String DEFAULT_COLOUR = "DEFAULT_COLOUR";
102 public static final String DEFAULT_COLOUR_PROT = "DEFAULT_COLOUR_PROT";
104 public static final String DEFAULT_COLOUR_NUC = "DEFAULT_COLOUR_NUC";
106 public static final String ADD_TEMPFACT_ANN = "ADD_TEMPFACT_ANN";
108 public static final String ADD_SS_ANN = "ADD_SS_ANN";
110 public static final String USE_RNAVIEW = "USE_RNAVIEW";
112 public static final String STRUCT_FROM_PDB = "STRUCT_FROM_PDB";
114 public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY";
116 public static final String CHIMERA_PATH = "CHIMERA_PATH";
118 public static final String SORT_ALIGNMENT = "SORT_ALIGNMENT";
120 public static final String WRAP_ALIGNMENT = "WRAP_ALIGNMENT";
122 public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS";
124 public static final String SORT_BY_TREE = "SORT_BY_TREE";
126 public static final String SHOW_ANNOTATIONS = "SHOW_ANNOTATIONS";
128 public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE";
130 public static final String SHOW_CONSERVATION = "SHOW_CONSERVATION";
132 public static final String SHOW_QUALITY = "SHOW_QUALITY";
134 public static final String SHOW_CONSENSUS_HISTOGRAM = "SHOW_CONSENSUS_HISTOGRAM";
136 public static final String SHOW_CONSENSUS = "SHOW_CONSENSUS";
138 public static final String SHOW_CONSENSUS_LOGO = "SHOW_CONSENSUS_LOGO";
140 public static final String SHOW_GROUP_CONSENSUS = "SHOW_GROUP_CONSENSUS";
142 public static final String SHOW_GROUP_CONSERVATION = "SHOW_GROUP_CONSERVATION";
144 public static final String NORMALISE_CONSENSUS_LOGO = "NORMALISE_CONSENSUS_LOGO";
146 public static final String NORMALISE_LOGO = "NORMALISE_LOGO";
148 public static final String SHOW_OCCUPANCY = "SHOW_OCCUPANCY";
150 public static final String SHOW_OVERVIEW = "SHOW_OVERVIEW";
152 public static final String SHOW_UNCONSERVED = "SHOW_UNCONSERVED";
154 public static final String SHOW_OV_HIDDEN_AT_START = "SHOW_OV_HIDDEN_AT_START";
156 public static final String USER_DEFINED_COLOURS = "USER_DEFINED_COLOURS";
158 public static final String USE_LEGACY_GAP = "USE_LEGACY_GAP";
160 public static final String GAP_COLOUR = "GAP_COLOUR";
162 public static final String HIDDEN_COLOUR = "HIDDEN_COLOUR";
164 private static final int MIN_FONT_SIZE = 1;
166 private static final int MAX_FONT_SIZE = 30;
169 * Holds name and link separated with | character. Sequence ID must be
170 * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$
172 public static UrlProviderI sequenceUrlLinks; // must be nonfinal for test
174 public final static UrlLinkTableModel dataModel;
177 * Holds name and link separated with | character. Sequence IDS and Sequences
178 * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and
179 * $SEQUENCES$ or $SEQUENCES=/.possible | chars ./=$ and separation character
180 * for first and second token specified after a pipe character at end |,|.
181 * (TODO: proper escape for using | to separate ids or sequences
184 public static final List<String> groupURLLinks; // not implemented
189 // get links selected to be in the menu (SEQUENCE_LINKS)
190 // and links entered by the user but not selected (STORED_LINKS)
191 String inMenuString = Cache.getDefault("SEQUENCE_LINKS", "");
192 String notInMenuString = Cache.getDefault("STORED_LINKS", "");
193 String defaultUrl = Cache.getDefault("DEFAULT_URL",
194 UrlConstants.DEFAULT_LABEL);
196 // if both links lists are empty, add the DEFAULT_URL link
197 // otherwise we assume the default link is in one of the lists
198 if (inMenuString.isEmpty() && notInMenuString.isEmpty())
200 inMenuString = UrlConstants.DEFAULT_STRING;
202 UrlProviderFactoryI factory = new DesktopUrlProviderFactory(defaultUrl,
203 inMenuString, notInMenuString);
204 sequenceUrlLinks = factory.createUrlProvider();
205 dataModel = new UrlLinkTableModel(sequenceUrlLinks);
208 * TODO: reformulate groupURL encoding so two or more can be stored in the
209 * .properties file as '|' separated strings
212 groupURLLinks = new ArrayList<>(); // not implemented
215 JInternalFrame frame;
217 private WsPreferences wsPrefs;
219 private OptionsParam promptEachTimeOpt = new OptionsParam(
220 MessageManager.getString("label.prompt_each_time"),
223 private OptionsParam lineArtOpt = new OptionsParam(
224 MessageManager.getString("label.lineart"), "Lineart");
226 private OptionsParam textOpt = new OptionsParam(
227 MessageManager.getString("action.text"), "Text");
230 * Creates a new Preferences object.
235 frame = new JInternalFrame();
236 frame.setContentPane(this);
237 if (!Platform.isJS())
244 wsPrefs = new WsPreferences();
245 wsTab.add(wsPrefs, BorderLayout.CENTER);
247 int width = 500, height = 450;
248 if (Platform.isAMacAndNotJS())
254 Desktop.addInternalFrame(frame,
255 MessageManager.getString("label.preferences"), width, height);
256 frame.setMinimumSize(new Dimension(width, height));
259 * Set Visual tab defaults
261 seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true));
262 rightAlign.setSelected(Cache.getDefault("RIGHT_ALIGN_IDS", false));
263 fullScreen.setSelected(Cache.getDefault("SHOW_FULLSCREEN", false));
264 annotations.setSelected(Cache.getDefault("SHOW_ANNOTATIONS", true));
266 conservation.setSelected(Cache.getDefault(SHOW_CONSERVATION, true));
267 quality.setSelected(Cache.getDefault(SHOW_QUALITY, true));
268 identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
269 openoverv.setSelected(Cache.getDefault(SHOW_OVERVIEW, false));
271 .setSelected(Cache.getDefault(SHOW_UNCONSERVED, false));
272 showOccupancy.setSelected(Cache.getDefault(SHOW_OCCUPANCY, false));
274 .setSelected(Cache.getDefault(SHOW_GROUP_CONSENSUS, false));
275 showGroupConservation.setSelected(
276 Cache.getDefault(SHOW_GROUP_CONSERVATION, false));
277 showConsensHistogram.setSelected(
278 Cache.getDefault(SHOW_CONSENSUS_HISTOGRAM, true));
280 .setSelected(Cache.getDefault(SHOW_CONSENSUS_LOGO, false));
282 .setSelected(Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true));
284 .setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP", true));
286 String[] fonts = java.awt.GraphicsEnvironment
287 .getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
288 for (int i = 0; i < fonts.length; i++)
290 fontNameCB.addItem(fonts[i]);
293 for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++)
295 fontSizeCB.addItem(i + "");
298 fontStyleCB.addItem("plain");
299 fontStyleCB.addItem("bold");
300 fontStyleCB.addItem("italic");
302 fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif"));
303 fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10"));
304 fontStyleCB.setSelectedItem(
305 Cache.getDefault("FONT_STYLE", Font.PLAIN + ""));
307 smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", false));
309 .setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA, false));
311 idItalics.setSelected(Cache.getDefault("ID_ITALICS", true));
313 wrap.setSelected(Cache.getDefault("WRAP_ALIGNMENT", false));
315 gapSymbolCB.addItem("-");
316 gapSymbolCB.addItem(".");
318 gapSymbolCB.setSelectedItem(Cache.getDefault("GAP_SYMBOL", "-"));
320 sortby.addItem("No sort");
321 sortby.addItem("Id");
322 sortby.addItem("Pairwise Identity");
323 sortby.setSelectedItem(Cache.getDefault(SORT_ALIGNMENT, "No sort"));
325 sortAnnBy.addItem(SequenceAnnotationOrder.NONE.toString());
327 .addItem(SequenceAnnotationOrder.SEQUENCE_AND_LABEL.toString());
329 .addItem(SequenceAnnotationOrder.LABEL_AND_SEQUENCE.toString());
330 SequenceAnnotationOrder savedSort = SequenceAnnotationOrder
331 .valueOf(Cache.getDefault(SORT_ANNOTATIONS,
332 SequenceAnnotationOrder.NONE.name()));
333 sortAnnBy.setSelectedItem(savedSort.toString());
335 sortAutocalc.addItem("Autocalculated first");
336 sortAutocalc.addItem("Autocalculated last");
337 final boolean showAbove = Cache.getDefault(SHOW_AUTOCALC_ABOVE, true);
338 sortAutocalc.setSelectedItem(showAbove ? sortAutocalc.getItemAt(0)
339 : sortAutocalc.getItemAt(1));
341 .setSelected(Cache.getDefault("SHOW_STARTUP_FILE", true));
342 startupFileTextfield.setText(Cache.getDefault("STARTUP_FILE",
343 Cache.getDefault("www.jalview.org", "http://www.jalview.org")
344 + "/examples/exampleFile_2_3.jar"));
347 * Set Colours tab defaults
349 protColour.addItem(ResidueColourScheme.NONE);
350 nucColour.addItem(ResidueColourScheme.NONE);
351 for (ColourSchemeI cs : ColourSchemes.getInstance().getColourSchemes())
353 String name = cs.getSchemeName();
354 protColour.addItem(name);
355 nucColour.addItem(name);
357 String oldProp = Cache.getDefault(DEFAULT_COLOUR,
358 ResidueColourScheme.NONE);
359 String newProp = Cache.getDefault(DEFAULT_COLOUR_PROT, null);
360 protColour.setSelectedItem(newProp != null ? newProp : oldProp);
361 newProp = Cache.getDefault(DEFAULT_COLOUR_NUC, null);
362 nucColour.setSelectedItem(newProp != null ? newProp : oldProp);
363 minColour.setBackground(
364 Cache.getDefaultColour(ANNOTATIONCOLOUR_MIN, Color.orange));
365 maxColour.setBackground(
366 Cache.getDefaultColour(ANNOTATIONCOLOUR_MAX, Color.red));
369 * Set overview panel defaults
371 gapColour.setBackground(
372 Cache.getDefaultColour(GAP_COLOUR,
373 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP));
374 hiddenColour.setBackground(
375 Cache.getDefaultColour(HIDDEN_COLOUR,
376 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_HIDDEN));
377 useLegacyGap.setSelected(Cache.getDefault(USE_LEGACY_GAP, false));
378 gapLabel.setEnabled(!useLegacyGap.isSelected());
379 gapColour.setEnabled(!useLegacyGap.isSelected());
381 .setSelected(Cache.getDefault(SHOW_OV_HIDDEN_AT_START, false));
384 * Set Structure tab defaults.
386 final boolean structSelected = Cache.getDefault(STRUCT_FROM_PDB, false);
387 structFromPdb.setSelected(structSelected);
388 useRnaView.setSelected(Cache.getDefault(USE_RNAVIEW, false));
389 useRnaView.setEnabled(structSelected);
390 addSecondaryStructure.setSelected(Cache.getDefault(ADD_SS_ANN, false));
391 addSecondaryStructure.setEnabled(structSelected);
392 addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, false));
393 addTempFactor.setEnabled(structSelected);
394 structViewer.setSelectedItem(
395 Cache.getDefault(STRUCTURE_DISPLAY, ViewerType.JMOL.name()));
396 chimeraPath.setText(Cache.getDefault(CHIMERA_PATH, ""));
397 chimeraPath.addActionListener(new ActionListener()
400 public void actionPerformed(ActionEvent e)
402 validateChimeraPath();
406 if (Cache.getDefault("MAP_WITH_SIFTS", false))
408 siftsMapping.setSelected(true);
412 nwMapping.setSelected(true);
416 .setMapWithSifts(Cache.getDefault("MAP_WITH_SIFTS", false));
419 * Set Connections tab defaults
423 linkUrlTable.setModel(dataModel);
424 final TableRowSorter<TableModel> sorter = new TableRowSorter<>(
425 linkUrlTable.getModel());
426 linkUrlTable.setRowSorter(sorter);
427 List<RowSorter.SortKey> sortKeys = new ArrayList<>();
429 UrlLinkTableModel m = (UrlLinkTableModel) linkUrlTable.getModel();
430 sortKeys.add(new RowSorter.SortKey(m.getPrimaryColumn(),
431 SortOrder.DESCENDING));
432 sortKeys.add(new RowSorter.SortKey(m.getSelectedColumn(),
433 SortOrder.DESCENDING));
435 new RowSorter.SortKey(m.getNameColumn(), SortOrder.ASCENDING));
437 sorter.setSortKeys(sortKeys);
438 // BH 2018 setSortKeys will do the sort
442 ActionListener onReset;
443 onReset = new ActionListener()
446 public void actionPerformed(ActionEvent e)
448 filterTB.setText("");
449 sorter.setRowFilter(RowFilter.regexFilter(""));
453 doReset.addActionListener(onReset);
455 // filter to display only custom urls
456 final RowFilter<TableModel, Object> customUrlFilter = new RowFilter<TableModel, Object>()
459 public boolean include(
460 Entry<? extends TableModel, ? extends Object> entry)
462 return ((UrlLinkTableModel) entry.getModel()).isUserEntry(entry);
466 final TableRowSorter<TableModel> customSorter = new TableRowSorter<>(
467 linkUrlTable.getModel());
468 customSorter.setRowFilter(customUrlFilter);
470 ActionListener onCustomOnly;
471 onCustomOnly = new ActionListener()
474 public void actionPerformed(ActionEvent e)
476 filterTB.setText("");
477 sorter.setRowFilter(customUrlFilter);
480 userOnly.addActionListener(onCustomOnly);
482 filterTB.getDocument().addDocumentListener(new DocumentListener()
484 String caseInsensitiveFlag = "(?i)";
487 public void changedUpdate(DocumentEvent e)
489 sorter.setRowFilter(RowFilter
490 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
494 public void removeUpdate(DocumentEvent e)
496 sorter.setRowFilter(RowFilter
497 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
501 public void insertUpdate(DocumentEvent e)
503 sorter.setRowFilter(RowFilter
504 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
508 // set up list selection functionality
509 linkUrlTable.getSelectionModel()
510 .addListSelectionListener(new UrlListSelectionHandler());
512 // set up radio buttons
513 int onClickCol = ((UrlLinkTableModel) linkUrlTable.getModel())
515 String onClickName = linkUrlTable.getColumnName(onClickCol);
516 linkUrlTable.getColumn(onClickName)
517 .setCellRenderer(new RadioButtonRenderer());
518 linkUrlTable.getColumn(onClickName)
519 .setCellEditor(new RadioButtonEditor());
521 // get boolean columns and resize those to min possible
522 for (int column = 0; column < linkUrlTable.getColumnCount(); column++)
524 if (linkUrlTable.getModel().getColumnClass(column)
525 .equals(Boolean.class))
527 TableColumn tableColumn = linkUrlTable.getColumnModel()
529 int preferredWidth = tableColumn.getMinWidth();
531 TableCellRenderer cellRenderer = linkUrlTable.getCellRenderer(0,
533 Component c = linkUrlTable.prepareRenderer(cellRenderer, 0, column);
534 int cwidth = c.getPreferredSize().width
535 + linkUrlTable.getIntercellSpacing().width;
536 preferredWidth = Math.max(preferredWidth, cwidth);
538 tableColumn.setPreferredWidth(preferredWidth);
542 useProxy.setSelected(Cache.getDefault("USE_PROXY", false));
543 useProxy_actionPerformed(); // make sure useProxy is correctly initialised
544 proxyServerTB.setText(Cache.getDefault("PROXY_SERVER", ""));
545 proxyPortTB.setText(Cache.getDefault("PROXY_PORT", ""));
547 defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
549 usagestats.setSelected(Cache.getDefault("USAGESTATS", false));
550 // note antisense here: default is true
552 .setSelected(Cache.getProperty(NOQUESTIONNAIRES) == null);
553 versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true));
556 * Set Output tab defaults
558 setupOutputCombo(epsRendering, "EPS_RENDERING");
559 setupOutputCombo(htmlRendering, "HTML_RENDERING");
560 setupOutputCombo(svgRendering, "SVG_RENDERING");
561 autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
562 userIdWidth.setEnabled(!autoIdWidth.isSelected());
563 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
564 Integer wi = Cache.getIntegerProperty("FIGURE_FIXEDIDWIDTH");
565 userIdWidth.setText(wi == null ? "" : wi.toString());
566 // TODO: refactor to use common enum via FormatAdapter and allow extension
567 // for new flat file formats
568 blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
569 clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
570 fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
571 msfjv.setSelected(Cache.getDefault("MSF_JVSUFFIX", true));
572 pfamjv.setSelected(Cache.getDefault("PFAM_JVSUFFIX", true));
573 pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true));
574 pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true));
575 modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false));
577 .setSelected(Cache.getDefault("EXPORT_EMBBED_BIOJSON", true));
580 * Set Editing tab defaults
582 autoCalculateConsCheck
583 .setSelected(Cache.getDefault("AUTO_CALC_CONSENSUS", true));
584 padGaps.setSelected(Cache.getDefault("PAD_GAPS", false));
585 sortByTree.setSelected(Cache.getDefault(SORT_BY_TREE, false));
587 annotations_actionPerformed(null); // update the display of the annotation
592 * Set Backups tab defaults
594 loadLastSavedBackupsOptions();
598 * A helper method that sets the items and initial selection in a character
599 * rendering option list (Prompt each time/Lineart/Text)
604 protected void setupOutputCombo(JComboBox<Object> comboBox,
607 comboBox.addItem(promptEachTimeOpt);
608 comboBox.addItem(lineArtOpt);
609 comboBox.addItem(textOpt);
612 * JalviewJS doesn't support Lineart so force it to Text
614 String defaultOption = Platform.isJS() ? "Text"
615 : Cache.getDefault(propertyKey, "Prompt each time");
616 if (defaultOption.equalsIgnoreCase("Text"))
618 comboBox.setSelectedItem(textOpt);
620 else if (defaultOption.equalsIgnoreCase("Lineart"))
622 comboBox.setSelectedItem(lineArtOpt);
626 comboBox.setSelectedItem(promptEachTimeOpt);
631 * Save user selections on the Preferences tabs to the Cache and write out to
637 public void ok_actionPerformed(ActionEvent e)
639 if (!validateSettings())
645 * Save Visual settings
647 Cache.setPropertyNoSave("SHOW_JVSUFFIX",
648 Boolean.toString(seqLimit.isSelected()));
649 Cache.setPropertyNoSave("RIGHT_ALIGN_IDS",
650 Boolean.toString(rightAlign.isSelected()));
651 Cache.setPropertyNoSave("SHOW_FULLSCREEN",
652 Boolean.toString(fullScreen.isSelected()));
653 Cache.setPropertyNoSave("SHOW_OVERVIEW",
654 Boolean.toString(openoverv.isSelected()));
655 Cache.setPropertyNoSave("SHOW_ANNOTATIONS",
656 Boolean.toString(annotations.isSelected()));
657 Cache.setPropertyNoSave(SHOW_CONSERVATION,
658 Boolean.toString(conservation.isSelected()));
659 Cache.setPropertyNoSave(SHOW_QUALITY,
660 Boolean.toString(quality.isSelected()));
661 Cache.setPropertyNoSave("SHOW_IDENTITY",
662 Boolean.toString(identity.isSelected()));
664 Cache.setPropertyNoSave("GAP_SYMBOL",
665 gapSymbolCB.getSelectedItem().toString());
667 Cache.setPropertyNoSave("FONT_NAME",
668 fontNameCB.getSelectedItem().toString());
669 Cache.setPropertyNoSave("FONT_STYLE",
670 fontStyleCB.getSelectedItem().toString());
671 Cache.setPropertyNoSave("FONT_SIZE",
672 fontSizeCB.getSelectedItem().toString());
674 Cache.setPropertyNoSave("ID_ITALICS",
675 Boolean.toString(idItalics.isSelected()));
676 Cache.setPropertyNoSave("SHOW_UNCONSERVED",
677 Boolean.toString(showUnconserved.isSelected()));
678 Cache.setPropertyNoSave(SHOW_OCCUPANCY,
679 Boolean.toString(showOccupancy.isSelected()));
680 Cache.setPropertyNoSave(SHOW_GROUP_CONSENSUS,
681 Boolean.toString(showGroupConsensus.isSelected()));
682 Cache.setPropertyNoSave(SHOW_GROUP_CONSERVATION,
683 Boolean.toString(showGroupConservation.isSelected()));
684 Cache.setPropertyNoSave(SHOW_CONSENSUS_HISTOGRAM,
685 Boolean.toString(showConsensHistogram.isSelected()));
686 Cache.setPropertyNoSave(SHOW_CONSENSUS_LOGO,
687 Boolean.toString(showConsensLogo.isSelected()));
688 Cache.setPropertyNoSave("ANTI_ALIAS",
689 Boolean.toString(smoothFont.isSelected()));
690 Cache.setPropertyNoSave(SCALE_PROTEIN_TO_CDNA,
691 Boolean.toString(scaleProteinToCdna.isSelected()));
692 Cache.setPropertyNoSave("SHOW_NPFEATS_TOOLTIP",
693 Boolean.toString(showNpTooltip.isSelected()));
694 Cache.setPropertyNoSave("SHOW_DBREFS_TOOLTIP",
695 Boolean.toString(showDbRefTooltip.isSelected()));
697 Cache.setPropertyNoSave("WRAP_ALIGNMENT",
698 Boolean.toString(wrap.isSelected()));
700 Cache.setPropertyNoSave("STARTUP_FILE",
701 startupFileTextfield.getText());
702 Cache.setPropertyNoSave("SHOW_STARTUP_FILE",
703 Boolean.toString(startupCheckbox.isSelected()));
705 Cache.setPropertyNoSave(SORT_ALIGNMENT,
706 sortby.getSelectedItem().toString());
708 // convert description of sort order to enum name for save
709 SequenceAnnotationOrder annSortOrder = SequenceAnnotationOrder
710 .forDescription(sortAnnBy.getSelectedItem().toString());
711 if (annSortOrder != null)
713 Cache.setPropertyNoSave(SORT_ANNOTATIONS,
714 annSortOrder.name());
717 final boolean showAutocalcFirst = sortAutocalc.getSelectedIndex() == 0;
718 Cache.setPropertyNoSave(SHOW_AUTOCALC_ABOVE,
719 Boolean.valueOf(showAutocalcFirst).toString());
722 * Save Colours settings
724 Cache.setPropertyNoSave(DEFAULT_COLOUR_PROT,
725 protColour.getSelectedItem().toString());
726 Cache.setPropertyNoSave(DEFAULT_COLOUR_NUC,
727 nucColour.getSelectedItem().toString());
728 Cache.setColourProperty(ANNOTATIONCOLOUR_MIN,
729 minColour.getBackground());
730 Cache.setColourProperty(ANNOTATIONCOLOUR_MAX,
731 maxColour.getBackground());
734 * Save Overview settings
736 Cache.setColourProperty(GAP_COLOUR, gapColour.getBackground());
737 Cache.setColourProperty(HIDDEN_COLOUR, hiddenColour.getBackground());
738 Cache.setPropertyNoSave(USE_LEGACY_GAP,
739 Boolean.toString(useLegacyGap.isSelected()));
740 Cache.setPropertyNoSave(SHOW_OV_HIDDEN_AT_START,
741 Boolean.toString(showHiddenAtStart.isSelected()));
744 * Save Structure settings
746 Cache.setPropertyNoSave(ADD_TEMPFACT_ANN,
747 Boolean.toString(addTempFactor.isSelected()));
748 Cache.setPropertyNoSave(ADD_SS_ANN,
749 Boolean.toString(addSecondaryStructure.isSelected()));
750 Cache.setPropertyNoSave(USE_RNAVIEW,
751 Boolean.toString(useRnaView.isSelected()));
752 Cache.setPropertyNoSave(STRUCT_FROM_PDB,
753 Boolean.toString(structFromPdb.isSelected()));
754 Cache.setPropertyNoSave(STRUCTURE_DISPLAY,
755 structViewer.getSelectedItem().toString());
756 Cache.setOrRemove(CHIMERA_PATH, chimeraPath.getText());
757 Cache.setPropertyNoSave("MAP_WITH_SIFTS",
758 Boolean.toString(siftsMapping.isSelected()));
759 SiftsSettings.setMapWithSifts(siftsMapping.isSelected());
762 * Save Output settings
764 Cache.setPropertyNoSave("EPS_RENDERING",
765 ((OptionsParam) epsRendering.getSelectedItem()).getCode());
766 Cache.setPropertyNoSave("HTML_RENDERING",
767 ((OptionsParam) htmlRendering.getSelectedItem()).getCode());
768 Cache.setPropertyNoSave("SVG_RENDERING",
769 ((OptionsParam) svgRendering.getSelectedItem()).getCode());
771 if (!Platform.isJS())
777 // Save Connections settings
778 Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
779 BrowserLauncher.resetBrowser();
782 // save user-defined and selected links
783 String menuLinks = sequenceUrlLinks.writeUrlsAsString(true);
784 if (menuLinks.isEmpty())
786 Cache.removePropertyNoSave("SEQUENCE_LINKS");
790 Cache.setPropertyNoSave("SEQUENCE_LINKS",
791 menuLinks.toString());
794 String nonMenuLinks = sequenceUrlLinks.writeUrlsAsString(false);
795 if (nonMenuLinks.isEmpty())
797 Cache.removePropertyNoSave("STORED_LINKS");
801 Cache.setPropertyNoSave("STORED_LINKS",
802 nonMenuLinks.toString());
805 Cache.setPropertyNoSave("DEFAULT_URL",
806 sequenceUrlLinks.getPrimaryUrlId());
808 Cache.setPropertyNoSave("USE_PROXY",
809 Boolean.toString(useProxy.isSelected()));
811 Cache.setOrRemove("PROXY_SERVER", proxyServerTB.getText());
813 Cache.setOrRemove("PROXY_PORT", proxyPortTB.getText());
815 if (useProxy.isSelected())
817 System.setProperty("http.proxyHost", proxyServerTB.getText());
818 System.setProperty("http.proxyPort", proxyPortTB.getText());
822 System.setProperty("http.proxyHost", "");
823 System.setProperty("http.proxyPort", "");
825 Cache.setProperty("VERSION_CHECK",
826 Boolean.toString(versioncheck.isSelected()));
827 if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
829 // default is false - we only set this if the user has actively agreed
830 Cache.setProperty("USAGESTATS",
831 Boolean.toString(usagestats.isSelected()));
833 if (!questionnaire.isSelected())
835 Cache.setProperty(NOQUESTIONNAIRES, "true");
839 // special - made easy to edit a property file to disable questionnaires
840 // by just adding the given line
841 Cache.removeProperty(NOQUESTIONNAIRES);
845 * Save Output settings
847 Cache.setPropertyNoSave("BLC_JVSUFFIX",
848 Boolean.toString(blcjv.isSelected()));
849 Cache.setPropertyNoSave("CLUSTAL_JVSUFFIX",
850 Boolean.toString(clustaljv.isSelected()));
851 Cache.setPropertyNoSave("FASTA_JVSUFFIX",
852 Boolean.toString(fastajv.isSelected()));
853 Cache.setPropertyNoSave("MSF_JVSUFFIX",
854 Boolean.toString(msfjv.isSelected()));
855 Cache.setPropertyNoSave("PFAM_JVSUFFIX",
856 Boolean.toString(pfamjv.isSelected()));
857 Cache.setPropertyNoSave("PILEUP_JVSUFFIX",
858 Boolean.toString(pileupjv.isSelected()));
859 Cache.setPropertyNoSave("PIR_JVSUFFIX",
860 Boolean.toString(pirjv.isSelected()));
861 Cache.setPropertyNoSave("PIR_MODELLER",
862 Boolean.toString(modellerOutput.isSelected()));
863 Cache.setPropertyNoSave("EXPORT_EMBBED_BIOJSON",
864 Boolean.toString(embbedBioJSON.isSelected()));
865 Cache.setPropertyNoSave("FIGURE_AUTOIDWIDTH",
866 Boolean.toString(autoIdWidth.isSelected()));
867 userIdWidth_actionPerformed();
868 Cache.setPropertyNoSave("FIGURE_FIXEDIDWIDTH",
869 userIdWidth.getText());
872 * Save Editing settings
874 Cache.setPropertyNoSave("AUTO_CALC_CONSENSUS",
875 Boolean.toString(autoCalculateConsCheck.isSelected()));
876 Cache.setPropertyNoSave("SORT_BY_TREE",
877 Boolean.toString(sortByTree.isSelected()));
878 Cache.setPropertyNoSave("PAD_GAPS",
879 Boolean.toString(padGaps.isSelected()));
881 if (!Platform.isJS())
883 wsPrefs.updateAndRefreshWsMenuConfig(false);
887 * Save Backups settings
889 Cache.setPropertyNoSave(BackupFiles.CONFIRM_DELETE_OLD,
890 Boolean.toString(backupfilesConfirmDelete.isSelected()));
891 Cache.setPropertyNoSave(BackupFiles.ENABLED,
892 Boolean.toString(enableBackupFiles.isSelected()));
893 Cache.setPropertyNoSave(BackupFiles.NO_MAX,
894 Boolean.toString(backupfilesKeepAll.isSelected()));
895 Cache.setPropertyNoSave(BackupFiles.REVERSE_ORDER,
896 Boolean.toString(suffixReverse.isSelected()));
897 Cache.setPropertyNoSave(BackupFiles.SUFFIX,
898 suffixTemplate.getText());
899 Cache.setPropertyNoSave(BackupFiles.ROLL_MAX,
900 Integer.toString(getSpinnerInt(backupfilesRollMaxSpinner, 4)));
901 Cache.setPropertyNoSave(BackupFiles.SUFFIX_DIGITS,
902 Integer.toString(getSpinnerInt(suffixDigitsSpinner, 3)));
903 Cache.setPropertyNoSave(BackupFiles.NS + "_PRESET",
904 Integer.toString(getComboIntStringKey(backupfilesPresetsCombo)));
906 Cache.saveProperties();
907 Desktop.getInstance().doConfigureStructurePrefs();
910 frame.setClosed(true);
911 } catch (Exception ex)
916 public static void setAppletDefaults()
919 // http://www.jalview.org/old/v2_8/examples/appletParameters.html
921 // showConservation true or false Default is true.
922 // showQuality true or false Default is true.
923 // showConsensus true or false Default is true.
924 // showFeatureSettings true or false Shows the feature settings window when
926 // showTreeBootstraps true or false (default is true) show or hide branch
928 // showTreeDistances true or false (default is true) show or hide branch
930 // showUnlinkedTreeNodes true or false (default is false) indicate if
931 // unassociated nodes should be highlighted in the tree view
932 // showUnconserved true of false (default is false) When true, only gaps and
933 // symbols different to the consensus sequence ions of the alignment
934 // showGroupConsensus true of false (default is false) When true, shows
935 // consensus annotation row for any groups on the alignment. (since 2.7)
936 // showGroupConservation true of false (default is false) When true, shows
937 // amino-acid property conservation annotation row for any groups on the
938 // showConsensusHistogram true of false (default is true) When true, shows
939 // the percentage occurence of the consensus symbol for each column as a
940 // showSequenceLogo true of false (default is false) When true, shows a
941 // sequence logo above the consensus sequence (overlaid above the Consensus
943 Cache.setPropertyNoSave(SHOW_CONSERVATION, "true");
944 Cache.setPropertyNoSave(SHOW_QUALITY, "false");
945 Cache.setPropertyNoSave(SHOW_CONSENSUS, "true");
946 Cache.setPropertyNoSave("SHOW_UNCONSERVED", "false");
947 Cache.setPropertyNoSave("SHOW_GROUP_CONSERVATION", "false");
948 Cache.setPropertyNoSave("SHOW_GROUP_CONCENSUS", "false");
950 // TODO -- just a start here
954 * Do any necessary validation before saving settings. Return focus to the
955 * first tab which fails validation.
959 private boolean validateSettings()
961 if (!validateStructure())
963 structureTab.requestFocusInWindow();
970 protected boolean validateStructure()
972 return validateChimeraPath();
980 public void startupFileTextfield_mouseClicked()
982 // TODO: JAL-3048 not needed for Jalview-JS
983 String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
984 JalviewFileChooser chooser = JalviewFileChooser
985 .forRead(Cache.getProperty("LAST_DIRECTORY"), fileFormat);
986 chooser.setFileView(new JalviewFileView());
987 chooser.setDialogTitle(
988 MessageManager.getString("label.select_startup_file"));
990 int value = chooser.showOpenDialog(this);
992 if (value == JalviewFileChooser.APPROVE_OPTION)
994 FileFormatI format = chooser.getSelectedFormat();
997 Cache.setPropertyNoSave("DEFAULT_FILE_FORMAT",
1000 startupFileTextfield
1001 .setText(chooser.getSelectedFile().getAbsolutePath());
1012 public void cancel_actionPerformed(ActionEvent e)
1016 if (!Platform.isJS())
1018 wsPrefs.updateWsMenuConfig(true);
1019 wsPrefs.refreshWs_actionPerformed(e);
1021 frame.setClosed(true);
1022 } catch (Exception ex)
1034 public void annotations_actionPerformed(ActionEvent e)
1036 conservation.setEnabled(annotations.isSelected());
1037 quality.setEnabled(annotations.isSelected());
1038 identity.setEnabled(annotations.isSelected());
1039 showOccupancy.setEnabled(annotations.isSelected());
1040 showGroupConsensus.setEnabled(annotations.isSelected());
1041 showGroupConservation.setEnabled(annotations.isSelected());
1042 showConsensHistogram.setEnabled(annotations.isSelected()
1043 && (identity.isSelected() || showGroupConsensus.isSelected()));
1044 showConsensLogo.setEnabled(annotations.isSelected()
1045 && (identity.isSelected() || showGroupConsensus.isSelected()));
1049 public void newLink_actionPerformed(ActionEvent e)
1051 GSequenceLink link = new GSequenceLink();
1052 boolean valid = false;
1055 if (JvOptionPane.showInternalConfirmDialog(Desktop.getDesktopPane(), link,
1056 MessageManager.getString("label.new_sequence_url_link"),
1057 JvOptionPane.OK_CANCEL_OPTION, -1,
1058 null) == JvOptionPane.OK_OPTION)
1060 if (link.checkValid())
1062 if (((UrlLinkTableModel) linkUrlTable.getModel())
1063 .isUniqueName(link.getName()))
1065 ((UrlLinkTableModel) linkUrlTable.getModel())
1066 .insertRow(link.getName(), link.getURL());
1071 link.notifyDuplicate();
1084 public void editLink_actionPerformed(ActionEvent e)
1086 GSequenceLink link = new GSequenceLink();
1088 int index = linkUrlTable.getSelectedRow();
1091 // button no longer enabled if row is not selected
1092 Cache.log.debug("Edit with no row selected in linkUrlTable");
1096 int nameCol = ((UrlLinkTableModel) linkUrlTable.getModel())
1098 int urlCol = ((UrlLinkTableModel) linkUrlTable.getModel())
1100 String oldName = linkUrlTable.getValueAt(index, nameCol).toString();
1101 link.setName(oldName);
1102 link.setURL(linkUrlTable.getValueAt(index, urlCol).toString());
1104 boolean valid = false;
1107 if (JvOptionPane.showInternalConfirmDialog(Desktop.getDesktopPane(), link,
1108 MessageManager.getString("label.edit_sequence_url_link"),
1109 JvOptionPane.OK_CANCEL_OPTION, -1,
1110 null) == JvOptionPane.OK_OPTION)
1112 if (link.checkValid())
1114 if ((oldName.equals(link.getName()))
1115 || (((UrlLinkTableModel) linkUrlTable.getModel())
1116 .isUniqueName(link.getName())))
1118 linkUrlTable.setValueAt(link.getName(), index, nameCol);
1119 linkUrlTable.setValueAt(link.getURL(), index, urlCol);
1124 link.notifyDuplicate();
1137 public void deleteLink_actionPerformed(ActionEvent e)
1139 int index = linkUrlTable.getSelectedRow();
1140 int modelIndex = -1;
1143 // button no longer enabled if row is not selected
1144 Cache.log.debug("Delete with no row selected in linkUrlTable");
1149 modelIndex = linkUrlTable.convertRowIndexToModel(index);
1152 // make sure we use the model index to delete, and not the table index
1153 ((UrlLinkTableModel) linkUrlTable.getModel()).removeRow(modelIndex);
1157 public void defaultBrowser_mouseClicked(MouseEvent e)
1159 // TODO: JAL-3048 not needed for j2s
1160 if (!Platform.isJS()) // BH 2019
1167 JFileChooser chooser = new JFileChooser(".");
1168 chooser.setDialogTitle(
1169 MessageManager.getString("label.select_default_browser"));
1171 int value = chooser.showOpenDialog(this);
1173 if (value == JFileChooser.APPROVE_OPTION)
1175 defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath());
1184 * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event
1188 protected void showunconserved_actionPerformed(ActionEvent e)
1190 // TODO Auto-generated method stub
1191 super.showunconserved_actionPerformed(e);
1195 * not implemented -- returns empty list
1199 public static List<String> getGroupURLLinks()
1201 return groupURLLinks;
1205 public void minColour_actionPerformed(JPanel panel)
1207 JalviewColourChooser.showColourChooser(this,
1208 MessageManager.getString("label.select_colour_minimum_value"),
1213 public void maxColour_actionPerformed(JPanel panel)
1215 JalviewColourChooser.showColourChooser(this,
1216 MessageManager.getString("label.select_colour_maximum_value"),
1221 public void gapColour_actionPerformed(JPanel gap)
1223 if (!useLegacyGap.isSelected())
1225 JalviewColourChooser.showColourChooser(this,
1226 MessageManager.getString("label.select_gap_colour"),
1232 public void hiddenColour_actionPerformed(JPanel hidden)
1234 JalviewColourChooser.showColourChooser(this,
1235 MessageManager.getString("label.select_hidden_colour"),
1240 protected void useLegacyGaps_actionPerformed(ActionEvent e)
1242 boolean enabled = useLegacyGap.isSelected();
1245 gapColour.setBackground(
1246 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_LEGACY_GAP);
1250 gapColour.setBackground(
1251 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP);
1253 gapColour.setEnabled(!enabled);
1254 gapLabel.setEnabled(!enabled);
1258 protected void resetOvDefaults_actionPerformed(ActionEvent e)
1260 useLegacyGap.setSelected(false);
1261 useLegacyGaps_actionPerformed(null);
1262 showHiddenAtStart.setSelected(false);
1263 hiddenColour.setBackground(
1264 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_HIDDEN);
1268 protected void userIdWidth_actionPerformed()
1272 String val = userIdWidth.getText().trim();
1273 if (val.length() > 0)
1275 Integer iw = Integer.parseInt(val);
1276 if (iw.intValue() < 12)
1278 throw new NumberFormatException();
1280 userIdWidth.setText(iw.toString());
1282 } catch (NumberFormatException x)
1284 userIdWidth.setText("");
1285 JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
1287 .getString("warn.user_defined_width_requirements"),
1288 MessageManager.getString("label.invalid_id_column_width"),
1289 JvOptionPane.WARNING_MESSAGE);
1294 protected void autoIdWidth_actionPerformed()
1296 userIdWidth.setEnabled(!autoIdWidth.isSelected());
1297 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
1301 * Returns true if chimera path is to a valid executable, else show an error
1304 protected boolean validateChimeraPath()
1306 if (chimeraPath.getText().trim().length() > 0)
1308 File f = new File(chimeraPath.getText());
1309 if (!f.canExecute())
1311 JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
1312 MessageManager.getString("label.invalid_chimera_path"),
1313 MessageManager.getString("label.invalid_name"),
1314 JvOptionPane.ERROR_MESSAGE);
1322 * If Chimera is selected, check it can be found on default or user-specified
1323 * path, if not show a warning/help dialog.
1326 protected void structureViewer_actionPerformed(String selectedItem)
1328 if (!selectedItem.equals(ViewerType.CHIMERA.name()))
1332 boolean found = false;
1335 * Try user-specified and standard paths for Chimera executable.
1337 List<String> paths = StructureManager.getChimeraPaths();
1338 paths.add(0, chimeraPath.getText());
1339 for (String path : paths)
1341 if (new File(path.trim()).canExecute())
1349 String[] options = { "OK", "Help" };
1350 int showHelp = JvOptionPane.showInternalOptionDialog(Desktop.getDesktopPane(),
1351 JvSwingUtils.wrapTooltip(true,
1352 MessageManager.getString("label.chimera_missing")),
1353 "", JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE,
1354 null, options, options[0]);
1355 if (showHelp == JvOptionPane.NO_OPTION)
1359 Help.showHelpWindow(HelpId.StructureViewer);
1360 } catch (HelpSetException e)
1362 e.printStackTrace();
1368 public class OptionsParam
1370 private String name;
1372 private String code;
1374 public OptionsParam(String name, String code)
1380 public String getName()
1385 public void setName(String name)
1390 public String getCode()
1395 public void setCode(String code)
1401 public String toString()
1407 public boolean equals(Object that)
1409 if (!(that instanceof OptionsParam))
1413 return this.code.equalsIgnoreCase(((OptionsParam) that).code);
1417 public int hashCode()
1419 return name.hashCode() + code.hashCode();
1423 protected class UrlListSelectionHandler implements ListSelectionListener
1427 public void valueChanged(ListSelectionEvent e)
1429 ListSelectionModel lsm = (ListSelectionModel) e.getSource();
1431 int index = lsm.getMinSelectionIndex();
1434 // no selection, so disable delete/edit buttons
1435 editLink.setEnabled(false);
1436 deleteLink.setEnabled(false);
1439 int modelIndex = linkUrlTable.convertRowIndexToModel(index);
1441 // enable/disable edit and delete link buttons
1442 if (((UrlLinkTableModel) linkUrlTable.getModel())
1443 .isRowDeletable(modelIndex))
1445 deleteLink.setEnabled(true);
1449 deleteLink.setEnabled(false);
1452 if (((UrlLinkTableModel) linkUrlTable.getModel())
1453 .isRowEditable(modelIndex))
1455 editLink.setEnabled(true);
1459 editLink.setEnabled(false);