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;
31 import java.util.ArrayList;
32 import java.util.List;
33 import java.util.concurrent.CompletableFuture;
35 import javax.help.HelpSetException;
36 import javax.swing.JComboBox;
37 import javax.swing.JInternalFrame;
38 import javax.swing.JPanel;
39 import javax.swing.ListSelectionModel;
40 import javax.swing.RowFilter;
41 import javax.swing.RowSorter;
42 import javax.swing.SortOrder;
43 import javax.swing.event.DocumentEvent;
44 import javax.swing.event.DocumentListener;
45 import javax.swing.event.ListSelectionEvent;
46 import javax.swing.event.ListSelectionListener;
47 import javax.swing.table.TableCellRenderer;
48 import javax.swing.table.TableColumn;
49 import javax.swing.table.TableModel;
50 import javax.swing.table.TableRowSorter;
52 //import edu.stanford.ejalbert.launching.IBrowserLaunching;
53 import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
54 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
55 import jalview.bin.Cache;
56 import jalview.bin.Console;
57 import jalview.bin.MemorySetting;
58 import jalview.ext.pymol.PymolManager;
59 import jalview.gui.Help.HelpId;
60 import jalview.gui.StructureViewer.ViewerType;
61 import jalview.io.BackupFiles;
62 import jalview.io.BackupFilesPresetEntry;
63 import jalview.io.FileFormatI;
64 import jalview.io.JalviewFileChooser;
65 import jalview.io.JalviewFileView;
66 import jalview.jbgui.GPreferences;
67 import jalview.jbgui.GSequenceLink;
68 import jalview.schemes.ColourSchemeI;
69 import jalview.schemes.ColourSchemes;
70 import jalview.schemes.ResidueColourScheme;
71 import jalview.urls.UrlLinkTableModel;
72 import jalview.urls.api.UrlProviderFactoryI;
73 import jalview.urls.api.UrlProviderI;
74 import jalview.urls.desktop.DesktopUrlProviderFactory;
75 import jalview.util.MessageManager;
76 import jalview.util.Platform;
77 import jalview.util.UrlConstants;
78 import jalview.ws.sifts.SiftsSettings;
87 * for merge with Jalview-JS
88 public class Preferences extends GPreferences implements ApplicationSingletonI
90 public class Preferences extends GPreferences
92 public static final String ENABLE_SPLIT_FRAME = "ENABLE_SPLIT_FRAME";
94 public static final String SCALE_PROTEIN_TO_CDNA = "SCALE_PROTEIN_TO_CDNA";
96 public static final String DEFAULT_COLOUR = "DEFAULT_COLOUR";
98 public static final String DEFAULT_COLOUR_PROT = "DEFAULT_COLOUR_PROT";
100 public static final String DEFAULT_COLOUR_NUC = "DEFAULT_COLOUR_NUC";
102 public static final String ADD_TEMPFACT_ANN = "ADD_TEMPFACT_ANN";
104 public static final String ADD_SS_ANN = "ADD_SS_ANN";
106 public static final String USE_RNAVIEW = "USE_RNAVIEW";
108 public static final String STRUCT_FROM_PDB = "STRUCT_FROM_PDB";
110 public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY";
112 public static final String CHIMERA_PATH = "CHIMERA_PATH";
114 public static final String CHIMERAX_PATH = "CHIMERAX_PATH";
116 public static final String PYMOL_PATH = "PYMOL_PATH";
118 public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS";
120 public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE";
122 public static final String SHOW_OCCUPANCY = "SHOW_OCCUPANCY";
124 public static final String SHOW_OV_HIDDEN_AT_START = "SHOW_OV_HIDDEN_AT_START";
126 public static final String USE_LEGACY_GAP = "USE_LEGACY_GAP";
128 public static final String GAP_COLOUR = "GAP_COLOUR";
130 public static final String HIDDEN_COLOUR = "HIDDEN_COLOUR";
132 private static final int MIN_FONT_SIZE = 1;
134 private static final int MAX_FONT_SIZE = 30;
136 private String previousProxyType;
138 private static Preferences INSTANCE = null; // add "final"
141 * Holds name and link separated with | character. Sequence ID must be
142 * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$
144 public static UrlProviderI sequenceUrlLinks;
146 public static UrlLinkTableModel dataModel;
149 * Holds name and link separated with | character. Sequence IDS and Sequences
150 * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and
151 * $SEQUENCES$ or $SEQUENCES=/.possible | chars ./=$ and separation character
152 * for first and second token specified after a pipe character at end |,|.
153 * (TODO: proper escape for using | to separate ids or sequences
156 public static List<String> groupURLLinks;
159 // don't populate with session properties
160 Cache.disableSessionProperties();
162 // get links selected to be in the menu (SEQUENCE_LINKS)
163 // and links entered by the user but not selected (STORED_LINKS)
164 String inMenuString = Cache.getDefault("SEQUENCE_LINKS", "");
165 String notInMenuString = Cache.getDefault("STORED_LINKS", "");
166 String defaultUrl = Cache.getDefault("DEFAULT_URL",
167 UrlConstants.DEFAULT_LABEL);
169 // if both links lists are empty, add the DEFAULT_URL link
170 // otherwise we assume the default link is in one of the lists
171 if (inMenuString.isEmpty() && notInMenuString.isEmpty())
173 inMenuString = UrlConstants.DEFAULT_STRING;
175 UrlProviderFactoryI factory = new DesktopUrlProviderFactory(defaultUrl,
176 inMenuString, notInMenuString);
177 sequenceUrlLinks = factory.createUrlProvider();
178 dataModel = new UrlLinkTableModel(sequenceUrlLinks);
181 * TODO: reformulate groupURL encoding so two or more can be stored in the
182 * .properties file as '|' separated strings
185 groupURLLinks = new ArrayList<>();
188 Cache.enableSessionProperties();
191 JInternalFrame frame;
193 private WsPreferences wsPrefs;
195 private OptionsParam promptEachTimeOpt = new OptionsParam(
196 MessageManager.getString("label.prompt_each_time"),
197 LineartOptions.PROMPT_EACH_TIME);
199 private OptionsParam lineArtOpt = new OptionsParam(
200 MessageManager.getString("label.lineart"), "Lineart");
202 private OptionsParam textOpt = new OptionsParam(
203 MessageManager.getString("action.text"), "Text");
205 // get singleton Preferences instance
206 public static Preferences getInstance()
208 if (INSTANCE == null || INSTANCE.frame == null
209 || INSTANCE.frame.isClosed())
211 INSTANCE = new Preferences();
216 * Replace code with the following for Jalvew-JS
217 Preferences INSTANCE = ApplicationSingletonProvider.getInstance(Preferences.class);
218 if (INSTANCE == null || INSTANCE.frame == null
219 || INSTANCE.frame.isClosed())
221 ApplicationSingletonProvider.remove(Preferences.class);
222 INSTANCE = ApplicationSingletonProvider.getInstance(Preferences.class);
228 public static void openPreferences()
230 openPreferences(null, null);
233 public static void openPreferences(TabRef selectTab, String message)
235 Preferences p = getInstance();
236 if (selectTab != null)
237 p.selectTab(selectTab, message);
239 p.frame.moveToFront();
243 public void selectTab(TabRef selectTab, String message)
245 this.selectTab(selectTab);
247 this.setMessage(message);
252 * Creates a new Preferences object.
254 private Preferences()
257 // don't populate with session properties
258 Cache.disableSessionProperties();
260 frame = new JInternalFrame();
261 frame.setFrameIcon(null);
262 frame.setContentPane(this);
263 if (!Platform.isJS())
270 wsPrefs = new WsPreferences();
271 wsTab.add(wsPrefs, BorderLayout.CENTER);
273 int width = 500, height = 450;
274 if (Platform.isAMacAndNotJS())
280 Desktop.addInternalFrame(frame,
281 MessageManager.getString("label.preferences"), width, height);
282 frame.setMinimumSize(new Dimension(width, height));
285 * Set Visual tab defaults
287 seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true));
288 rightAlign.setSelected(Cache.getDefault("RIGHT_ALIGN_IDS", false));
289 fullScreen.setSelected(Cache.getDefault("SHOW_FULLSCREEN", false));
290 annotations.setSelected(Cache.getDefault("SHOW_ANNOTATIONS", true));
292 conservation.setSelected(Cache.getDefault("SHOW_CONSERVATION", true));
293 quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));
294 identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
295 openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false));
297 .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
298 showOccupancy.setSelected(Cache.getDefault(SHOW_OCCUPANCY, false));
300 .setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS", false));
301 showGroupConservation.setSelected(
302 Cache.getDefault("SHOW_GROUP_CONSERVATION", false));
303 showConsensHistogram.setSelected(
304 Cache.getDefault("SHOW_CONSENSUS_HISTOGRAM", true));
306 .setSelected(Cache.getDefault("SHOW_CONSENSUS_LOGO", false));
308 .setSelected(Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true));
310 .setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP", true));
312 String[] fonts = java.awt.GraphicsEnvironment
313 .getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
314 for (int i = 0; i < fonts.length; i++)
316 fontNameCB.addItem(fonts[i]);
319 for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++)
321 fontSizeCB.addItem(i + "");
324 fontStyleCB.addItem("plain");
325 fontStyleCB.addItem("bold");
326 fontStyleCB.addItem("italic");
328 fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif"));
329 fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10"));
330 fontStyleCB.setSelectedItem(
331 Cache.getDefault("FONT_STYLE", Font.PLAIN + ""));
333 smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", true));
335 .setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA, false));
337 idItalics.setSelected(Cache.getDefault("ID_ITALICS", true));
339 wrap.setSelected(Cache.getDefault("WRAP_ALIGNMENT", false));
341 gapSymbolCB.addItem("-");
342 gapSymbolCB.addItem(".");
344 gapSymbolCB.setSelectedItem(Cache.getDefault("GAP_SYMBOL", "-"));
346 sortby.addItem("No sort");
347 sortby.addItem("Id");
348 sortby.addItem("Pairwise Identity");
349 sortby.setSelectedItem(Cache.getDefault("SORT_ALIGNMENT", "No sort"));
351 sortAnnBy.addItem(SequenceAnnotationOrder.NONE.toString());
353 .addItem(SequenceAnnotationOrder.SEQUENCE_AND_LABEL.toString());
355 .addItem(SequenceAnnotationOrder.LABEL_AND_SEQUENCE.toString());
356 SequenceAnnotationOrder savedSort = SequenceAnnotationOrder
357 .valueOf(Cache.getDefault(SORT_ANNOTATIONS,
358 SequenceAnnotationOrder.NONE.name()));
359 sortAnnBy.setSelectedItem(savedSort.toString());
361 sortAutocalc.addItem("Autocalculated first");
362 sortAutocalc.addItem("Autocalculated last");
363 final boolean showAbove = Cache.getDefault(SHOW_AUTOCALC_ABOVE, true);
364 sortAutocalc.setSelectedItem(showAbove ? sortAutocalc.getItemAt(0)
365 : sortAutocalc.getItemAt(1));
367 .setSelected(Cache.getDefault("SHOW_STARTUP_FILE", true));
368 startupFileTextfield.setText(Cache.getDefault("STARTUP_FILE",
369 Cache.getDefault("www.jalview.org", "https://www.jalview.org")
370 + "/examples/exampleFile_2_7.jvp"));
373 * Set Colours tab defaults
375 protColour.addItem(ResidueColourScheme.NONE);
376 nucColour.addItem(ResidueColourScheme.NONE);
377 for (ColourSchemeI cs : ColourSchemes.getInstance().getColourSchemes())
379 String name = cs.getSchemeName();
380 protColour.addItem(name);
381 nucColour.addItem(name);
383 String oldProp = Cache.getDefault(DEFAULT_COLOUR,
384 ResidueColourScheme.NONE);
385 String newProp = Cache.getDefault(DEFAULT_COLOUR_PROT, null);
386 protColour.setSelectedItem(newProp != null ? newProp : oldProp);
387 newProp = Cache.getDefault(DEFAULT_COLOUR_NUC, null);
388 nucColour.setSelectedItem(newProp != null ? newProp : oldProp);
389 minColour.setBackground(
390 Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN", Color.orange));
391 maxColour.setBackground(
392 Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX", Color.red));
395 * Set overview panel defaults
397 gapColour.setBackground(Cache.getDefaultColour(GAP_COLOUR,
398 OverviewCanvas.OVERVIEW_DEFAULT_GAP));
399 hiddenColour.setBackground(Cache.getDefaultColour(HIDDEN_COLOUR,
400 OverviewCanvas.OVERVIEW_DEFAULT_HIDDEN));
401 useLegacyGap.setSelected(Cache.getDefault(USE_LEGACY_GAP, false));
402 gapLabel.setEnabled(!useLegacyGap.isSelected());
403 gapColour.setEnabled(!useLegacyGap.isSelected());
405 .setSelected(Cache.getDefault(SHOW_OV_HIDDEN_AT_START, false));
408 * Set Structure tab defaults
410 final boolean structSelected = Cache.getDefault(STRUCT_FROM_PDB, true);
411 structFromPdb.setSelected(structSelected);
412 addSecondaryStructure.setSelected(Cache.getDefault(ADD_SS_ANN, true));
413 addSecondaryStructure.setEnabled(structSelected);
414 addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, true));
415 addTempFactor.setEnabled(structSelected);
418 * set choice of structure viewer, and path if saved as a preference;
419 * default to Jmol (first choice) if an unexpected value is found
421 String viewerType = Cache.getDefault(STRUCTURE_DISPLAY,
422 ViewerType.JMOL.name());
423 structViewer.setSelectedItem(viewerType);
424 String viewerPath = "";
425 ViewerType type = null;
428 type = ViewerType.valueOf(viewerType);
434 viewerPath = Cache.getDefault(CHIMERA_PATH, "");
437 viewerPath = Cache.getDefault(CHIMERAX_PATH, "");
440 viewerPath = Cache.getDefault(PYMOL_PATH, "");
443 } catch (IllegalArgumentException e)
445 Console.error("Unknown structure viewer type: " + viewerType
446 + ", defaulting to Jmol");
447 type = ViewerType.JMOL;
449 structureViewerPath.setText(viewerPath);
451 structureViewerPath.addActionListener(new ActionListener()
454 public void actionPerformed(ActionEvent e)
456 if (validateViewerPath())
458 String path = structureViewerPath.getText();
461 ViewerType type = ViewerType.valueOf(viewerType);
467 Cache.setProperty(CHIMERA_PATH, path);
470 Cache.setProperty(CHIMERAX_PATH, path);
473 Cache.setProperty(PYMOL_PATH, path);
476 } catch (IllegalArgumentException x)
478 Console.error("Failed to set path - unknown viewer type", x);
484 if (Cache.getDefault("MAP_WITH_SIFTS", false))
486 siftsMapping.setSelected(true);
490 nwMapping.setSelected(true);
494 .setMapWithSifts(Cache.getDefault("MAP_WITH_SIFTS", false));
497 * Set Connections tab defaults
501 linkUrlTable.setModel(dataModel);
502 final TableRowSorter<TableModel> sorter = new TableRowSorter<>(
503 linkUrlTable.getModel());
504 linkUrlTable.setRowSorter(sorter);
505 List<RowSorter.SortKey> sortKeys = new ArrayList<>();
507 UrlLinkTableModel m = (UrlLinkTableModel) linkUrlTable.getModel();
508 sortKeys.add(new RowSorter.SortKey(m.getPrimaryColumn(),
509 SortOrder.DESCENDING));
510 sortKeys.add(new RowSorter.SortKey(m.getSelectedColumn(),
511 SortOrder.DESCENDING));
513 new RowSorter.SortKey(m.getNameColumn(), SortOrder.ASCENDING));
515 sorter.setSortKeys(sortKeys);
516 // BH 2018 setSortKeys will do the sort
520 ActionListener onReset;
521 onReset = new ActionListener()
524 public void actionPerformed(ActionEvent e)
526 filterTB.setText("");
527 sorter.setRowFilter(RowFilter.regexFilter(""));
531 doReset.addActionListener(onReset);
533 // filter to display only custom urls
534 final RowFilter<TableModel, Object> customUrlFilter = new RowFilter<TableModel, Object>()
537 public boolean include(
538 Entry<? extends TableModel, ? extends Object> entry)
540 return ((UrlLinkTableModel) entry.getModel()).isUserEntry(entry);
544 final TableRowSorter<TableModel> customSorter = new TableRowSorter<>(
545 linkUrlTable.getModel());
546 customSorter.setRowFilter(customUrlFilter);
548 ActionListener onCustomOnly;
549 onCustomOnly = new ActionListener()
552 public void actionPerformed(ActionEvent e)
554 filterTB.setText("");
555 sorter.setRowFilter(customUrlFilter);
558 userOnly.addActionListener(onCustomOnly);
560 filterTB.getDocument().addDocumentListener(new DocumentListener()
562 String caseInsensitiveFlag = "(?i)";
565 public void changedUpdate(DocumentEvent e)
567 sorter.setRowFilter(RowFilter
568 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
572 public void removeUpdate(DocumentEvent e)
574 sorter.setRowFilter(RowFilter
575 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
579 public void insertUpdate(DocumentEvent e)
581 sorter.setRowFilter(RowFilter
582 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
586 // set up list selection functionality
587 linkUrlTable.getSelectionModel()
588 .addListSelectionListener(new UrlListSelectionHandler());
590 // set up radio buttons
591 int onClickCol = ((UrlLinkTableModel) linkUrlTable.getModel())
593 String onClickName = linkUrlTable.getColumnName(onClickCol);
594 linkUrlTable.getColumn(onClickName)
595 .setCellRenderer(new RadioButtonRenderer());
596 linkUrlTable.getColumn(onClickName)
597 .setCellEditor(new RadioButtonEditor());
599 // get boolean columns and resize those to min possible
600 for (int column = 0; column < linkUrlTable.getColumnCount(); column++)
602 if (linkUrlTable.getModel().getColumnClass(column)
603 .equals(Boolean.class))
605 TableColumn tableColumn = linkUrlTable.getColumnModel()
607 int preferredWidth = tableColumn.getMinWidth();
609 TableCellRenderer cellRenderer = linkUrlTable.getCellRenderer(0,
611 Component c = linkUrlTable.prepareRenderer(cellRenderer, 0, column);
612 int cwidth = c.getPreferredSize().width
613 + linkUrlTable.getIntercellSpacing().width;
614 preferredWidth = Math.max(preferredWidth, cwidth);
616 tableColumn.setPreferredWidth(preferredWidth);
620 String proxyTypeString = Cache.getDefault("USE_PROXY", "false");
621 previousProxyType = proxyTypeString;
622 switch (proxyTypeString)
624 case Cache.PROXYTYPE_NONE:
625 proxyType.setSelected(noProxy.getModel(), true);
627 case Cache.PROXYTYPE_SYSTEM:
628 proxyType.setSelected(systemProxy.getModel(), true);
630 case Cache.PROXYTYPE_CUSTOM:
631 proxyType.setSelected(customProxy.getModel(), true);
635 "Incorrect PROXY_TYPE - should be 'none' (clear proxy properties), 'false' (system settings), 'true' (custom settings): "
638 proxyServerHttpTB.setText(Cache.getDefault("PROXY_SERVER", ""));
639 proxyPortHttpTB.setText(Cache.getDefault("PROXY_PORT", ""));
640 proxyServerHttpsTB.setText(Cache.getDefault("PROXY_SERVER_HTTPS", ""));
641 proxyPortHttpsTB.setText(Cache.getDefault("PROXY_PORT_HTTPS", ""));
642 proxyAuth.setSelected(Cache.getDefault("PROXY_AUTH", false));
644 .setText(Cache.getDefault("PROXY_AUTH_USERNAME", ""));
645 // we are not storing or retrieving proxy password from .jalview_properties
646 proxyAuthPasswordPB.setText(Cache.proxyAuthPassword == null ? ""
647 : new String(Cache.proxyAuthPassword));
648 setCustomProxyEnabled();
649 applyProxyButtonEnabled(false);
651 usagestats.setSelected(Cache.getDefault("USAGESTATS", false));
652 // note antisense here: default is true
654 .setSelected(Cache.getProperty("NOQUESTIONNAIRES") == null);
655 versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true));
658 * Set Output tab defaults
660 setupOutputCombo(epsRendering, "EPS_RENDERING");
661 setupOutputCombo(htmlRendering, "HTML_RENDERING");
662 setupOutputCombo(svgRendering, "SVG_RENDERING");
663 autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
664 userIdWidth.setEnabled(!autoIdWidth.isSelected());
665 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
666 Integer wi = Cache.getIntegerProperty("FIGURE_FIXEDIDWIDTH");
667 userIdWidth.setText(wi == null ? "" : wi.toString());
668 // TODO: refactor to use common enum via FormatAdapter and allow extension
669 // for new flat file formats
670 blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
671 clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
672 fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
673 msfjv.setSelected(Cache.getDefault("MSF_JVSUFFIX", true));
674 pfamjv.setSelected(Cache.getDefault("PFAM_JVSUFFIX", true));
675 pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true));
676 pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true));
677 modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false));
679 .setSelected(Cache.getDefault("EXPORT_EMBBED_BIOJSON", true));
682 * Set Editing tab defaults
684 autoCalculateConsCheck
685 .setSelected(Cache.getDefault("AUTO_CALC_CONSENSUS", true));
686 padGaps.setSelected(Cache.getDefault("PAD_GAPS", false));
687 sortByTree.setSelected(Cache.getDefault("SORT_BY_TREE", false));
689 annotations_actionPerformed(null); // update the display of the annotation
693 * Set Backups tab defaults
695 loadLastSavedBackupsOptions();
698 * Set Startup tab defaults
702 Cache.enableSessionProperties();
706 * A helper method that sets the items and initial selection in a character
707 * rendering option list (Prompt each time/Lineart/Text)
712 protected void setupOutputCombo(JComboBox<Object> comboBox,
715 Cache.disableSessionProperties();
717 comboBox.addItem(promptEachTimeOpt);
718 comboBox.addItem(lineArtOpt);
719 comboBox.addItem(textOpt);
722 * JalviewJS doesn't support Lineart so force it to Text
724 String defaultOption = Platform.isJS() ? "Text"
725 : Cache.getDefault(propertyKey, "Prompt each time");
726 if (defaultOption.equalsIgnoreCase("Text"))
728 comboBox.setSelectedItem(textOpt);
730 else if (defaultOption.equalsIgnoreCase("Lineart"))
732 comboBox.setSelectedItem(lineArtOpt);
736 comboBox.setSelectedItem(promptEachTimeOpt);
739 Cache.enableSessionProperties();
743 * Save user selections on the Preferences tabs to the Cache and write out to
749 public void ok_actionPerformed(ActionEvent e)
751 Cache.disableSessionProperties();
753 if (!validateSettings())
759 * Set proxy settings first (to be before web services refresh)
764 * Save Visual settings
767 Cache.applicationProperties.setProperty("SHOW_JVSUFFIX",
768 Boolean.toString(seqLimit.isSelected()));
769 Cache.applicationProperties.setProperty("RIGHT_ALIGN_IDS",
770 Boolean.toString(rightAlign.isSelected()));
771 Cache.applicationProperties.setProperty("SHOW_FULLSCREEN",
772 Boolean.toString(fullScreen.isSelected()));
773 Cache.applicationProperties.setProperty("SHOW_OVERVIEW",
774 Boolean.toString(openoverv.isSelected()));
775 Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
776 Boolean.toString(annotations.isSelected()));
777 Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
778 Boolean.toString(conservation.isSelected()));
779 Cache.applicationProperties.setProperty("SHOW_QUALITY",
780 Boolean.toString(quality.isSelected()));
781 Cache.applicationProperties.setProperty("SHOW_IDENTITY",
782 Boolean.toString(identity.isSelected()));
784 Cache.applicationProperties.setProperty("GAP_SYMBOL",
785 gapSymbolCB.getSelectedItem().toString());
787 Cache.applicationProperties.setProperty("FONT_NAME",
788 fontNameCB.getSelectedItem().toString());
789 Cache.applicationProperties.setProperty("FONT_STYLE",
790 fontStyleCB.getSelectedItem().toString());
791 Cache.applicationProperties.setProperty("FONT_SIZE",
792 fontSizeCB.getSelectedItem().toString());
794 Cache.applicationProperties.setProperty("ID_ITALICS",
795 Boolean.toString(idItalics.isSelected()));
796 Cache.applicationProperties.setProperty("SHOW_UNCONSERVED",
797 Boolean.toString(showUnconserved.isSelected()));
798 Cache.applicationProperties.setProperty(SHOW_OCCUPANCY,
799 Boolean.toString(showOccupancy.isSelected()));
800 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSENSUS",
801 Boolean.toString(showGroupConsensus.isSelected()));
802 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSERVATION",
803 Boolean.toString(showGroupConservation.isSelected()));
804 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_HISTOGRAM",
805 Boolean.toString(showConsensHistogram.isSelected()));
806 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_LOGO",
807 Boolean.toString(showConsensLogo.isSelected()));
808 Cache.applicationProperties.setProperty("ANTI_ALIAS",
809 Boolean.toString(smoothFont.isSelected()));
810 Cache.applicationProperties.setProperty(SCALE_PROTEIN_TO_CDNA,
811 Boolean.toString(scaleProteinToCdna.isSelected()));
812 Cache.applicationProperties.setProperty("SHOW_NPFEATS_TOOLTIP",
813 Boolean.toString(showNpTooltip.isSelected()));
814 Cache.applicationProperties.setProperty("SHOW_DBREFS_TOOLTIP",
815 Boolean.toString(showDbRefTooltip.isSelected()));
817 Cache.applicationProperties.setProperty("WRAP_ALIGNMENT",
818 Boolean.toString(wrap.isSelected()));
820 Cache.applicationProperties.setProperty("STARTUP_FILE",
821 startupFileTextfield.getText());
822 Cache.applicationProperties.setProperty("SHOW_STARTUP_FILE",
823 Boolean.toString(startupCheckbox.isSelected()));
825 Cache.applicationProperties.setProperty("SORT_ALIGNMENT",
826 sortby.getSelectedItem().toString());
828 // convert description of sort order to enum name for save
829 SequenceAnnotationOrder annSortOrder = SequenceAnnotationOrder
830 .forDescription(sortAnnBy.getSelectedItem().toString());
831 if (annSortOrder != null)
833 Cache.applicationProperties.setProperty(SORT_ANNOTATIONS,
834 annSortOrder.name());
837 final boolean showAutocalcFirst = sortAutocalc.getSelectedIndex() == 0;
838 Cache.applicationProperties.setProperty(SHOW_AUTOCALC_ABOVE,
839 Boolean.valueOf(showAutocalcFirst).toString());
842 * Save Colours settings
844 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_PROT,
845 protColour.getSelectedItem().toString());
846 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_NUC,
847 nucColour.getSelectedItem().toString());
848 Cache.setColourProperty("ANNOTATIONCOLOUR_MIN",
849 minColour.getBackground());
850 Cache.setColourProperty("ANNOTATIONCOLOUR_MAX",
851 maxColour.getBackground());
854 * Save Overview settings
856 Cache.setColourProperty(GAP_COLOUR, gapColour.getBackground());
857 Cache.setColourProperty(HIDDEN_COLOUR, hiddenColour.getBackground());
858 Cache.applicationProperties.setProperty(USE_LEGACY_GAP,
859 Boolean.toString(useLegacyGap.isSelected()));
860 Cache.applicationProperties.setProperty(SHOW_OV_HIDDEN_AT_START,
861 Boolean.toString(showHiddenAtStart.isSelected()));
864 * Save Structure settings
866 Cache.applicationProperties.setProperty(ADD_TEMPFACT_ANN,
867 Boolean.toString(addTempFactor.isSelected()));
868 Cache.applicationProperties.setProperty(ADD_SS_ANN,
869 Boolean.toString(addSecondaryStructure.isSelected()));
870 Cache.applicationProperties.setProperty(STRUCT_FROM_PDB,
871 Boolean.toString(structFromPdb.isSelected()));
872 String viewer = structViewer.getSelectedItem().toString();
873 String viewerPath = structureViewerPath.getText();
874 Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY, viewer);
875 if (viewer.equals(ViewerType.CHIMERA.name()))
877 Cache.setOrRemove(CHIMERA_PATH, viewerPath);
879 else if (viewer.equals(ViewerType.CHIMERAX.name()))
881 Cache.setOrRemove(CHIMERAX_PATH, viewerPath);
883 else if (viewer.equals(ViewerType.PYMOL.name()))
885 Cache.setOrRemove(PYMOL_PATH, viewerPath);
887 Cache.applicationProperties.setProperty("MAP_WITH_SIFTS",
888 Boolean.toString(siftsMapping.isSelected()));
889 SiftsSettings.setMapWithSifts(siftsMapping.isSelected());
892 * Save Output settings
894 Cache.applicationProperties.setProperty("EPS_RENDERING",
895 ((OptionsParam) epsRendering.getSelectedItem()).getCode());
896 Cache.applicationProperties.setProperty("HTML_RENDERING",
897 ((OptionsParam) htmlRendering.getSelectedItem()).getCode());
898 Cache.applicationProperties.setProperty("SVG_RENDERING",
899 ((OptionsParam) svgRendering.getSelectedItem()).getCode());
902 * Save Connections settings
904 // Proxy settings set first (to catch web services)
906 // save user-defined and selected links
907 String menuLinks = sequenceUrlLinks.writeUrlsAsString(true);
908 if (menuLinks.isEmpty())
910 Cache.applicationProperties.remove("SEQUENCE_LINKS");
914 Cache.applicationProperties.setProperty("SEQUENCE_LINKS",
915 menuLinks.toString());
918 String nonMenuLinks = sequenceUrlLinks.writeUrlsAsString(false);
919 if (nonMenuLinks.isEmpty())
921 Cache.applicationProperties.remove("STORED_LINKS");
925 Cache.applicationProperties.setProperty("STORED_LINKS",
926 nonMenuLinks.toString());
929 Cache.applicationProperties.setProperty("DEFAULT_URL",
930 sequenceUrlLinks.getPrimaryUrlId());
932 Cache.setProperty("VERSION_CHECK",
933 Boolean.toString(versioncheck.isSelected()));
934 if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
936 // default is false - we only set this if the user has actively agreed
937 Cache.setProperty("USAGESTATS",
938 Boolean.toString(usagestats.isSelected()));
940 if (!questionnaire.isSelected())
942 Cache.setProperty("NOQUESTIONNAIRES", "true");
946 // special - made easy to edit a property file to disable questionnaires
947 // by just adding the given line
948 Cache.removeProperty("NOQUESTIONNAIRES");
952 * Save Output settings
954 Cache.applicationProperties.setProperty("BLC_JVSUFFIX",
955 Boolean.toString(blcjv.isSelected()));
956 Cache.applicationProperties.setProperty("CLUSTAL_JVSUFFIX",
957 Boolean.toString(clustaljv.isSelected()));
958 Cache.applicationProperties.setProperty("FASTA_JVSUFFIX",
959 Boolean.toString(fastajv.isSelected()));
960 Cache.applicationProperties.setProperty("MSF_JVSUFFIX",
961 Boolean.toString(msfjv.isSelected()));
962 Cache.applicationProperties.setProperty("PFAM_JVSUFFIX",
963 Boolean.toString(pfamjv.isSelected()));
964 Cache.applicationProperties.setProperty("PILEUP_JVSUFFIX",
965 Boolean.toString(pileupjv.isSelected()));
966 Cache.applicationProperties.setProperty("PIR_JVSUFFIX",
967 Boolean.toString(pirjv.isSelected()));
968 Cache.applicationProperties.setProperty("PIR_MODELLER",
969 Boolean.toString(modellerOutput.isSelected()));
970 Cache.applicationProperties.setProperty("EXPORT_EMBBED_BIOJSON",
971 Boolean.toString(embbedBioJSON.isSelected()));
972 jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
974 Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH",
975 Boolean.toString(autoIdWidth.isSelected()));
976 userIdWidth_actionPerformed();
977 Cache.applicationProperties.setProperty("FIGURE_FIXEDIDWIDTH",
978 userIdWidth.getText());
981 * Save Editing settings
983 Cache.applicationProperties.setProperty("AUTO_CALC_CONSENSUS",
984 Boolean.toString(autoCalculateConsCheck.isSelected()));
985 Cache.applicationProperties.setProperty("SORT_BY_TREE",
986 Boolean.toString(sortByTree.isSelected()));
987 Cache.applicationProperties.setProperty("PAD_GAPS",
988 Boolean.toString(padGaps.isSelected()));
990 if (!Platform.isJS())
992 wsPrefs.updateAndRefreshWsMenuConfig(false);
996 * Save Backups settings
998 Cache.applicationProperties.setProperty(BackupFiles.ENABLED,
999 Boolean.toString(enableBackupFiles.isSelected()));
1000 int preset = getComboIntStringKey(backupfilesPresetsCombo);
1001 Cache.applicationProperties.setProperty(BackupFiles.NS + "_PRESET",
1002 Integer.toString(preset));
1004 if (preset == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
1006 BackupFilesPresetEntry customBFPE = getBackupfilesCurrentEntry();
1007 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
1008 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM, customBFPE);
1009 Cache.applicationProperties.setProperty(
1010 BackupFilesPresetEntry.CUSTOMCONFIG, customBFPE.toString());
1013 BackupFilesPresetEntry savedBFPE = BackupFilesPresetEntry.backupfilesPresetEntriesValues
1015 Cache.applicationProperties.setProperty(
1016 BackupFilesPresetEntry.SAVEDCONFIG, savedBFPE.toString());
1019 * Save Memory Settings
1021 Cache.applicationProperties.setProperty(
1022 MemorySetting.CUSTOMISED_SETTINGS,
1023 Boolean.toString(customiseMemorySetting.isSelected()));
1024 Cache.applicationProperties.setProperty(MemorySetting.MEMORY_JVMMEMPC,
1025 Integer.toString(jvmMemoryPercentSlider.getValue()));
1026 Cache.applicationProperties.setProperty(MemorySetting.MEMORY_JVMMEMMAX,
1027 jvmMemoryMaxTextField.getText());
1030 * save and close Preferences
1033 Cache.saveProperties();
1034 Desktop.instance.doConfigureStructurePrefs();
1037 frame.setClosed(true);
1038 } catch (Exception ex)
1042 Cache.enableSessionProperties();
1045 public void saveProxySettings()
1047 Cache.disableSessionProperties();
1049 String newProxyType = customProxy.isSelected() ? Cache.PROXYTYPE_CUSTOM
1050 : noProxy.isSelected() ? Cache.PROXYTYPE_NONE
1051 : Cache.PROXYTYPE_SYSTEM;
1052 Cache.applicationProperties.setProperty("USE_PROXY", newProxyType);
1053 Cache.setOrRemove("PROXY_SERVER", proxyServerHttpTB.getText());
1054 Cache.setOrRemove("PROXY_PORT", proxyPortHttpTB.getText());
1055 Cache.setOrRemove("PROXY_SERVER_HTTPS", proxyServerHttpsTB.getText());
1056 Cache.setOrRemove("PROXY_PORT_HTTPS", proxyPortHttpsTB.getText());
1057 Cache.setOrRemove("PROXY_AUTH",
1058 Boolean.toString(proxyAuth.isSelected()));
1059 Cache.setOrRemove("PROXY_AUTH_USERNAME", proxyAuthUsernameTB.getText());
1060 Cache.proxyAuthPassword = proxyAuthPasswordPB.getPassword();
1061 Cache.setProxyPropertiesFromPreferences(previousProxyType);
1062 if (newProxyType.equals(Cache.PROXYTYPE_CUSTOM)
1063 || !newProxyType.equals(previousProxyType))
1065 // force a re-lookup of ws if proxytype is custom or has changed
1068 previousProxyType = newProxyType;
1070 Cache.enableSessionProperties();
1074 * Do any necessary validation before saving settings. Return focus to the
1075 * first tab which fails validation.
1079 private boolean validateSettings()
1081 if (!validateStructure())
1083 structureTab.requestFocusInWindow();
1090 protected boolean validateStructure()
1092 return validateViewerPath();
1100 public void startupFileTextfield_mouseClicked()
1102 Cache.disableSessionProperties();
1104 // TODO: JAL-3048 not needed for Jalview-JS
1105 String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
1106 JalviewFileChooser chooser = JalviewFileChooser
1107 .forRead(Cache.getProperty("LAST_DIRECTORY"), fileFormat);
1108 chooser.setFileView(new JalviewFileView());
1109 chooser.setDialogTitle(
1110 MessageManager.getString("label.select_startup_file"));
1112 int value = chooser.showOpenDialog(this);
1114 if (value == JalviewFileChooser.APPROVE_OPTION)
1116 FileFormatI format = chooser.getSelectedFormat();
1119 Cache.applicationProperties.setProperty("DEFAULT_FILE_FORMAT",
1122 startupFileTextfield
1123 .setText(chooser.getSelectedFile().getAbsolutePath());
1126 Cache.enableSessionProperties();
1136 public void cancel_actionPerformed(ActionEvent e)
1140 if (!Platform.isJS())
1142 wsPrefs.updateWsMenuConfig(true);
1143 wsPrefs.refreshWs_actionPerformed(e);
1145 frame.setClosed(true);
1146 } catch (Exception ex)
1158 public void annotations_actionPerformed(ActionEvent e)
1160 conservation.setEnabled(annotations.isSelected());
1161 quality.setEnabled(annotations.isSelected());
1162 identity.setEnabled(annotations.isSelected());
1163 showOccupancy.setEnabled(annotations.isSelected());
1164 showGroupConsensus.setEnabled(annotations.isSelected());
1165 showGroupConservation.setEnabled(annotations.isSelected());
1166 showConsensHistogram.setEnabled(annotations.isSelected()
1167 && (identity.isSelected() || showGroupConsensus.isSelected()));
1168 showConsensLogo.setEnabled(annotations.isSelected()
1169 && (identity.isSelected() || showGroupConsensus.isSelected()));
1173 public void newLink_actionPerformed(ActionEvent e)
1175 GSequenceLink link = new GSequenceLink();
1176 boolean valid = false;
1179 if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
1180 MessageManager.getString("label.new_sequence_url_link"),
1181 JvOptionPane.OK_CANCEL_OPTION, -1,
1182 null) == JvOptionPane.OK_OPTION)
1184 if (link.checkValid())
1186 if (((UrlLinkTableModel) linkUrlTable.getModel())
1187 .isUniqueName(link.getName()))
1189 ((UrlLinkTableModel) linkUrlTable.getModel())
1190 .insertRow(link.getName(), link.getURL());
1195 link.notifyDuplicate();
1208 public void editLink_actionPerformed(ActionEvent e)
1210 GSequenceLink link = new GSequenceLink();
1212 int index = linkUrlTable.getSelectedRow();
1215 // button no longer enabled if row is not selected
1216 Console.debug("Edit with no row selected in linkUrlTable");
1220 int nameCol = ((UrlLinkTableModel) linkUrlTable.getModel())
1222 int urlCol = ((UrlLinkTableModel) linkUrlTable.getModel())
1224 String oldName = linkUrlTable.getValueAt(index, nameCol).toString();
1225 link.setName(oldName);
1226 link.setURL(linkUrlTable.getValueAt(index, urlCol).toString());
1228 boolean valid = false;
1231 if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
1232 MessageManager.getString("label.edit_sequence_url_link"),
1233 JvOptionPane.OK_CANCEL_OPTION, -1,
1234 null) == JvOptionPane.OK_OPTION)
1236 if (link.checkValid())
1238 if ((oldName.equals(link.getName()))
1239 || (((UrlLinkTableModel) linkUrlTable.getModel())
1240 .isUniqueName(link.getName())))
1242 linkUrlTable.setValueAt(link.getName(), index, nameCol);
1243 linkUrlTable.setValueAt(link.getURL(), index, urlCol);
1248 link.notifyDuplicate();
1261 public void deleteLink_actionPerformed(ActionEvent e)
1263 int index = linkUrlTable.getSelectedRow();
1264 int modelIndex = -1;
1267 // button no longer enabled if row is not selected
1268 Console.debug("Delete with no row selected in linkUrlTable");
1273 modelIndex = linkUrlTable.convertRowIndexToModel(index);
1276 // make sure we use the model index to delete, and not the table index
1277 ((UrlLinkTableModel) linkUrlTable.getModel()).removeRow(modelIndex);
1284 * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event
1288 protected void showunconserved_actionPerformed(ActionEvent e)
1290 // TODO Auto-generated method stub
1291 super.showunconserved_actionPerformed(e);
1294 public static List<String> getGroupURLLinks()
1296 return groupURLLinks;
1300 public void minColour_actionPerformed(JPanel panel)
1302 JalviewColourChooser.showColourChooser(this,
1303 MessageManager.getString("label.select_colour_minimum_value"),
1308 public void maxColour_actionPerformed(JPanel panel)
1310 JalviewColourChooser.showColourChooser(this,
1311 MessageManager.getString("label.select_colour_maximum_value"),
1316 public void gapColour_actionPerformed(JPanel gap)
1318 if (!useLegacyGap.isSelected())
1320 JalviewColourChooser.showColourChooser(this,
1321 MessageManager.getString("label.select_gap_colour"), gap);
1326 public void hiddenColour_actionPerformed(JPanel hidden)
1328 JalviewColourChooser.showColourChooser(this,
1329 MessageManager.getString("label.select_hidden_colour"), hidden);
1333 protected void useLegacyGaps_actionPerformed(ActionEvent e)
1335 boolean enabled = useLegacyGap.isSelected();
1338 gapColour.setBackground(OverviewCanvas.OVERVIEW_DEFAULT_LEGACY_GAP);
1342 gapColour.setBackground(OverviewCanvas.OVERVIEW_DEFAULT_GAP);
1344 gapColour.setEnabled(!enabled);
1345 gapLabel.setEnabled(!enabled);
1349 protected void resetOvDefaults_actionPerformed(ActionEvent e)
1351 useLegacyGap.setSelected(false);
1352 useLegacyGaps_actionPerformed(null);
1353 showHiddenAtStart.setSelected(false);
1354 hiddenColour.setBackground(OverviewCanvas.OVERVIEW_DEFAULT_HIDDEN);
1358 protected void userIdWidth_actionPerformed()
1362 String val = userIdWidth.getText().trim();
1363 if (val.length() > 0)
1365 Integer iw = Integer.parseInt(val);
1366 if (iw.intValue() < 12)
1368 throw new NumberFormatException();
1370 userIdWidth.setText(iw.toString());
1372 } catch (NumberFormatException x)
1374 userIdWidth.setText("");
1375 JvOptionPane.showInternalMessageDialog(Desktop.desktop,
1377 .getString("warn.user_defined_width_requirements"),
1378 MessageManager.getString("label.invalid_id_column_width"),
1379 JvOptionPane.WARNING_MESSAGE);
1384 protected void autoIdWidth_actionPerformed()
1386 userIdWidth.setEnabled(!autoIdWidth.isSelected());
1387 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
1391 * Returns true if structure viewer path is to a valid executable, else shows
1392 * an error dialog. Does nothing if the path is empty, as is the case for Jmol
1393 * (built in to Jalview) or when Jalview is left to try default paths.
1395 private boolean validateViewerPath()
1397 if (structureViewerPath.getText().trim().length() > 0)
1399 File f = new File(structureViewerPath.getText());
1400 if (!f.canExecute())
1402 JvOptionPane.showInternalMessageDialog(Desktop.desktop,
1403 MessageManager.getString("label.invalid_viewer_path"),
1404 MessageManager.getString("label.invalid_viewer_path"),
1405 JvOptionPane.ERROR_MESSAGE);
1413 * If Chimera or ChimeraX or Pymol is selected, check it can be found on
1414 * default or user-specified path, if not show a warning/help dialog
1417 protected void structureViewer_actionPerformed(String selectedItem)
1419 if (selectedItem.equals(ViewerType.JMOL.name()))
1421 structureViewerPath.setEnabled(false);
1422 structureViewerPathLabel.setEnabled(false);
1425 boolean found = false;
1426 structureViewerPath.setEnabled(true);
1427 structureViewerPathLabel.setEnabled(true);
1428 structureViewerPathLabel.setText(MessageManager
1429 .formatMessage("label.viewer_path", selectedItem));
1432 * Try user-specified and standard paths for structure viewer executable
1434 String viewerPath = "";
1435 List<String> paths = null;
1436 Cache.disableSessionProperties();
1439 ViewerType viewerType = ViewerType.valueOf(selectedItem);
1446 viewerPath = Cache.getDefault(CHIMERA_PATH, "");
1447 paths = StructureManager.getChimeraPaths(false);
1450 viewerPath = Cache.getDefault(CHIMERAX_PATH, "");
1451 paths = StructureManager.getChimeraPaths(true);
1454 viewerPath = Cache.getDefault(PYMOL_PATH, "");
1455 paths = PymolManager.getPymolPaths();
1458 } catch (IllegalArgumentException e)
1460 // only valid entries should be in the drop-down
1462 Cache.enableSessionProperties();
1463 structureViewerPath.setText(viewerPath);
1465 paths.add(0, structureViewerPath.getText());
1466 for (String path : paths)
1468 if (new File(path.trim()).canExecute())
1477 String[] options = { "OK", "Help" };
1478 int showHelp = JvOptionPane.showInternalOptionDialog(Desktop.desktop,
1479 JvSwingUtils.wrapTooltip(true,
1480 MessageManager.getString("label.viewer_missing")),
1481 "", JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE,
1482 null, options, options[0]);
1484 if (showHelp == JvOptionPane.NO_OPTION)
1486 this.selectTab(Preferences.TabRef.STRUCTURE_TAB, null);
1489 Help.showHelpWindow(HelpId.StructureViewer);
1490 } catch (HelpSetException e)
1492 e.printStackTrace();
1495 else if (showHelp == JvOptionPane.OK_OPTION)
1497 this.selectTab(Preferences.TabRef.STRUCTURE_TAB, null);
1498 CompletableFuture<Void> cf = CompletableFuture.runAsync(() -> {
1501 for (int i = 0; i < 3; i++)
1503 structureViewerPath.setBackground(Color.PINK);
1505 structureViewerPath.setBackground(Color.WHITE);
1508 } catch (InterruptedException e)
1516 public class OptionsParam
1518 private String name;
1520 private String code;
1522 public OptionsParam(String name, String code)
1528 public String getName()
1533 public void setName(String name)
1538 public String getCode()
1543 public void setCode(String code)
1549 public String toString()
1555 public boolean equals(Object that)
1557 if (!(that instanceof OptionsParam))
1561 return this.code.equalsIgnoreCase(((OptionsParam) that).code);
1565 public int hashCode()
1567 return name.hashCode() + code.hashCode();
1571 private class UrlListSelectionHandler implements ListSelectionListener
1575 public void valueChanged(ListSelectionEvent e)
1577 ListSelectionModel lsm = (ListSelectionModel) e.getSource();
1579 int index = lsm.getMinSelectionIndex();
1582 // no selection, so disable delete/edit buttons
1583 editLink.setEnabled(false);
1584 deleteLink.setEnabled(false);
1587 int modelIndex = linkUrlTable.convertRowIndexToModel(index);
1589 // enable/disable edit and delete link buttons
1590 if (((UrlLinkTableModel) linkUrlTable.getModel())
1591 .isRowDeletable(modelIndex))
1593 deleteLink.setEnabled(true);
1597 deleteLink.setEnabled(false);
1600 if (((UrlLinkTableModel) linkUrlTable.getModel())
1601 .isRowEditable(modelIndex))
1603 editLink.setEnabled(true);
1607 editLink.setEnabled(false);