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.FileFormatI;
28 import jalview.io.JalviewFileChooser;
29 import jalview.io.JalviewFileView;
30 import jalview.jbgui.GPreferences;
31 import jalview.jbgui.GSequenceLink;
32 import jalview.schemes.ColourSchemeI;
33 import jalview.schemes.ColourSchemes;
34 import jalview.schemes.ResidueColourScheme;
35 import jalview.urls.UrlLinkTableModel;
36 import jalview.urls.api.UrlProviderFactoryI;
37 import jalview.urls.api.UrlProviderI;
38 import jalview.urls.desktop.DesktopUrlProviderFactory;
39 import jalview.util.MessageManager;
40 import jalview.util.Platform;
41 import jalview.util.UrlConstants;
42 import jalview.ws.sifts.SiftsSettings;
44 import java.awt.BorderLayout;
45 import java.awt.Color;
46 import java.awt.Component;
47 import java.awt.Dimension;
49 import java.awt.event.ActionEvent;
50 import java.awt.event.ActionListener;
51 import java.awt.event.MouseEvent;
53 import java.util.ArrayList;
54 import java.util.List;
56 import javax.help.HelpSetException;
57 import javax.swing.JColorChooser;
58 import javax.swing.JFileChooser;
59 import javax.swing.JInternalFrame;
60 import javax.swing.JPanel;
61 import javax.swing.ListSelectionModel;
62 import javax.swing.RowFilter;
63 import javax.swing.RowSorter;
64 import javax.swing.SortOrder;
65 import javax.swing.event.DocumentEvent;
66 import javax.swing.event.DocumentListener;
67 import javax.swing.event.ListSelectionEvent;
68 import javax.swing.event.ListSelectionListener;
69 import javax.swing.table.TableCellRenderer;
70 import javax.swing.table.TableColumn;
71 import javax.swing.table.TableModel;
72 import javax.swing.table.TableRowSorter;
74 import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
82 public class Preferences extends GPreferences
84 public static final String ENABLE_SPLIT_FRAME = "ENABLE_SPLIT_FRAME";
86 public static final String SCALE_PROTEIN_TO_CDNA = "SCALE_PROTEIN_TO_CDNA";
88 public static final String DEFAULT_COLOUR = "DEFAULT_COLOUR";
90 public static final String DEFAULT_COLOUR_PROT = "DEFAULT_COLOUR_PROT";
92 public static final String DEFAULT_COLOUR_NUC = "DEFAULT_COLOUR_NUC";
94 public static final String ADD_TEMPFACT_ANN = "ADD_TEMPFACT_ANN";
96 public static final String ADD_SS_ANN = "ADD_SS_ANN";
98 public static final String USE_RNAVIEW = "USE_RNAVIEW";
100 public static final String STRUCT_FROM_PDB = "STRUCT_FROM_PDB";
102 public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY";
104 public static final String CHIMERA_PATH = "CHIMERA_PATH";
106 public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS";
108 public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE";
110 public static final String SHOW_OCCUPANCY = "SHOW_OCCUPANCY";
112 public static final String SHOW_OV_HIDDEN_AT_START = "SHOW_OV_HIDDEN_AT_START";
114 public static final String USE_LEGACY_GAP = "USE_LEGACY_GAP";
116 private static final int MIN_FONT_SIZE = 1;
118 private static final int MAX_FONT_SIZE = 30;
120 private static final Color OVERVIEW_DEFAULT_GAP = Color.lightGray;
122 private static final Color OVERVIEW_DEFAULT_LEGACY_GAP = Color.white;
124 private static final Color OVERVIEW_DEFAULT_HIDDEN = Color.darkGray
128 * Holds name and link separated with | character. Sequence ID must be
129 * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$
131 public static UrlProviderI sequenceUrlLinks;
133 public static UrlLinkTableModel dataModel;
136 * Holds name and link separated with | character. Sequence IDS and Sequences
137 * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and
138 * $SEQUENCES$ or $SEQUENCES=/.possible | chars ./=$ and separation character
139 * for first and second token specified after a pipe character at end |,|.
140 * (TODO: proper escape for using | to separate ids or sequences
143 public static List<String> groupURLLinks;
146 // get links selected to be in the menu (SEQUENCE_LINKS)
147 // and links entered by the user but not selected (STORED_LINKS)
148 String inMenuString = Cache.getDefault("SEQUENCE_LINKS", "");
149 String notInMenuString = Cache.getDefault("STORED_LINKS", "");
150 String defaultUrl = Cache.getDefault("DEFAULT_URL",
151 UrlConstants.DEFAULT_LABEL);
153 // if both links lists are empty, add the DEFAULT_URL link
154 // otherwise we assume the default link is in one of the lists
155 if (inMenuString.isEmpty() && notInMenuString.isEmpty())
157 inMenuString = UrlConstants.DEFAULT_STRING;
159 UrlProviderFactoryI factory = new DesktopUrlProviderFactory(defaultUrl,
160 inMenuString, notInMenuString);
161 sequenceUrlLinks = factory.createUrlProvider();
162 dataModel = new UrlLinkTableModel(sequenceUrlLinks);
165 * TODO: reformulate groupURL encoding so two or more can be stored in the
166 * .properties file as '|' separated strings
169 groupURLLinks = new ArrayList<>();
172 JInternalFrame frame;
174 DasSourceBrowser dasSource;
176 private WsPreferences wsPrefs;
178 private OptionsParam promptEachTimeOpt = new OptionsParam(
179 MessageManager.getString("label.prompt_each_time"),
182 private OptionsParam lineArtOpt = new OptionsParam(
183 MessageManager.getString("label.lineart"), "Lineart");
185 private OptionsParam textOpt = new OptionsParam(
186 MessageManager.getString("action.text"), "Text");
189 * Creates a new Preferences object.
194 frame = new JInternalFrame();
195 frame.setContentPane(this);
196 dasSource = new DasSourceBrowser();
197 dasTab.add(dasSource, BorderLayout.CENTER);
198 wsPrefs = new WsPreferences();
199 wsTab.add(wsPrefs, BorderLayout.CENTER);
200 int width = 500, height = 450;
201 new jalview.util.Platform();
202 if (Platform.isAMac())
208 Desktop.addInternalFrame(frame,
209 MessageManager.getString("label.preferences"), width, height);
210 frame.setMinimumSize(new Dimension(width, height));
213 * Set Visual tab defaults
215 seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true));
216 rightAlign.setSelected(Cache.getDefault("RIGHT_ALIGN_IDS", false));
217 fullScreen.setSelected(Cache.getDefault("SHOW_FULLSCREEN", false));
218 annotations.setSelected(Cache.getDefault("SHOW_ANNOTATIONS", true));
220 conservation.setSelected(Cache.getDefault("SHOW_CONSERVATION", true));
221 quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));
222 identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
223 openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false));
225 .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
226 showOccupancy.setSelected(Cache.getDefault(SHOW_OCCUPANCY, false));
228 .setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS", false));
229 showGroupConservation.setSelected(
230 Cache.getDefault("SHOW_GROUP_CONSERVATION", false));
231 showConsensHistogram.setSelected(
232 Cache.getDefault("SHOW_CONSENSUS_HISTOGRAM", true));
234 .setSelected(Cache.getDefault("SHOW_CONSENSUS_LOGO", false));
236 .setSelected(Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true));
238 .setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP", true));
240 String[] fonts = java.awt.GraphicsEnvironment
241 .getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
242 for (int i = 0; i < fonts.length; i++)
244 fontNameCB.addItem(fonts[i]);
247 for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++)
249 fontSizeCB.addItem(i + "");
252 fontStyleCB.addItem("plain");
253 fontStyleCB.addItem("bold");
254 fontStyleCB.addItem("italic");
256 fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif"));
257 fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10"));
258 fontStyleCB.setSelectedItem(
259 Cache.getDefault("FONT_STYLE", Font.PLAIN + ""));
261 smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", false));
263 .setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA, false));
265 idItalics.setSelected(Cache.getDefault("ID_ITALICS", true));
267 wrap.setSelected(Cache.getDefault("WRAP_ALIGNMENT", false));
269 gapSymbolCB.addItem("-");
270 gapSymbolCB.addItem(".");
272 gapSymbolCB.setSelectedItem(Cache.getDefault("GAP_SYMBOL", "-"));
274 sortby.addItem("No sort");
275 sortby.addItem("Id");
276 sortby.addItem("Pairwise Identity");
277 sortby.setSelectedItem(Cache.getDefault("SORT_ALIGNMENT", "No sort"));
279 sortAnnBy.addItem(SequenceAnnotationOrder.NONE.toString());
281 .addItem(SequenceAnnotationOrder.SEQUENCE_AND_LABEL.toString());
283 .addItem(SequenceAnnotationOrder.LABEL_AND_SEQUENCE.toString());
284 SequenceAnnotationOrder savedSort = SequenceAnnotationOrder
285 .valueOf(Cache.getDefault(SORT_ANNOTATIONS,
286 SequenceAnnotationOrder.NONE.name()));
287 sortAnnBy.setSelectedItem(savedSort.toString());
289 sortAutocalc.addItem("Autocalculated first");
290 sortAutocalc.addItem("Autocalculated last");
291 final boolean showAbove = Cache.getDefault(SHOW_AUTOCALC_ABOVE, true);
292 sortAutocalc.setSelectedItem(showAbove ? sortAutocalc.getItemAt(0)
293 : sortAutocalc.getItemAt(1));
295 .setSelected(Cache.getDefault("SHOW_STARTUP_FILE", true));
296 startupFileTextfield.setText(Cache.getDefault("STARTUP_FILE",
297 Cache.getDefault("www.jalview.org", "http://www.jalview.org")
298 + "/examples/exampleFile_2_3.jar"));
301 * Set Colours tab defaults
303 protColour.addItem(ResidueColourScheme.NONE);
304 nucColour.addItem(ResidueColourScheme.NONE);
305 for (ColourSchemeI cs : ColourSchemes.getInstance().getColourSchemes())
307 String name = cs.getSchemeName();
308 protColour.addItem(name);
309 nucColour.addItem(name);
311 String oldProp = Cache.getDefault(DEFAULT_COLOUR,
312 ResidueColourScheme.NONE);
313 String newProp = Cache.getDefault(DEFAULT_COLOUR_PROT, null);
314 protColour.setSelectedItem(newProp != null ? newProp : oldProp);
315 newProp = Cache.getDefault(DEFAULT_COLOUR_NUC, null);
316 nucColour.setSelectedItem(newProp != null ? newProp : oldProp);
317 minColour.setBackground(
318 Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN", Color.orange));
319 maxColour.setBackground(
320 Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX", Color.red));
323 * Set overview panel defaults
325 gapColour.setBackground(
326 Cache.getDefaultColour("GAP_COLOUR", OVERVIEW_DEFAULT_GAP));
327 hiddenColour.setBackground(
328 Cache.getDefaultColour("HIDDEN_COLOUR",
329 OVERVIEW_DEFAULT_HIDDEN));
330 useLegacyGap.setSelected(Cache.getDefault("USE_LEGACY_GAP", false));
331 gapLabel.setEnabled(!useLegacyGap.isSelected());
332 gapColour.setEnabled(!useLegacyGap.isSelected());
334 .setSelected(Cache.getDefault("SHOW_OV_HIDDEN_AT_START", true));
337 * Set Structure tab defaults.
339 final boolean structSelected = Cache.getDefault(STRUCT_FROM_PDB, false);
340 structFromPdb.setSelected(structSelected);
341 useRnaView.setSelected(Cache.getDefault(USE_RNAVIEW, false));
342 useRnaView.setEnabled(structSelected);
343 addSecondaryStructure.setSelected(Cache.getDefault(ADD_SS_ANN, false));
344 addSecondaryStructure.setEnabled(structSelected);
345 addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, false));
346 addTempFactor.setEnabled(structSelected);
347 structViewer.setSelectedItem(
348 Cache.getDefault(STRUCTURE_DISPLAY, ViewerType.JMOL.name()));
349 chimeraPath.setText(Cache.getDefault(CHIMERA_PATH, ""));
350 chimeraPath.addActionListener(new ActionListener()
353 public void actionPerformed(ActionEvent e)
355 validateChimeraPath();
359 if (Cache.getDefault("MAP_WITH_SIFTS", false))
361 siftsMapping.setSelected(true);
365 nwMapping.setSelected(true);
369 .setMapWithSifts(Cache.getDefault("MAP_WITH_SIFTS", false));
372 * Set Connections tab defaults
376 linkUrlTable.setModel(dataModel);
377 final TableRowSorter<TableModel> sorter = new TableRowSorter<>(
378 linkUrlTable.getModel());
379 linkUrlTable.setRowSorter(sorter);
380 List<RowSorter.SortKey> sortKeys = new ArrayList<>();
382 UrlLinkTableModel m = (UrlLinkTableModel) linkUrlTable.getModel();
383 sortKeys.add(new RowSorter.SortKey(m.getPrimaryColumn(),
384 SortOrder.DESCENDING));
385 sortKeys.add(new RowSorter.SortKey(m.getSelectedColumn(),
386 SortOrder.DESCENDING));
388 new RowSorter.SortKey(m.getNameColumn(), SortOrder.ASCENDING));
390 sorter.setSortKeys(sortKeys);
394 ActionListener onReset;
395 onReset = new ActionListener()
398 public void actionPerformed(ActionEvent e)
400 filterTB.setText("");
401 sorter.setRowFilter(RowFilter.regexFilter(""));
405 doReset.addActionListener(onReset);
407 // filter to display only custom urls
408 final RowFilter<TableModel, Object> customUrlFilter = new RowFilter<TableModel, Object>()
411 public boolean include(
412 Entry<? extends TableModel, ? extends Object> entry)
414 return ((UrlLinkTableModel) entry.getModel()).isUserEntry(entry);
418 final TableRowSorter<TableModel> customSorter = new TableRowSorter<>(
419 linkUrlTable.getModel());
420 customSorter.setRowFilter(customUrlFilter);
422 ActionListener onCustomOnly;
423 onCustomOnly = new ActionListener()
426 public void actionPerformed(ActionEvent e)
428 filterTB.setText("");
429 sorter.setRowFilter(customUrlFilter);
432 userOnly.addActionListener(onCustomOnly);
434 filterTB.getDocument().addDocumentListener(new DocumentListener()
436 String caseInsensitiveFlag = "(?i)";
439 public void changedUpdate(DocumentEvent e)
441 sorter.setRowFilter(RowFilter
442 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
446 public void removeUpdate(DocumentEvent e)
448 sorter.setRowFilter(RowFilter
449 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
453 public void insertUpdate(DocumentEvent e)
455 sorter.setRowFilter(RowFilter
456 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
460 // set up list selection functionality
461 linkUrlTable.getSelectionModel()
462 .addListSelectionListener(new UrlListSelectionHandler());
464 // set up radio buttons
465 int onClickCol = ((UrlLinkTableModel) linkUrlTable.getModel())
467 String onClickName = linkUrlTable.getColumnName(onClickCol);
468 linkUrlTable.getColumn(onClickName)
469 .setCellRenderer(new RadioButtonRenderer());
470 linkUrlTable.getColumn(onClickName)
471 .setCellEditor(new RadioButtonEditor());
473 // get boolean columns and resize those to min possible
474 for (int column = 0; column < linkUrlTable.getColumnCount(); column++)
476 if (linkUrlTable.getModel().getColumnClass(column)
477 .equals(Boolean.class))
479 TableColumn tableColumn = linkUrlTable.getColumnModel()
481 int preferredWidth = tableColumn.getMinWidth();
483 TableCellRenderer cellRenderer = linkUrlTable.getCellRenderer(0,
485 Component c = linkUrlTable.prepareRenderer(cellRenderer, 0, column);
486 int cwidth = c.getPreferredSize().width
487 + linkUrlTable.getIntercellSpacing().width;
488 preferredWidth = Math.max(preferredWidth, cwidth);
490 tableColumn.setPreferredWidth(preferredWidth);
494 useProxy.setSelected(Cache.getDefault("USE_PROXY", false));
495 useProxy_actionPerformed(); // make sure useProxy is correctly initialised
496 proxyServerTB.setText(Cache.getDefault("PROXY_SERVER", ""));
497 proxyPortTB.setText(Cache.getDefault("PROXY_PORT", ""));
499 defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
501 usagestats.setSelected(Cache.getDefault("USAGESTATS", false));
502 // note antisense here: default is true
504 .setSelected(Cache.getProperty("NOQUESTIONNAIRES") == null);
505 versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true));
508 * Set Output tab defaults
510 epsRendering.addItem(promptEachTimeOpt);
511 epsRendering.addItem(lineArtOpt);
512 epsRendering.addItem(textOpt);
513 String defaultEPS = Cache.getDefault("EPS_RENDERING",
515 if (defaultEPS.equalsIgnoreCase("Text"))
517 epsRendering.setSelectedItem(textOpt);
519 else if (defaultEPS.equalsIgnoreCase("Lineart"))
521 epsRendering.setSelectedItem(lineArtOpt);
525 epsRendering.setSelectedItem(promptEachTimeOpt);
527 autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
528 userIdWidth.setEnabled(!autoIdWidth.isSelected());
529 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
530 Integer wi = Cache.getIntegerProperty("FIGURE_USERIDWIDTH");
531 userIdWidth.setText(wi == null ? "" : wi.toString());
532 blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
533 clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
534 fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
535 msfjv.setSelected(Cache.getDefault("MSF_JVSUFFIX", true));
536 pfamjv.setSelected(Cache.getDefault("PFAM_JVSUFFIX", true));
537 pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true));
538 pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true));
539 modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false));
541 .setSelected(Cache.getDefault("EXPORT_EMBBED_BIOJSON", true));
544 * Set Editing tab defaults
546 autoCalculateConsCheck
547 .setSelected(Cache.getDefault("AUTO_CALC_CONSENSUS", true));
548 padGaps.setSelected(Cache.getDefault("PAD_GAPS", false));
549 sortByTree.setSelected(Cache.getDefault("SORT_BY_TREE", false));
551 annotations_actionPerformed(null); // update the display of the annotation
556 * Save user selections on the Preferences tabs to the Cache and write out to
562 public void ok_actionPerformed(ActionEvent e)
564 if (!validateSettings())
570 * Save Visual settings
572 Cache.applicationProperties.setProperty("SHOW_JVSUFFIX",
573 Boolean.toString(seqLimit.isSelected()));
574 Cache.applicationProperties.setProperty("RIGHT_ALIGN_IDS",
575 Boolean.toString(rightAlign.isSelected()));
576 Cache.applicationProperties.setProperty("SHOW_FULLSCREEN",
577 Boolean.toString(fullScreen.isSelected()));
578 Cache.applicationProperties.setProperty("SHOW_OVERVIEW",
579 Boolean.toString(openoverv.isSelected()));
580 Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
581 Boolean.toString(annotations.isSelected()));
582 Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
583 Boolean.toString(conservation.isSelected()));
584 Cache.applicationProperties.setProperty("SHOW_QUALITY",
585 Boolean.toString(quality.isSelected()));
586 Cache.applicationProperties.setProperty("SHOW_IDENTITY",
587 Boolean.toString(identity.isSelected()));
589 Cache.applicationProperties.setProperty("GAP_SYMBOL",
590 gapSymbolCB.getSelectedItem().toString());
592 Cache.applicationProperties.setProperty("FONT_NAME",
593 fontNameCB.getSelectedItem().toString());
594 Cache.applicationProperties.setProperty("FONT_STYLE",
595 fontStyleCB.getSelectedItem().toString());
596 Cache.applicationProperties.setProperty("FONT_SIZE",
597 fontSizeCB.getSelectedItem().toString());
599 Cache.applicationProperties.setProperty("ID_ITALICS",
600 Boolean.toString(idItalics.isSelected()));
601 Cache.applicationProperties.setProperty("SHOW_UNCONSERVED",
602 Boolean.toString(showUnconserved.isSelected()));
603 Cache.applicationProperties.setProperty(SHOW_OCCUPANCY,
604 Boolean.toString(showOccupancy.isSelected()));
605 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSENSUS",
606 Boolean.toString(showGroupConsensus.isSelected()));
607 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSERVATION",
608 Boolean.toString(showGroupConservation.isSelected()));
609 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_HISTOGRAM",
610 Boolean.toString(showConsensHistogram.isSelected()));
611 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_LOGO",
612 Boolean.toString(showConsensLogo.isSelected()));
613 Cache.applicationProperties.setProperty("ANTI_ALIAS",
614 Boolean.toString(smoothFont.isSelected()));
615 Cache.applicationProperties.setProperty(SCALE_PROTEIN_TO_CDNA,
616 Boolean.toString(scaleProteinToCdna.isSelected()));
617 Cache.applicationProperties.setProperty("SHOW_NPFEATS_TOOLTIP",
618 Boolean.toString(showNpTooltip.isSelected()));
619 Cache.applicationProperties.setProperty("SHOW_DBREFS_TOOLTIP",
620 Boolean.toString(showDbRefTooltip.isSelected()));
622 Cache.applicationProperties.setProperty("WRAP_ALIGNMENT",
623 Boolean.toString(wrap.isSelected()));
625 Cache.applicationProperties.setProperty("STARTUP_FILE",
626 startupFileTextfield.getText());
627 Cache.applicationProperties.setProperty("SHOW_STARTUP_FILE",
628 Boolean.toString(startupCheckbox.isSelected()));
630 Cache.applicationProperties.setProperty("SORT_ALIGNMENT",
631 sortby.getSelectedItem().toString());
633 // convert description of sort order to enum name for save
634 SequenceAnnotationOrder annSortOrder = SequenceAnnotationOrder
635 .forDescription(sortAnnBy.getSelectedItem().toString());
636 if (annSortOrder != null)
638 Cache.applicationProperties.setProperty(SORT_ANNOTATIONS,
639 annSortOrder.name());
642 final boolean showAutocalcFirst = sortAutocalc.getSelectedIndex() == 0;
643 Cache.applicationProperties.setProperty(SHOW_AUTOCALC_ABOVE,
644 Boolean.valueOf(showAutocalcFirst).toString());
647 * Save Colours settings
649 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_PROT,
650 protColour.getSelectedItem().toString());
651 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_NUC,
652 nucColour.getSelectedItem().toString());
653 Cache.setColourProperty("ANNOTATIONCOLOUR_MIN",
654 minColour.getBackground());
655 Cache.setColourProperty("ANNOTATIONCOLOUR_MAX",
656 maxColour.getBackground());
659 * Save Overview settings
661 Cache.setColourProperty("GAP_COLOUR", gapColour.getBackground());
662 Cache.setColourProperty("HIDDEN_COLOUR", hiddenColour.getBackground());
663 Cache.applicationProperties.setProperty(USE_LEGACY_GAP,
664 Boolean.toString(useLegacyGap.isSelected()));
665 Cache.applicationProperties.setProperty(SHOW_OV_HIDDEN_AT_START,
666 Boolean.toString(showHiddenAtStart.isSelected()));
669 * Save Structure settings
671 Cache.applicationProperties.setProperty(ADD_TEMPFACT_ANN,
672 Boolean.toString(addTempFactor.isSelected()));
673 Cache.applicationProperties.setProperty(ADD_SS_ANN,
674 Boolean.toString(addSecondaryStructure.isSelected()));
675 Cache.applicationProperties.setProperty(USE_RNAVIEW,
676 Boolean.toString(useRnaView.isSelected()));
677 Cache.applicationProperties.setProperty(STRUCT_FROM_PDB,
678 Boolean.toString(structFromPdb.isSelected()));
679 Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY,
680 structViewer.getSelectedItem().toString());
681 Cache.setOrRemove(CHIMERA_PATH, chimeraPath.getText());
682 Cache.applicationProperties.setProperty("MAP_WITH_SIFTS",
683 Boolean.toString(siftsMapping.isSelected()));
684 SiftsSettings.setMapWithSifts(siftsMapping.isSelected());
687 * Save Output settings
689 Cache.applicationProperties.setProperty("EPS_RENDERING",
690 ((OptionsParam) epsRendering.getSelectedItem()).getCode());
693 * Save Connections settings
695 Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
697 jalview.util.BrowserLauncher.resetBrowser();
699 // save user-defined and selected links
700 String menuLinks = sequenceUrlLinks.writeUrlsAsString(true);
701 if (menuLinks.isEmpty())
703 Cache.applicationProperties.remove("SEQUENCE_LINKS");
707 Cache.applicationProperties.setProperty("SEQUENCE_LINKS",
708 menuLinks.toString());
711 String nonMenuLinks = sequenceUrlLinks.writeUrlsAsString(false);
712 if (nonMenuLinks.isEmpty())
714 Cache.applicationProperties.remove("STORED_LINKS");
718 Cache.applicationProperties.setProperty("STORED_LINKS",
719 nonMenuLinks.toString());
722 Cache.applicationProperties.setProperty("DEFAULT_URL",
723 sequenceUrlLinks.getPrimaryUrlId());
725 Cache.applicationProperties.setProperty("USE_PROXY",
726 Boolean.toString(useProxy.isSelected()));
728 Cache.setOrRemove("PROXY_SERVER", proxyServerTB.getText());
730 Cache.setOrRemove("PROXY_PORT", proxyPortTB.getText());
732 if (useProxy.isSelected())
734 System.setProperty("http.proxyHost", proxyServerTB.getText());
735 System.setProperty("http.proxyPort", proxyPortTB.getText());
739 System.setProperty("http.proxyHost", "");
740 System.setProperty("http.proxyPort", "");
742 Cache.setProperty("VERSION_CHECK",
743 Boolean.toString(versioncheck.isSelected()));
744 if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
746 // default is false - we only set this if the user has actively agreed
747 Cache.setProperty("USAGESTATS",
748 Boolean.toString(usagestats.isSelected()));
750 if (!questionnaire.isSelected())
752 Cache.setProperty("NOQUESTIONNAIRES", "true");
756 // special - made easy to edit a property file to disable questionnaires
757 // by just adding the given line
758 Cache.removeProperty("NOQUESTIONNAIRES");
762 * Save Output settings
764 Cache.applicationProperties.setProperty("BLC_JVSUFFIX",
765 Boolean.toString(blcjv.isSelected()));
766 Cache.applicationProperties.setProperty("CLUSTAL_JVSUFFIX",
767 Boolean.toString(clustaljv.isSelected()));
768 Cache.applicationProperties.setProperty("FASTA_JVSUFFIX",
769 Boolean.toString(fastajv.isSelected()));
770 Cache.applicationProperties.setProperty("MSF_JVSUFFIX",
771 Boolean.toString(msfjv.isSelected()));
772 Cache.applicationProperties.setProperty("PFAM_JVSUFFIX",
773 Boolean.toString(pfamjv.isSelected()));
774 Cache.applicationProperties.setProperty("PILEUP_JVSUFFIX",
775 Boolean.toString(pileupjv.isSelected()));
776 Cache.applicationProperties.setProperty("PIR_JVSUFFIX",
777 Boolean.toString(pirjv.isSelected()));
778 Cache.applicationProperties.setProperty("PIR_MODELLER",
779 Boolean.toString(modellerOutput.isSelected()));
780 Cache.applicationProperties.setProperty("EXPORT_EMBBED_BIOJSON",
781 Boolean.toString(embbedBioJSON.isSelected()));
782 jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
784 Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH",
785 Boolean.toString(autoIdWidth.isSelected()));
786 userIdWidth_actionPerformed();
787 Cache.applicationProperties.setProperty("FIGURE_USERIDWIDTH",
788 userIdWidth.getText());
791 * Save Editing settings
793 Cache.applicationProperties.setProperty("AUTO_CALC_CONSENSUS",
794 Boolean.toString(autoCalculateConsCheck.isSelected()));
795 Cache.applicationProperties.setProperty("SORT_BY_TREE",
796 Boolean.toString(sortByTree.isSelected()));
797 Cache.applicationProperties.setProperty("PAD_GAPS",
798 Boolean.toString(padGaps.isSelected()));
800 dasSource.saveProperties(Cache.applicationProperties);
801 wsPrefs.updateAndRefreshWsMenuConfig(false);
802 Cache.saveProperties();
803 Desktop.instance.doConfigureStructurePrefs();
806 frame.setClosed(true);
807 } catch (Exception ex)
813 * Do any necessary validation before saving settings. Return focus to the
814 * first tab which fails validation.
818 private boolean validateSettings()
820 if (!validateStructure())
822 structureTab.requestFocusInWindow();
829 protected boolean validateStructure()
831 return validateChimeraPath();
839 public void startupFileTextfield_mouseClicked()
841 String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
842 JalviewFileChooser chooser = JalviewFileChooser
843 .forRead(Cache.getProperty("LAST_DIRECTORY"), fileFormat);
844 chooser.setFileView(new JalviewFileView());
845 chooser.setDialogTitle(
846 MessageManager.getString("label.select_startup_file"));
848 int value = chooser.showOpenDialog(this);
850 if (value == JalviewFileChooser.APPROVE_OPTION)
852 FileFormatI format = chooser.getSelectedFormat();
855 Cache.applicationProperties.setProperty("DEFAULT_FILE_FORMAT",
859 .setText(chooser.getSelectedFile().getAbsolutePath());
870 public void cancel_actionPerformed(ActionEvent e)
874 wsPrefs.updateWsMenuConfig(true);
875 wsPrefs.refreshWs_actionPerformed(e);
876 frame.setClosed(true);
877 } catch (Exception ex)
889 public void annotations_actionPerformed(ActionEvent e)
891 conservation.setEnabled(annotations.isSelected());
892 quality.setEnabled(annotations.isSelected());
893 identity.setEnabled(annotations.isSelected());
894 showOccupancy.setEnabled(annotations.isSelected());
895 showGroupConsensus.setEnabled(annotations.isSelected());
896 showGroupConservation.setEnabled(annotations.isSelected());
897 showConsensHistogram.setEnabled(annotations.isSelected()
898 && (identity.isSelected() || showGroupConsensus.isSelected()));
899 showConsensLogo.setEnabled(annotations.isSelected()
900 && (identity.isSelected() || showGroupConsensus.isSelected()));
904 public void newLink_actionPerformed(ActionEvent e)
906 GSequenceLink link = new GSequenceLink();
907 boolean valid = false;
910 if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
911 MessageManager.getString("label.new_sequence_url_link"),
912 JvOptionPane.OK_CANCEL_OPTION, -1,
913 null) == JvOptionPane.OK_OPTION)
915 if (link.checkValid())
917 if (((UrlLinkTableModel) linkUrlTable.getModel())
918 .isUniqueName(link.getName()))
920 ((UrlLinkTableModel) linkUrlTable.getModel())
921 .insertRow(link.getName(), link.getURL());
926 link.notifyDuplicate();
939 public void editLink_actionPerformed(ActionEvent e)
941 GSequenceLink link = new GSequenceLink();
943 int index = linkUrlTable.getSelectedRow();
946 // button no longer enabled if row is not selected
947 Cache.log.debug("Edit with no row selected in linkUrlTable");
951 int nameCol = ((UrlLinkTableModel) linkUrlTable.getModel())
953 int urlCol = ((UrlLinkTableModel) linkUrlTable.getModel())
955 String oldName = linkUrlTable.getValueAt(index, nameCol).toString();
956 link.setName(oldName);
957 link.setURL(linkUrlTable.getValueAt(index, urlCol).toString());
959 boolean valid = false;
962 if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
963 MessageManager.getString("label.edit_sequence_url_link"),
964 JvOptionPane.OK_CANCEL_OPTION, -1,
965 null) == JvOptionPane.OK_OPTION)
967 if (link.checkValid())
969 if ((oldName.equals(link.getName()))
970 || (((UrlLinkTableModel) linkUrlTable.getModel())
971 .isUniqueName(link.getName())))
973 linkUrlTable.setValueAt(link.getName(), index, nameCol);
974 linkUrlTable.setValueAt(link.getURL(), index, urlCol);
979 link.notifyDuplicate();
992 public void deleteLink_actionPerformed(ActionEvent e)
994 int index = linkUrlTable.getSelectedRow();
998 // button no longer enabled if row is not selected
999 Cache.log.debug("Delete with no row selected in linkUrlTable");
1004 modelIndex = linkUrlTable.convertRowIndexToModel(index);
1007 // make sure we use the model index to delete, and not the table index
1008 ((UrlLinkTableModel) linkUrlTable.getModel()).removeRow(modelIndex);
1012 public void defaultBrowser_mouseClicked(MouseEvent e)
1014 JFileChooser chooser = new JFileChooser(".");
1015 chooser.setDialogTitle(
1016 MessageManager.getString("label.select_default_browser"));
1018 int value = chooser.showOpenDialog(this);
1020 if (value == JFileChooser.APPROVE_OPTION)
1022 defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath());
1031 * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event
1035 protected void showunconserved_actionPerformed(ActionEvent e)
1037 // TODO Auto-generated method stub
1038 super.showunconserved_actionPerformed(e);
1041 public static List<String> getGroupURLLinks()
1043 return groupURLLinks;
1047 public void minColour_actionPerformed(JPanel panel)
1049 Color col = JColorChooser.showDialog(this,
1050 MessageManager.getString("label.select_colour_minimum_value"),
1051 minColour.getBackground());
1054 panel.setBackground(col);
1060 public void maxColour_actionPerformed(JPanel panel)
1062 Color col = JColorChooser.showDialog(this,
1063 MessageManager.getString("label.select_colour_maximum_value"),
1064 maxColour.getBackground());
1067 panel.setBackground(col);
1073 public void gapColour_actionPerformed(JPanel gap)
1075 if (!useLegacyGap.isSelected())
1077 Color col = JColorChooser.showDialog(this,
1078 MessageManager.getString("label.select_gap_colour"),
1079 gapColour.getBackground());
1082 gap.setBackground(col);
1089 public void hiddenColour_actionPerformed(JPanel hidden)
1091 Color col = JColorChooser.showDialog(this,
1092 MessageManager.getString("label.select_hidden_colour"),
1093 hiddenColour.getBackground());
1096 hidden.setBackground(col);
1102 protected void useLegacyGaps_actionPerformed(ActionEvent e)
1104 boolean enabled = useLegacyGap.isSelected();
1107 gapColour.setBackground(OVERVIEW_DEFAULT_LEGACY_GAP);
1111 gapColour.setBackground(OVERVIEW_DEFAULT_GAP);
1113 gapColour.setEnabled(!enabled);
1114 gapLabel.setEnabled(!enabled);
1118 protected void resetOvDefaults_actionPerformed(ActionEvent e)
1120 useLegacyGap.setSelected(false);
1121 useLegacyGaps_actionPerformed(null);
1122 showHiddenAtStart.setSelected(true);
1123 hiddenColour.setBackground(OVERVIEW_DEFAULT_HIDDEN);
1127 protected void userIdWidth_actionPerformed()
1131 String val = userIdWidth.getText().trim();
1132 if (val.length() > 0)
1134 Integer iw = Integer.parseInt(val);
1135 if (iw.intValue() < 12)
1137 throw new NumberFormatException();
1139 userIdWidth.setText(iw.toString());
1141 } catch (NumberFormatException x)
1143 JvOptionPane.showInternalMessageDialog(Desktop.desktop,
1145 .getString("warn.user_defined_width_requirements"),
1146 MessageManager.getString("label.invalid_id_column_width"),
1147 JvOptionPane.WARNING_MESSAGE);
1148 userIdWidth.setText("");
1153 protected void autoIdWidth_actionPerformed()
1155 userIdWidth.setEnabled(!autoIdWidth.isSelected());
1156 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
1160 * Returns true if chimera path is to a valid executable, else show an error
1163 private boolean validateChimeraPath()
1165 if (chimeraPath.getText().trim().length() > 0)
1167 File f = new File(chimeraPath.getText());
1168 if (!f.canExecute())
1170 JvOptionPane.showInternalMessageDialog(Desktop.desktop,
1171 MessageManager.getString("label.invalid_chimera_path"),
1172 MessageManager.getString("label.invalid_name"),
1173 JvOptionPane.ERROR_MESSAGE);
1181 * If Chimera is selected, check it can be found on default or user-specified
1182 * path, if not show a warning/help dialog.
1185 protected void structureViewer_actionPerformed(String selectedItem)
1187 if (!selectedItem.equals(ViewerType.CHIMERA.name()))
1191 boolean found = false;
1194 * Try user-specified and standard paths for Chimera executable.
1196 List<String> paths = StructureManager.getChimeraPaths();
1197 paths.add(0, chimeraPath.getText());
1198 for (String path : paths)
1200 if (new File(path.trim()).canExecute())
1208 String[] options = { "OK", "Help" };
1209 int showHelp = JvOptionPane.showInternalOptionDialog(Desktop.desktop,
1210 JvSwingUtils.wrapTooltip(true,
1211 MessageManager.getString("label.chimera_missing")),
1212 "", JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE,
1213 null, options, options[0]);
1214 if (showHelp == JvOptionPane.NO_OPTION)
1218 Help.showHelpWindow(HelpId.StructureViewer);
1219 } catch (HelpSetException e)
1221 e.printStackTrace();
1227 public class OptionsParam
1229 private String name;
1231 private String code;
1233 public OptionsParam(String name, String code)
1239 public String getName()
1244 public void setName(String name)
1249 public String getCode()
1254 public void setCode(String code)
1260 public String toString()
1266 public boolean equals(Object that)
1268 if (!(that instanceof OptionsParam))
1272 return this.code.equalsIgnoreCase(((OptionsParam) that).code);
1276 public int hashCode()
1278 return name.hashCode() + code.hashCode();
1282 private class UrlListSelectionHandler implements ListSelectionListener
1286 public void valueChanged(ListSelectionEvent e)
1288 ListSelectionModel lsm = (ListSelectionModel) e.getSource();
1290 int index = lsm.getMinSelectionIndex();
1293 // no selection, so disable delete/edit buttons
1294 editLink.setEnabled(false);
1295 deleteLink.setEnabled(false);
1298 int modelIndex = linkUrlTable.convertRowIndexToModel(index);
1300 // enable/disable edit and delete link buttons
1301 if (((UrlLinkTableModel) linkUrlTable.getModel())
1302 .isRowDeletable(modelIndex))
1304 deleteLink.setEnabled(true);
1308 deleteLink.setEnabled(false);
1311 if (((UrlLinkTableModel) linkUrlTable.getModel())
1312 .isRowEditable(modelIndex))
1314 editLink.setEnabled(true);
1318 editLink.setEnabled(false);