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.MouseEvent;
32 import java.util.ArrayList;
33 import java.util.List;
34 import java.util.concurrent.CompletableFuture;
36 import javax.help.HelpSetException;
37 import javax.swing.JComboBox;
38 import javax.swing.JFileChooser;
39 import javax.swing.JInternalFrame;
40 import javax.swing.JPanel;
41 import javax.swing.ListSelectionModel;
42 import javax.swing.RowFilter;
43 import javax.swing.RowSorter;
44 import javax.swing.SortOrder;
45 import javax.swing.event.DocumentEvent;
46 import javax.swing.event.DocumentListener;
47 import javax.swing.event.ListSelectionEvent;
48 import javax.swing.event.ListSelectionListener;
49 import javax.swing.table.TableCellRenderer;
50 import javax.swing.table.TableColumn;
51 import javax.swing.table.TableModel;
52 import javax.swing.table.TableRowSorter;
54 import edu.stanford.ejalbert.launching.IBrowserLaunching;
55 import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
56 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
57 import jalview.bin.Cache;
58 import jalview.bin.Console;
59 import jalview.bin.MemorySetting;
60 import jalview.ext.pymol.PymolManager;
61 import jalview.gui.Help.HelpId;
62 import jalview.gui.StructureViewer.ViewerType;
63 import jalview.io.BackupFiles;
64 import jalview.io.BackupFilesPresetEntry;
65 import jalview.io.FileFormatI;
66 import jalview.io.JalviewFileChooser;
67 import jalview.io.JalviewFileView;
68 import jalview.jbgui.GPreferences;
69 import jalview.jbgui.GSequenceLink;
70 import jalview.schemes.ColourSchemeI;
71 import jalview.schemes.ColourSchemes;
72 import jalview.schemes.ResidueColourScheme;
73 import jalview.urls.UrlLinkTableModel;
74 import jalview.urls.api.UrlProviderFactoryI;
75 import jalview.urls.api.UrlProviderI;
76 import jalview.urls.desktop.DesktopUrlProviderFactory;
77 import jalview.util.BrowserLauncher;
78 import jalview.util.MessageManager;
79 import jalview.util.Platform;
80 import jalview.util.UrlConstants;
81 import jalview.ws.sifts.SiftsSettings;
90 * for merge with Jalview-JS
91 public class Preferences extends GPreferences implements ApplicationSingletonI
93 public class Preferences extends GPreferences
95 public static final String ENABLE_SPLIT_FRAME = "ENABLE_SPLIT_FRAME";
97 public static final String SCALE_PROTEIN_TO_CDNA = "SCALE_PROTEIN_TO_CDNA";
99 public static final String DEFAULT_COLOUR = "DEFAULT_COLOUR";
101 public static final String DEFAULT_COLOUR_PROT = "DEFAULT_COLOUR_PROT";
103 public static final String DEFAULT_COLOUR_NUC = "DEFAULT_COLOUR_NUC";
105 public static final String ADD_TEMPFACT_ANN = "ADD_TEMPFACT_ANN";
107 public static final String ADD_SS_ANN = "ADD_SS_ANN";
109 public static final String USE_RNAVIEW = "USE_RNAVIEW";
111 public static final String STRUCT_FROM_PDB = "STRUCT_FROM_PDB";
113 public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY";
115 public static final String CHIMERA_PATH = "CHIMERA_PATH";
117 public static final String CHIMERAX_PATH = "CHIMERAX_PATH";
119 public static final String PYMOL_PATH = "PYMOL_PATH";
121 public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS";
123 public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE";
125 public static final String SHOW_OCCUPANCY = "SHOW_OCCUPANCY";
127 public static final String SHOW_OV_HIDDEN_AT_START = "SHOW_OV_HIDDEN_AT_START";
129 public static final String USE_LEGACY_GAP = "USE_LEGACY_GAP";
131 public static final String GAP_COLOUR = "GAP_COLOUR";
133 public static final String HIDDEN_COLOUR = "HIDDEN_COLOUR";
135 private static final int MIN_FONT_SIZE = 1;
137 private static final int MAX_FONT_SIZE = 30;
139 private String previousProxyType;
141 private static Preferences INSTANCE = null; // add "final"
144 * Holds name and link separated with | character. Sequence ID must be
145 * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$
147 public static UrlProviderI sequenceUrlLinks;
149 public static UrlLinkTableModel dataModel;
152 * Holds name and link separated with | character. Sequence IDS and Sequences
153 * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and
154 * $SEQUENCES$ or $SEQUENCES=/.possible | chars ./=$ and separation character
155 * for first and second token specified after a pipe character at end |,|.
156 * (TODO: proper escape for using | to separate ids or sequences
159 public static List<String> groupURLLinks;
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 JInternalFrame frame;
190 private WsPreferences wsPrefs;
192 private OptionsParam promptEachTimeOpt = new OptionsParam(
193 MessageManager.getString("label.prompt_each_time"),
196 private OptionsParam lineArtOpt = new OptionsParam(
197 MessageManager.getString("label.lineart"), "Lineart");
199 private OptionsParam textOpt = new OptionsParam(
200 MessageManager.getString("action.text"), "Text");
202 // get singleton Preferences instance
203 public static Preferences getInstance()
205 if (INSTANCE == null || INSTANCE.frame == null
206 || INSTANCE.frame.isClosed())
208 INSTANCE = new Preferences();
213 * Replace code with the following for Jalvew-JS
214 Preferences INSTANCE = ApplicationSingletonProvider.getInstance(Preferences.class);
215 if (INSTANCE == null || INSTANCE.frame == null
216 || INSTANCE.frame.isClosed())
218 ApplicationSingletonProvider.remove(Preferences.class);
219 INSTANCE = ApplicationSingletonProvider.getInstance(Preferences.class);
225 public static void openPreferences()
227 openPreferences(null, null);
230 public static void openPreferences(TabRef selectTab, String message)
232 Preferences p = getInstance();
233 if (selectTab != null)
234 p.selectTab(selectTab, message);
236 p.frame.moveToFront();
240 public void selectTab(TabRef selectTab, String message)
242 this.selectTab(selectTab);
244 this.setMessage(message);
249 * Creates a new Preferences object.
251 private Preferences()
254 frame = new JInternalFrame();
255 frame.setContentPane(this);
256 if (!Platform.isJS())
263 wsPrefs = new WsPreferences();
264 wsTab.add(wsPrefs, BorderLayout.CENTER);
266 int width = 500, height = 450;
267 if (Platform.isAMacAndNotJS())
273 Desktop.addInternalFrame(frame,
274 MessageManager.getString("label.preferences"), width, height);
275 frame.setMinimumSize(new Dimension(width, height));
278 * Set Visual tab defaults
280 seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true));
281 rightAlign.setSelected(Cache.getDefault("RIGHT_ALIGN_IDS", false));
282 fullScreen.setSelected(Cache.getDefault("SHOW_FULLSCREEN", false));
283 annotations.setSelected(Cache.getDefault("SHOW_ANNOTATIONS", true));
285 conservation.setSelected(Cache.getDefault("SHOW_CONSERVATION", true));
286 quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));
287 identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
288 openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false));
290 .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
291 showOccupancy.setSelected(Cache.getDefault(SHOW_OCCUPANCY, false));
293 .setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS", false));
294 showGroupConservation.setSelected(
295 Cache.getDefault("SHOW_GROUP_CONSERVATION", false));
296 showConsensHistogram.setSelected(
297 Cache.getDefault("SHOW_CONSENSUS_HISTOGRAM", true));
299 .setSelected(Cache.getDefault("SHOW_CONSENSUS_LOGO", false));
301 .setSelected(Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true));
303 .setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP", true));
305 String[] fonts = java.awt.GraphicsEnvironment
306 .getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
307 for (int i = 0; i < fonts.length; i++)
309 fontNameCB.addItem(fonts[i]);
312 for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++)
314 fontSizeCB.addItem(i + "");
317 fontStyleCB.addItem("plain");
318 fontStyleCB.addItem("bold");
319 fontStyleCB.addItem("italic");
321 fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif"));
322 fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10"));
323 fontStyleCB.setSelectedItem(
324 Cache.getDefault("FONT_STYLE", Font.PLAIN + ""));
326 smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", true));
328 .setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA, false));
330 idItalics.setSelected(Cache.getDefault("ID_ITALICS", true));
332 wrap.setSelected(Cache.getDefault("WRAP_ALIGNMENT", false));
334 gapSymbolCB.addItem("-");
335 gapSymbolCB.addItem(".");
337 gapSymbolCB.setSelectedItem(Cache.getDefault("GAP_SYMBOL", "-"));
339 sortby.addItem("No sort");
340 sortby.addItem("Id");
341 sortby.addItem("Pairwise Identity");
342 sortby.setSelectedItem(Cache.getDefault("SORT_ALIGNMENT", "No sort"));
344 sortAnnBy.addItem(SequenceAnnotationOrder.NONE.toString());
346 .addItem(SequenceAnnotationOrder.SEQUENCE_AND_LABEL.toString());
348 .addItem(SequenceAnnotationOrder.LABEL_AND_SEQUENCE.toString());
349 SequenceAnnotationOrder savedSort = SequenceAnnotationOrder
350 .valueOf(Cache.getDefault(SORT_ANNOTATIONS,
351 SequenceAnnotationOrder.NONE.name()));
352 sortAnnBy.setSelectedItem(savedSort.toString());
354 sortAutocalc.addItem("Autocalculated first");
355 sortAutocalc.addItem("Autocalculated last");
356 final boolean showAbove = Cache.getDefault(SHOW_AUTOCALC_ABOVE, true);
357 sortAutocalc.setSelectedItem(showAbove ? sortAutocalc.getItemAt(0)
358 : sortAutocalc.getItemAt(1));
360 .setSelected(Cache.getDefault("SHOW_STARTUP_FILE", true));
361 startupFileTextfield.setText(Cache.getDefault("STARTUP_FILE",
362 Cache.getDefault("www.jalview.org", "https://www.jalview.org")
363 + "/examples/exampleFile_2_7.jvp"));
366 * Set Colours tab defaults
368 protColour.addItem(ResidueColourScheme.NONE);
369 nucColour.addItem(ResidueColourScheme.NONE);
370 for (ColourSchemeI cs : ColourSchemes.getInstance().getColourSchemes())
372 String name = cs.getSchemeName();
373 protColour.addItem(name);
374 nucColour.addItem(name);
376 String oldProp = Cache.getDefault(DEFAULT_COLOUR,
377 ResidueColourScheme.NONE);
378 String newProp = Cache.getDefault(DEFAULT_COLOUR_PROT, null);
379 protColour.setSelectedItem(newProp != null ? newProp : oldProp);
380 newProp = Cache.getDefault(DEFAULT_COLOUR_NUC, null);
381 nucColour.setSelectedItem(newProp != null ? newProp : oldProp);
382 minColour.setBackground(
383 Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN", Color.orange));
384 maxColour.setBackground(
385 Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX", Color.red));
388 * Set overview panel defaults
390 gapColour.setBackground(Cache.getDefaultColour(GAP_COLOUR,
391 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP));
392 hiddenColour.setBackground(Cache.getDefaultColour(HIDDEN_COLOUR,
393 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_HIDDEN));
394 useLegacyGap.setSelected(Cache.getDefault(USE_LEGACY_GAP, false));
395 gapLabel.setEnabled(!useLegacyGap.isSelected());
396 gapColour.setEnabled(!useLegacyGap.isSelected());
398 .setSelected(Cache.getDefault(SHOW_OV_HIDDEN_AT_START, false));
401 * Set Structure tab defaults
403 final boolean structSelected = Cache.getDefault(STRUCT_FROM_PDB, true);
404 structFromPdb.setSelected(structSelected);
405 addSecondaryStructure.setSelected(Cache.getDefault(ADD_SS_ANN, true));
406 addSecondaryStructure.setEnabled(structSelected);
407 addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, true));
408 addTempFactor.setEnabled(structSelected);
411 * set choice of structure viewer, and path if saved as a preference;
412 * default to Jmol (first choice) if an unexpected value is found
414 String viewerType = Cache.getDefault(STRUCTURE_DISPLAY,
415 ViewerType.JMOL.name());
416 structViewer.setSelectedItem(viewerType);
417 String viewerPath = "";
418 ViewerType type = null;
421 type = ViewerType.valueOf(viewerType);
427 viewerPath = Cache.getDefault(CHIMERA_PATH, "");
430 viewerPath = Cache.getDefault(CHIMERAX_PATH, "");
433 viewerPath = Cache.getDefault(PYMOL_PATH, "");
436 } catch (IllegalArgumentException e)
438 Console.error("Unknown structure viewer type: " + viewerType
439 + ", defaulting to Jmol");
440 type = ViewerType.JMOL;
442 structureViewerPath.setText(viewerPath);
444 structureViewerPath.addActionListener(new ActionListener()
447 public void actionPerformed(ActionEvent e)
449 if (validateViewerPath())
451 String path = structureViewerPath.getText();
454 ViewerType type = ViewerType.valueOf(viewerType);
460 Cache.setProperty(CHIMERA_PATH, path);
463 Cache.setProperty(CHIMERAX_PATH, path);
466 Cache.setProperty(PYMOL_PATH, path);
469 } catch (IllegalArgumentException x)
471 Console.error("Failed to set path - unknown viewer type", x);
477 if (Cache.getDefault("MAP_WITH_SIFTS", false))
479 siftsMapping.setSelected(true);
483 nwMapping.setSelected(true);
487 .setMapWithSifts(Cache.getDefault("MAP_WITH_SIFTS", false));
490 * Set Connections tab defaults
494 linkUrlTable.setModel(dataModel);
495 final TableRowSorter<TableModel> sorter = new TableRowSorter<>(
496 linkUrlTable.getModel());
497 linkUrlTable.setRowSorter(sorter);
498 List<RowSorter.SortKey> sortKeys = new ArrayList<>();
500 UrlLinkTableModel m = (UrlLinkTableModel) linkUrlTable.getModel();
501 sortKeys.add(new RowSorter.SortKey(m.getPrimaryColumn(),
502 SortOrder.DESCENDING));
503 sortKeys.add(new RowSorter.SortKey(m.getSelectedColumn(),
504 SortOrder.DESCENDING));
506 new RowSorter.SortKey(m.getNameColumn(), SortOrder.ASCENDING));
508 sorter.setSortKeys(sortKeys);
509 // BH 2018 setSortKeys will do the sort
513 ActionListener onReset;
514 onReset = new ActionListener()
517 public void actionPerformed(ActionEvent e)
519 filterTB.setText("");
520 sorter.setRowFilter(RowFilter.regexFilter(""));
524 doReset.addActionListener(onReset);
526 // filter to display only custom urls
527 final RowFilter<TableModel, Object> customUrlFilter = new RowFilter<TableModel, Object>()
530 public boolean include(
531 Entry<? extends TableModel, ? extends Object> entry)
533 return ((UrlLinkTableModel) entry.getModel()).isUserEntry(entry);
537 final TableRowSorter<TableModel> customSorter = new TableRowSorter<>(
538 linkUrlTable.getModel());
539 customSorter.setRowFilter(customUrlFilter);
541 ActionListener onCustomOnly;
542 onCustomOnly = new ActionListener()
545 public void actionPerformed(ActionEvent e)
547 filterTB.setText("");
548 sorter.setRowFilter(customUrlFilter);
551 userOnly.addActionListener(onCustomOnly);
553 filterTB.getDocument().addDocumentListener(new DocumentListener()
555 String caseInsensitiveFlag = "(?i)";
558 public void changedUpdate(DocumentEvent e)
560 sorter.setRowFilter(RowFilter
561 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
565 public void removeUpdate(DocumentEvent e)
567 sorter.setRowFilter(RowFilter
568 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
572 public void insertUpdate(DocumentEvent e)
574 sorter.setRowFilter(RowFilter
575 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
579 // set up list selection functionality
580 linkUrlTable.getSelectionModel()
581 .addListSelectionListener(new UrlListSelectionHandler());
583 // set up radio buttons
584 int onClickCol = ((UrlLinkTableModel) linkUrlTable.getModel())
586 String onClickName = linkUrlTable.getColumnName(onClickCol);
587 linkUrlTable.getColumn(onClickName)
588 .setCellRenderer(new RadioButtonRenderer());
589 linkUrlTable.getColumn(onClickName)
590 .setCellEditor(new RadioButtonEditor());
592 // get boolean columns and resize those to min possible
593 for (int column = 0; column < linkUrlTable.getColumnCount(); column++)
595 if (linkUrlTable.getModel().getColumnClass(column)
596 .equals(Boolean.class))
598 TableColumn tableColumn = linkUrlTable.getColumnModel()
600 int preferredWidth = tableColumn.getMinWidth();
602 TableCellRenderer cellRenderer = linkUrlTable.getCellRenderer(0,
604 Component c = linkUrlTable.prepareRenderer(cellRenderer, 0, column);
605 int cwidth = c.getPreferredSize().width
606 + linkUrlTable.getIntercellSpacing().width;
607 preferredWidth = Math.max(preferredWidth, cwidth);
609 tableColumn.setPreferredWidth(preferredWidth);
613 String proxyTypeString = Cache.getDefault("USE_PROXY", "false");
614 previousProxyType = proxyTypeString;
615 switch (proxyTypeString)
617 case Cache.PROXYTYPE_NONE:
618 proxyType.setSelected(noProxy.getModel(), true);
620 case Cache.PROXYTYPE_SYSTEM:
621 proxyType.setSelected(systemProxy.getModel(), true);
623 case Cache.PROXYTYPE_CUSTOM:
624 proxyType.setSelected(customProxy.getModel(), true);
628 "Incorrect PROXY_TYPE - should be 'none' (clear proxy properties), 'false' (system settings), 'true' (custom settings): "
631 proxyServerHttpTB.setText(Cache.getDefault("PROXY_SERVER", ""));
632 proxyPortHttpTB.setText(Cache.getDefault("PROXY_PORT", ""));
633 proxyServerHttpsTB.setText(Cache.getDefault("PROXY_SERVER_HTTPS", ""));
634 proxyPortHttpsTB.setText(Cache.getDefault("PROXY_PORT_HTTPS", ""));
635 proxyAuth.setSelected(Cache.getDefault("PROXY_AUTH", false));
637 .setText(Cache.getDefault("PROXY_AUTH_USERNAME", ""));
638 // we are not storing or retrieving proxy password from .jalview_properties
639 proxyAuthPasswordPB.setText(Cache.proxyAuthPassword == null ? ""
640 : new String(Cache.proxyAuthPassword));
641 setCustomProxyEnabled();
642 applyProxyButtonEnabled(false);
644 defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
646 usagestats.setSelected(Cache.getDefault("USAGESTATS", false));
647 // note antisense here: default is true
649 .setSelected(Cache.getProperty("NOQUESTIONNAIRES") == null);
650 versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true));
653 * Set Output tab defaults
655 setupOutputCombo(epsRendering, "EPS_RENDERING");
656 setupOutputCombo(htmlRendering, "HTML_RENDERING");
657 setupOutputCombo(svgRendering, "SVG_RENDERING");
658 autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
659 userIdWidth.setEnabled(!autoIdWidth.isSelected());
660 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
661 Integer wi = Cache.getIntegerProperty("FIGURE_FIXEDIDWIDTH");
662 userIdWidth.setText(wi == null ? "" : wi.toString());
663 // TODO: refactor to use common enum via FormatAdapter and allow extension
664 // for new flat file formats
665 blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
666 clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
667 fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
668 msfjv.setSelected(Cache.getDefault("MSF_JVSUFFIX", true));
669 pfamjv.setSelected(Cache.getDefault("PFAM_JVSUFFIX", true));
670 pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true));
671 pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true));
672 modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false));
674 .setSelected(Cache.getDefault("EXPORT_EMBBED_BIOJSON", true));
677 * Set Editing tab defaults
679 autoCalculateConsCheck
680 .setSelected(Cache.getDefault("AUTO_CALC_CONSENSUS", true));
681 padGaps.setSelected(Cache.getDefault("PAD_GAPS", false));
682 sortByTree.setSelected(Cache.getDefault("SORT_BY_TREE", false));
684 annotations_actionPerformed(null); // update the display of the annotation
688 * Set Backups tab defaults
690 loadLastSavedBackupsOptions();
693 * Set Startup tab defaults
699 * A helper method that sets the items and initial selection in a character
700 * rendering option list (Prompt each time/Lineart/Text)
705 protected void setupOutputCombo(JComboBox<Object> comboBox,
708 comboBox.addItem(promptEachTimeOpt);
709 comboBox.addItem(lineArtOpt);
710 comboBox.addItem(textOpt);
713 * JalviewJS doesn't support Lineart so force it to Text
715 String defaultOption = Platform.isJS() ? "Text"
716 : Cache.getDefault(propertyKey, "Prompt each time");
717 if (defaultOption.equalsIgnoreCase("Text"))
719 comboBox.setSelectedItem(textOpt);
721 else if (defaultOption.equalsIgnoreCase("Lineart"))
723 comboBox.setSelectedItem(lineArtOpt);
727 comboBox.setSelectedItem(promptEachTimeOpt);
732 * Save user selections on the Preferences tabs to the Cache and write out to
738 public void ok_actionPerformed(ActionEvent e)
740 if (!validateSettings())
746 * Set proxy settings first (to be before web services refresh)
751 * Save Visual settings
753 Cache.applicationProperties.setProperty("SHOW_JVSUFFIX",
754 Boolean.toString(seqLimit.isSelected()));
755 Cache.applicationProperties.setProperty("RIGHT_ALIGN_IDS",
756 Boolean.toString(rightAlign.isSelected()));
757 Cache.applicationProperties.setProperty("SHOW_FULLSCREEN",
758 Boolean.toString(fullScreen.isSelected()));
759 Cache.applicationProperties.setProperty("SHOW_OVERVIEW",
760 Boolean.toString(openoverv.isSelected()));
761 Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
762 Boolean.toString(annotations.isSelected()));
763 Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
764 Boolean.toString(conservation.isSelected()));
765 Cache.applicationProperties.setProperty("SHOW_QUALITY",
766 Boolean.toString(quality.isSelected()));
767 Cache.applicationProperties.setProperty("SHOW_IDENTITY",
768 Boolean.toString(identity.isSelected()));
770 Cache.applicationProperties.setProperty("GAP_SYMBOL",
771 gapSymbolCB.getSelectedItem().toString());
773 Cache.applicationProperties.setProperty("FONT_NAME",
774 fontNameCB.getSelectedItem().toString());
775 Cache.applicationProperties.setProperty("FONT_STYLE",
776 fontStyleCB.getSelectedItem().toString());
777 Cache.applicationProperties.setProperty("FONT_SIZE",
778 fontSizeCB.getSelectedItem().toString());
780 Cache.applicationProperties.setProperty("ID_ITALICS",
781 Boolean.toString(idItalics.isSelected()));
782 Cache.applicationProperties.setProperty("SHOW_UNCONSERVED",
783 Boolean.toString(showUnconserved.isSelected()));
784 Cache.applicationProperties.setProperty(SHOW_OCCUPANCY,
785 Boolean.toString(showOccupancy.isSelected()));
786 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSENSUS",
787 Boolean.toString(showGroupConsensus.isSelected()));
788 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSERVATION",
789 Boolean.toString(showGroupConservation.isSelected()));
790 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_HISTOGRAM",
791 Boolean.toString(showConsensHistogram.isSelected()));
792 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_LOGO",
793 Boolean.toString(showConsensLogo.isSelected()));
794 Cache.applicationProperties.setProperty("ANTI_ALIAS",
795 Boolean.toString(smoothFont.isSelected()));
796 Cache.applicationProperties.setProperty(SCALE_PROTEIN_TO_CDNA,
797 Boolean.toString(scaleProteinToCdna.isSelected()));
798 Cache.applicationProperties.setProperty("SHOW_NPFEATS_TOOLTIP",
799 Boolean.toString(showNpTooltip.isSelected()));
800 Cache.applicationProperties.setProperty("SHOW_DBREFS_TOOLTIP",
801 Boolean.toString(showDbRefTooltip.isSelected()));
803 Cache.applicationProperties.setProperty("WRAP_ALIGNMENT",
804 Boolean.toString(wrap.isSelected()));
806 Cache.applicationProperties.setProperty("STARTUP_FILE",
807 startupFileTextfield.getText());
808 Cache.applicationProperties.setProperty("SHOW_STARTUP_FILE",
809 Boolean.toString(startupCheckbox.isSelected()));
811 Cache.applicationProperties.setProperty("SORT_ALIGNMENT",
812 sortby.getSelectedItem().toString());
814 // convert description of sort order to enum name for save
815 SequenceAnnotationOrder annSortOrder = SequenceAnnotationOrder
816 .forDescription(sortAnnBy.getSelectedItem().toString());
817 if (annSortOrder != null)
819 Cache.applicationProperties.setProperty(SORT_ANNOTATIONS,
820 annSortOrder.name());
823 final boolean showAutocalcFirst = sortAutocalc.getSelectedIndex() == 0;
824 Cache.applicationProperties.setProperty(SHOW_AUTOCALC_ABOVE,
825 Boolean.valueOf(showAutocalcFirst).toString());
828 * Save Colours settings
830 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_PROT,
831 protColour.getSelectedItem().toString());
832 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_NUC,
833 nucColour.getSelectedItem().toString());
834 Cache.setColourProperty("ANNOTATIONCOLOUR_MIN",
835 minColour.getBackground());
836 Cache.setColourProperty("ANNOTATIONCOLOUR_MAX",
837 maxColour.getBackground());
840 * Save Overview settings
842 Cache.setColourProperty(GAP_COLOUR, gapColour.getBackground());
843 Cache.setColourProperty(HIDDEN_COLOUR, hiddenColour.getBackground());
844 Cache.applicationProperties.setProperty(USE_LEGACY_GAP,
845 Boolean.toString(useLegacyGap.isSelected()));
846 Cache.applicationProperties.setProperty(SHOW_OV_HIDDEN_AT_START,
847 Boolean.toString(showHiddenAtStart.isSelected()));
850 * Save Structure settings
852 Cache.applicationProperties.setProperty(ADD_TEMPFACT_ANN,
853 Boolean.toString(addTempFactor.isSelected()));
854 Cache.applicationProperties.setProperty(ADD_SS_ANN,
855 Boolean.toString(addSecondaryStructure.isSelected()));
856 Cache.applicationProperties.setProperty(STRUCT_FROM_PDB,
857 Boolean.toString(structFromPdb.isSelected()));
858 String viewer = structViewer.getSelectedItem().toString();
859 String viewerPath = structureViewerPath.getText();
860 Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY, viewer);
861 if (viewer.equals(ViewerType.CHIMERA.name()))
863 Cache.setOrRemove(CHIMERA_PATH, viewerPath);
865 else if (viewer.equals(ViewerType.CHIMERAX.name()))
867 Cache.setOrRemove(CHIMERAX_PATH, viewerPath);
869 else if (viewer.equals(ViewerType.PYMOL.name()))
871 Cache.setOrRemove(PYMOL_PATH, viewerPath);
873 Cache.applicationProperties.setProperty("MAP_WITH_SIFTS",
874 Boolean.toString(siftsMapping.isSelected()));
875 SiftsSettings.setMapWithSifts(siftsMapping.isSelected());
878 * Save Output settings
880 Cache.applicationProperties.setProperty("EPS_RENDERING",
881 ((OptionsParam) epsRendering.getSelectedItem()).getCode());
882 Cache.applicationProperties.setProperty("HTML_RENDERING",
883 ((OptionsParam) htmlRendering.getSelectedItem()).getCode());
884 Cache.applicationProperties.setProperty("SVG_RENDERING",
885 ((OptionsParam) svgRendering.getSelectedItem()).getCode());
888 * Save Connections settings
890 // Proxy settings set first (to catch web services)
892 Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
893 if (Cache.getProperty("DEFAULT_BROWSER") != null)
895 System.setProperty(IBrowserLaunching.BROWSER_SYSTEM_PROPERTY,
896 Cache.getProperty("DEFAULT_BROWSER"));
900 System.clearProperty(IBrowserLaunching.BROWSER_SYSTEM_PROPERTY);
902 BrowserLauncher.resetBrowser();
904 // save user-defined and selected links
905 String menuLinks = sequenceUrlLinks.writeUrlsAsString(true);
906 if (menuLinks.isEmpty())
908 Cache.applicationProperties.remove("SEQUENCE_LINKS");
912 Cache.applicationProperties.setProperty("SEQUENCE_LINKS",
913 menuLinks.toString());
916 String nonMenuLinks = sequenceUrlLinks.writeUrlsAsString(false);
917 if (nonMenuLinks.isEmpty())
919 Cache.applicationProperties.remove("STORED_LINKS");
923 Cache.applicationProperties.setProperty("STORED_LINKS",
924 nonMenuLinks.toString());
927 Cache.applicationProperties.setProperty("DEFAULT_URL",
928 sequenceUrlLinks.getPrimaryUrlId());
930 Cache.setProperty("VERSION_CHECK",
931 Boolean.toString(versioncheck.isSelected()));
932 if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
934 // default is false - we only set this if the user has actively agreed
935 Cache.setProperty("USAGESTATS",
936 Boolean.toString(usagestats.isSelected()));
938 if (!questionnaire.isSelected())
940 Cache.setProperty("NOQUESTIONNAIRES", "true");
944 // special - made easy to edit a property file to disable questionnaires
945 // by just adding the given line
946 Cache.removeProperty("NOQUESTIONNAIRES");
950 * Save Output settings
952 Cache.applicationProperties.setProperty("BLC_JVSUFFIX",
953 Boolean.toString(blcjv.isSelected()));
954 Cache.applicationProperties.setProperty("CLUSTAL_JVSUFFIX",
955 Boolean.toString(clustaljv.isSelected()));
956 Cache.applicationProperties.setProperty("FASTA_JVSUFFIX",
957 Boolean.toString(fastajv.isSelected()));
958 Cache.applicationProperties.setProperty("MSF_JVSUFFIX",
959 Boolean.toString(msfjv.isSelected()));
960 Cache.applicationProperties.setProperty("PFAM_JVSUFFIX",
961 Boolean.toString(pfamjv.isSelected()));
962 Cache.applicationProperties.setProperty("PILEUP_JVSUFFIX",
963 Boolean.toString(pileupjv.isSelected()));
964 Cache.applicationProperties.setProperty("PIR_JVSUFFIX",
965 Boolean.toString(pirjv.isSelected()));
966 Cache.applicationProperties.setProperty("PIR_MODELLER",
967 Boolean.toString(modellerOutput.isSelected()));
968 Cache.applicationProperties.setProperty("EXPORT_EMBBED_BIOJSON",
969 Boolean.toString(embbedBioJSON.isSelected()));
970 jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
972 Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH",
973 Boolean.toString(autoIdWidth.isSelected()));
974 userIdWidth_actionPerformed();
975 Cache.applicationProperties.setProperty("FIGURE_FIXEDIDWIDTH",
976 userIdWidth.getText());
979 * Save Editing settings
981 Cache.applicationProperties.setProperty("AUTO_CALC_CONSENSUS",
982 Boolean.toString(autoCalculateConsCheck.isSelected()));
983 Cache.applicationProperties.setProperty("SORT_BY_TREE",
984 Boolean.toString(sortByTree.isSelected()));
985 Cache.applicationProperties.setProperty("PAD_GAPS",
986 Boolean.toString(padGaps.isSelected()));
988 if (!Platform.isJS())
990 wsPrefs.updateAndRefreshWsMenuConfig(false);
994 * Save Backups settings
996 Cache.applicationProperties.setProperty(BackupFiles.ENABLED,
997 Boolean.toString(enableBackupFiles.isSelected()));
998 int preset = getComboIntStringKey(backupfilesPresetsCombo);
999 Cache.applicationProperties.setProperty(BackupFiles.NS + "_PRESET",
1000 Integer.toString(preset));
1002 if (preset == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
1004 BackupFilesPresetEntry customBFPE = getBackupfilesCurrentEntry();
1005 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
1006 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM, customBFPE);
1007 Cache.applicationProperties.setProperty(
1008 BackupFilesPresetEntry.CUSTOMCONFIG, customBFPE.toString());
1011 BackupFilesPresetEntry savedBFPE = BackupFilesPresetEntry.backupfilesPresetEntriesValues
1013 Cache.applicationProperties.setProperty(
1014 BackupFilesPresetEntry.SAVEDCONFIG, savedBFPE.toString());
1017 * Save Memory Settings
1019 Cache.applicationProperties.setProperty(
1020 MemorySetting.CUSTOMISED_SETTINGS,
1021 Boolean.toString(customiseMemorySetting.isSelected()));
1022 Cache.applicationProperties.setProperty(MemorySetting.MEMORY_JVMMEMPC,
1023 Integer.toString(jvmMemoryPercentSlider.getValue()));
1024 Cache.applicationProperties.setProperty(MemorySetting.MEMORY_JVMMEMMAX,
1025 jvmMemoryMaxTextField.getText());
1028 * save and close Preferences
1031 Cache.saveProperties();
1032 Desktop.instance.doConfigureStructurePrefs();
1035 frame.setClosed(true);
1036 } catch (Exception ex)
1041 public void saveProxySettings()
1043 String newProxyType = customProxy.isSelected() ? Cache.PROXYTYPE_CUSTOM
1044 : noProxy.isSelected() ? Cache.PROXYTYPE_NONE
1045 : Cache.PROXYTYPE_SYSTEM;
1046 Cache.applicationProperties.setProperty("USE_PROXY", newProxyType);
1047 Cache.setOrRemove("PROXY_SERVER", proxyServerHttpTB.getText());
1048 Cache.setOrRemove("PROXY_PORT", proxyPortHttpTB.getText());
1049 Cache.setOrRemove("PROXY_SERVER_HTTPS", proxyServerHttpsTB.getText());
1050 Cache.setOrRemove("PROXY_PORT_HTTPS", proxyPortHttpsTB.getText());
1051 Cache.setOrRemove("PROXY_AUTH",
1052 Boolean.toString(proxyAuth.isSelected()));
1053 Cache.setOrRemove("PROXY_AUTH_USERNAME", proxyAuthUsernameTB.getText());
1054 Cache.proxyAuthPassword = proxyAuthPasswordPB.getPassword();
1055 Cache.setProxyPropertiesFromPreferences(previousProxyType);
1056 if (newProxyType.equals(Cache.PROXYTYPE_CUSTOM)
1057 || !newProxyType.equals(previousProxyType))
1059 // force a re-lookup of ws if proxytype is custom or has changed
1062 previousProxyType = newProxyType;
1066 * Do any necessary validation before saving settings. Return focus to the
1067 * first tab which fails validation.
1071 private boolean validateSettings()
1073 if (!validateStructure())
1075 structureTab.requestFocusInWindow();
1082 protected boolean validateStructure()
1084 return validateViewerPath();
1092 public void startupFileTextfield_mouseClicked()
1094 // TODO: JAL-3048 not needed for Jalview-JS
1095 String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
1096 JalviewFileChooser chooser = JalviewFileChooser
1097 .forRead(Cache.getProperty("LAST_DIRECTORY"), fileFormat);
1098 chooser.setFileView(new JalviewFileView());
1099 chooser.setDialogTitle(
1100 MessageManager.getString("label.select_startup_file"));
1102 int value = chooser.showOpenDialog(this);
1104 if (value == JalviewFileChooser.APPROVE_OPTION)
1106 FileFormatI format = chooser.getSelectedFormat();
1109 Cache.applicationProperties.setProperty("DEFAULT_FILE_FORMAT",
1112 startupFileTextfield
1113 .setText(chooser.getSelectedFile().getAbsolutePath());
1124 public void cancel_actionPerformed(ActionEvent e)
1128 if (!Platform.isJS())
1130 wsPrefs.updateWsMenuConfig(true);
1131 wsPrefs.refreshWs_actionPerformed(e);
1133 frame.setClosed(true);
1134 } catch (Exception ex)
1146 public void annotations_actionPerformed(ActionEvent e)
1148 conservation.setEnabled(annotations.isSelected());
1149 quality.setEnabled(annotations.isSelected());
1150 identity.setEnabled(annotations.isSelected());
1151 showOccupancy.setEnabled(annotations.isSelected());
1152 showGroupConsensus.setEnabled(annotations.isSelected());
1153 showGroupConservation.setEnabled(annotations.isSelected());
1154 showConsensHistogram.setEnabled(annotations.isSelected()
1155 && (identity.isSelected() || showGroupConsensus.isSelected()));
1156 showConsensLogo.setEnabled(annotations.isSelected()
1157 && (identity.isSelected() || showGroupConsensus.isSelected()));
1161 public void newLink_actionPerformed(ActionEvent e)
1163 GSequenceLink link = new GSequenceLink();
1164 boolean valid = false;
1167 if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
1168 MessageManager.getString("label.new_sequence_url_link"),
1169 JvOptionPane.OK_CANCEL_OPTION, -1,
1170 null) == JvOptionPane.OK_OPTION)
1172 if (link.checkValid())
1174 if (((UrlLinkTableModel) linkUrlTable.getModel())
1175 .isUniqueName(link.getName()))
1177 ((UrlLinkTableModel) linkUrlTable.getModel())
1178 .insertRow(link.getName(), link.getURL());
1183 link.notifyDuplicate();
1196 public void editLink_actionPerformed(ActionEvent e)
1198 GSequenceLink link = new GSequenceLink();
1200 int index = linkUrlTable.getSelectedRow();
1203 // button no longer enabled if row is not selected
1204 Console.debug("Edit with no row selected in linkUrlTable");
1208 int nameCol = ((UrlLinkTableModel) linkUrlTable.getModel())
1210 int urlCol = ((UrlLinkTableModel) linkUrlTable.getModel())
1212 String oldName = linkUrlTable.getValueAt(index, nameCol).toString();
1213 link.setName(oldName);
1214 link.setURL(linkUrlTable.getValueAt(index, urlCol).toString());
1216 boolean valid = false;
1219 if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
1220 MessageManager.getString("label.edit_sequence_url_link"),
1221 JvOptionPane.OK_CANCEL_OPTION, -1,
1222 null) == JvOptionPane.OK_OPTION)
1224 if (link.checkValid())
1226 if ((oldName.equals(link.getName()))
1227 || (((UrlLinkTableModel) linkUrlTable.getModel())
1228 .isUniqueName(link.getName())))
1230 linkUrlTable.setValueAt(link.getName(), index, nameCol);
1231 linkUrlTable.setValueAt(link.getURL(), index, urlCol);
1236 link.notifyDuplicate();
1249 public void deleteLink_actionPerformed(ActionEvent e)
1251 int index = linkUrlTable.getSelectedRow();
1252 int modelIndex = -1;
1255 // button no longer enabled if row is not selected
1256 Console.debug("Delete with no row selected in linkUrlTable");
1261 modelIndex = linkUrlTable.convertRowIndexToModel(index);
1264 // make sure we use the model index to delete, and not the table index
1265 ((UrlLinkTableModel) linkUrlTable.getModel()).removeRow(modelIndex);
1269 public void defaultBrowser_mouseClicked(MouseEvent e)
1271 // TODO: JAL-3048 not needed for j2s
1272 if (!Platform.isJS()) // BH 2019
1279 JFileChooser chooser = new JFileChooser(".");
1280 chooser.setDialogTitle(
1281 MessageManager.getString("label.select_default_browser"));
1283 int value = chooser.showOpenDialog(this);
1285 if (value == JFileChooser.APPROVE_OPTION)
1287 defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath());
1296 * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event
1300 protected void showunconserved_actionPerformed(ActionEvent e)
1302 // TODO Auto-generated method stub
1303 super.showunconserved_actionPerformed(e);
1306 public static List<String> getGroupURLLinks()
1308 return groupURLLinks;
1312 public void minColour_actionPerformed(JPanel panel)
1314 JalviewColourChooser.showColourChooser(this,
1315 MessageManager.getString("label.select_colour_minimum_value"),
1320 public void maxColour_actionPerformed(JPanel panel)
1322 JalviewColourChooser.showColourChooser(this,
1323 MessageManager.getString("label.select_colour_maximum_value"),
1328 public void gapColour_actionPerformed(JPanel gap)
1330 if (!useLegacyGap.isSelected())
1332 JalviewColourChooser.showColourChooser(this,
1333 MessageManager.getString("label.select_gap_colour"), gap);
1338 public void hiddenColour_actionPerformed(JPanel hidden)
1340 JalviewColourChooser.showColourChooser(this,
1341 MessageManager.getString("label.select_hidden_colour"), hidden);
1345 protected void useLegacyGaps_actionPerformed(ActionEvent e)
1347 boolean enabled = useLegacyGap.isSelected();
1350 gapColour.setBackground(
1351 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_LEGACY_GAP);
1355 gapColour.setBackground(
1356 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP);
1358 gapColour.setEnabled(!enabled);
1359 gapLabel.setEnabled(!enabled);
1363 protected void resetOvDefaults_actionPerformed(ActionEvent e)
1365 useLegacyGap.setSelected(false);
1366 useLegacyGaps_actionPerformed(null);
1367 showHiddenAtStart.setSelected(false);
1368 hiddenColour.setBackground(
1369 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_HIDDEN);
1373 protected void userIdWidth_actionPerformed()
1377 String val = userIdWidth.getText().trim();
1378 if (val.length() > 0)
1380 Integer iw = Integer.parseInt(val);
1381 if (iw.intValue() < 12)
1383 throw new NumberFormatException();
1385 userIdWidth.setText(iw.toString());
1387 } catch (NumberFormatException x)
1389 userIdWidth.setText("");
1390 JvOptionPane.showInternalMessageDialog(Desktop.desktop,
1392 .getString("warn.user_defined_width_requirements"),
1393 MessageManager.getString("label.invalid_id_column_width"),
1394 JvOptionPane.WARNING_MESSAGE);
1399 protected void autoIdWidth_actionPerformed()
1401 userIdWidth.setEnabled(!autoIdWidth.isSelected());
1402 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
1406 * Returns true if structure viewer path is to a valid executable, else shows
1407 * an error dialog. Does nothing if the path is empty, as is the case for Jmol
1408 * (built in to Jalview) or when Jalview is left to try default paths.
1410 private boolean validateViewerPath()
1412 if (structureViewerPath.getText().trim().length() > 0)
1414 File f = new File(structureViewerPath.getText());
1415 if (!f.canExecute())
1417 JvOptionPane.showInternalMessageDialog(Desktop.desktop,
1418 MessageManager.getString("label.invalid_viewer_path"),
1419 MessageManager.getString("label.invalid_viewer_path"),
1420 JvOptionPane.ERROR_MESSAGE);
1428 * If Chimera or ChimeraX or Pymol is selected, check it can be found on
1429 * default or user-specified path, if not show a warning/help dialog
1432 protected void structureViewer_actionPerformed(String selectedItem)
1434 if (selectedItem.equals(ViewerType.JMOL.name()))
1436 structureViewerPath.setEnabled(false);
1437 structureViewerPathLabel.setEnabled(false);
1440 boolean found = false;
1441 structureViewerPath.setEnabled(true);
1442 structureViewerPathLabel.setEnabled(true);
1443 structureViewerPathLabel.setText(MessageManager
1444 .formatMessage("label.viewer_path", selectedItem));
1447 * Try user-specified and standard paths for structure viewer executable
1449 String viewerPath = "";
1450 List<String> paths = null;
1453 ViewerType viewerType = ViewerType.valueOf(selectedItem);
1460 viewerPath = Cache.getDefault(CHIMERA_PATH, "");
1461 paths = StructureManager.getChimeraPaths(false);
1464 viewerPath = Cache.getDefault(CHIMERAX_PATH, "");
1465 paths = StructureManager.getChimeraPaths(true);
1468 viewerPath = Cache.getDefault(PYMOL_PATH, "");
1469 paths = PymolManager.getPymolPaths();
1472 } catch (IllegalArgumentException e)
1474 // only valid entries should be in the drop-down
1476 structureViewerPath.setText(viewerPath);
1478 paths.add(0, structureViewerPath.getText());
1479 for (String path : paths)
1481 if (new File(path.trim()).canExecute())
1490 String[] options = { "OK", "Help" };
1491 int showHelp = JvOptionPane.showInternalOptionDialog(Desktop.desktop,
1492 JvSwingUtils.wrapTooltip(true,
1493 MessageManager.getString("label.viewer_missing")),
1494 "", JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE,
1495 null, options, options[0]);
1497 if (showHelp == JvOptionPane.NO_OPTION)
1499 this.selectTab(Preferences.TabRef.STRUCTURE_TAB, null);
1502 Help.showHelpWindow(HelpId.StructureViewer);
1503 } catch (HelpSetException e)
1505 e.printStackTrace();
1508 else if (showHelp == JvOptionPane.OK_OPTION)
1510 this.selectTab(Preferences.TabRef.STRUCTURE_TAB, null);
1511 CompletableFuture<Void> cf = CompletableFuture.runAsync(() -> {
1514 for (int i = 0; i < 3; i++)
1516 structureViewerPath.setBackground(Color.PINK);
1518 structureViewerPath.setBackground(Color.WHITE);
1521 } catch (InterruptedException e)
1529 public class OptionsParam
1531 private String name;
1533 private String code;
1535 public OptionsParam(String name, String code)
1541 public String getName()
1546 public void setName(String name)
1551 public String getCode()
1556 public void setCode(String code)
1562 public String toString()
1568 public boolean equals(Object that)
1570 if (!(that instanceof OptionsParam))
1574 return this.code.equalsIgnoreCase(((OptionsParam) that).code);
1578 public int hashCode()
1580 return name.hashCode() + code.hashCode();
1584 private class UrlListSelectionHandler implements ListSelectionListener
1588 public void valueChanged(ListSelectionEvent e)
1590 ListSelectionModel lsm = (ListSelectionModel) e.getSource();
1592 int index = lsm.getMinSelectionIndex();
1595 // no selection, so disable delete/edit buttons
1596 editLink.setEnabled(false);
1597 deleteLink.setEnabled(false);
1600 int modelIndex = linkUrlTable.convertRowIndexToModel(index);
1602 // enable/disable edit and delete link buttons
1603 if (((UrlLinkTableModel) linkUrlTable.getModel())
1604 .isRowDeletable(modelIndex))
1606 deleteLink.setEnabled(true);
1610 deleteLink.setEnabled(false);
1613 if (((UrlLinkTableModel) linkUrlTable.getModel())
1614 .isRowEditable(modelIndex))
1616 editLink.setEnabled(true);
1620 editLink.setEnabled(false);