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.JalviewFileChooser;
28 import jalview.io.JalviewFileView;
29 import jalview.jbgui.GPreferences;
30 import jalview.jbgui.GSequenceLink;
31 import jalview.schemes.ColourSchemeProperty;
32 import jalview.urls.DesktopUrlProviderFactory;
33 import jalview.urls.UrlLinkTableModel;
34 import jalview.urls.UrlProviderFactoryI;
35 import jalview.urls.UrlProviderI;
36 import jalview.util.MessageManager;
37 import jalview.util.Platform;
38 import jalview.util.UrlConstants;
39 import jalview.ws.sifts.SiftsSettings;
41 import java.awt.BorderLayout;
42 import java.awt.Color;
43 import java.awt.Component;
44 import java.awt.Dimension;
46 import java.awt.event.ActionEvent;
47 import java.awt.event.ActionListener;
48 import java.awt.event.MouseEvent;
50 import java.util.ArrayList;
51 import java.util.List;
53 import javax.help.HelpSetException;
54 import javax.swing.JColorChooser;
55 import javax.swing.JFileChooser;
56 import javax.swing.JInternalFrame;
57 import javax.swing.JOptionPane;
58 import javax.swing.JPanel;
59 import javax.swing.ListSelectionModel;
60 import javax.swing.RowFilter;
61 import javax.swing.RowSorter;
62 import javax.swing.SortOrder;
63 import javax.swing.event.DocumentEvent;
64 import javax.swing.event.DocumentListener;
65 import javax.swing.event.ListSelectionEvent;
66 import javax.swing.event.ListSelectionListener;
67 import javax.swing.table.TableCellRenderer;
68 import javax.swing.table.TableColumn;
69 import javax.swing.table.TableModel;
70 import javax.swing.table.TableRowSorter;
72 import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
80 public class Preferences extends GPreferences
82 public static final String ENABLE_SPLIT_FRAME = "ENABLE_SPLIT_FRAME";
84 public static final String SCALE_PROTEIN_TO_CDNA = "SCALE_PROTEIN_TO_CDNA";
86 public static final String DEFAULT_COLOUR = "DEFAULT_COLOUR";
88 public static final String DEFAULT_COLOUR_PROT = "DEFAULT_COLOUR_PROT";
90 public static final String DEFAULT_COLOUR_NUC = "DEFAULT_COLOUR_NUC";
92 public static final String ADD_TEMPFACT_ANN = "ADD_TEMPFACT_ANN";
94 public static final String ADD_SS_ANN = "ADD_SS_ANN";
96 public static final String USE_RNAVIEW = "USE_RNAVIEW";
98 public static final String STRUCT_FROM_PDB = "STRUCT_FROM_PDB";
100 public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY";
102 public static final String CHIMERA_PATH = "CHIMERA_PATH";
104 public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS";
106 public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE";
108 private static final int MIN_FONT_SIZE = 1;
110 private static final int MAX_FONT_SIZE = 30;
113 * Holds name and link separated with | character. Sequence ID must be
114 * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$
116 public static UrlProviderI sequenceUrlLinks;
118 public static UrlLinkTableModel dataModel;
121 * Holds name and link separated with | character. Sequence IDS and Sequences
122 * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and
123 * $SEQUENCES$ or $SEQUENCES=/.possible | chars ./=$ and separation character
124 * for first and second token specified after a pipe character at end |,|.
125 * (TODO: proper escape for using | to separate ids or sequences
128 public static List<String> groupURLLinks;
131 // get links selected to be in the menu (SEQUENCE_LINKS)
132 // and links entered by the user but not selected (STORED_LINKS)
133 String inMenuString = Cache.getDefault("SEQUENCE_LINKS", "");
134 String notInMenuString = Cache.getDefault("STORED_LINKS", "");
135 String defaultUrl = Cache.getDefault("DEFAULT_URL",
136 UrlConstants.DEFAULT_LABEL);
138 // if both links lists are empty, add the DEFAULT_URL link
139 // otherwise we assume the default link is in one of the lists
140 if (inMenuString.isEmpty() && notInMenuString.isEmpty())
142 inMenuString = UrlConstants.DEFAULT_STRING;
144 UrlProviderFactoryI factory = new DesktopUrlProviderFactory(defaultUrl,
145 inMenuString, notInMenuString);
146 sequenceUrlLinks = factory.createUrlProvider();
147 dataModel = new UrlLinkTableModel(sequenceUrlLinks);
150 * TODO: reformulate groupURL encoding so two or more can be stored in the
151 * .properties file as '|' separated strings
154 groupURLLinks = new ArrayList<String>();
157 JInternalFrame frame;
159 DasSourceBrowser dasSource;
161 private WsPreferences wsPrefs;
163 private OptionsParam promptEachTimeOpt = new OptionsParam(
164 MessageManager.getString("label.prompt_each_time"),
167 private OptionsParam lineArtOpt = new OptionsParam(
168 MessageManager.getString("label.lineart"), "Lineart");
170 private OptionsParam textOpt = new OptionsParam(
171 MessageManager.getString("action.text"), "Text");
174 * Creates a new Preferences object.
179 frame = new JInternalFrame();
180 frame.setContentPane(this);
181 dasSource = new DasSourceBrowser();
182 dasTab.add(dasSource, BorderLayout.CENTER);
183 wsPrefs = new WsPreferences();
184 wsTab.add(wsPrefs, BorderLayout.CENTER);
185 int width = 500, height = 450;
186 new jalview.util.Platform();
187 if (Platform.isAMac())
193 Desktop.addInternalFrame(frame,
194 MessageManager.getString("label.preferences"), width, height);
195 frame.setMinimumSize(new Dimension(width, height));
198 * Set Visual tab defaults
200 seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true));
201 rightAlign.setSelected(Cache.getDefault("RIGHT_ALIGN_IDS", false));
202 fullScreen.setSelected(Cache.getDefault("SHOW_FULLSCREEN", false));
203 annotations.setSelected(Cache.getDefault("SHOW_ANNOTATIONS", true));
205 conservation.setSelected(Cache.getDefault("SHOW_CONSERVATION", true));
206 quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));
207 identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
208 openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false));
210 .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
211 showGroupConsensus.setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS",
213 showGroupConservation.setSelected(Cache.getDefault(
214 "SHOW_GROUP_CONSERVATION", false));
215 showConsensHistogram.setSelected(Cache.getDefault(
216 "SHOW_CONSENSUS_HISTOGRAM", true));
217 showConsensLogo.setSelected(Cache.getDefault("SHOW_CONSENSUS_LOGO",
219 showNpTooltip.setSelected(Cache
220 .getDefault("SHOW_NPFEATS_TOOLTIP", true));
221 showDbRefTooltip.setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP",
224 String[] fonts = java.awt.GraphicsEnvironment
225 .getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
226 for (int i = 0; i < fonts.length; i++)
228 fontNameCB.addItem(fonts[i]);
231 for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++)
233 fontSizeCB.addItem(i + "");
236 fontStyleCB.addItem("plain");
237 fontStyleCB.addItem("bold");
238 fontStyleCB.addItem("italic");
240 fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif"));
241 fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10"));
242 fontStyleCB.setSelectedItem(Cache.getDefault("FONT_STYLE", Font.PLAIN
245 smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", false));
246 scaleProteinToCdna.setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA,
249 idItalics.setSelected(Cache.getDefault("ID_ITALICS", true));
251 wrap.setSelected(Cache.getDefault("WRAP_ALIGNMENT", false));
253 gapSymbolCB.addItem("-");
254 gapSymbolCB.addItem(".");
256 gapSymbolCB.setSelectedItem(Cache.getDefault("GAP_SYMBOL", "-"));
258 sortby.addItem("No sort");
259 sortby.addItem("Id");
260 sortby.addItem("Pairwise Identity");
261 sortby.setSelectedItem(Cache.getDefault("SORT_ALIGNMENT", "No sort"));
263 sortAnnBy.addItem(SequenceAnnotationOrder.NONE.toString());
265 .addItem(SequenceAnnotationOrder.SEQUENCE_AND_LABEL.toString());
267 .addItem(SequenceAnnotationOrder.LABEL_AND_SEQUENCE.toString());
268 SequenceAnnotationOrder savedSort = SequenceAnnotationOrder
269 .valueOf(Cache.getDefault(SORT_ANNOTATIONS,
270 SequenceAnnotationOrder.NONE.name()));
271 sortAnnBy.setSelectedItem(savedSort.toString());
273 sortAutocalc.addItem("Autocalculated first");
274 sortAutocalc.addItem("Autocalculated last");
275 final boolean showAbove = Cache.getDefault(SHOW_AUTOCALC_ABOVE, true);
276 sortAutocalc.setSelectedItem(showAbove ? sortAutocalc.getItemAt(0)
277 : sortAutocalc.getItemAt(1));
279 .setSelected(Cache.getDefault("SHOW_STARTUP_FILE", true));
280 startupFileTextfield.setText(Cache.getDefault("STARTUP_FILE",
281 Cache.getDefault("www.jalview.org", "http://www.jalview.org")
282 + "/examples/exampleFile_2_3.jar"));
285 * Set Colours tab defaults
287 for (int i = ColourSchemeProperty.FIRST_COLOUR; i <= ColourSchemeProperty.LAST_COLOUR; i++)
289 protColour.addItem(ColourSchemeProperty.getColourName(i));
290 nucColour.addItem(ColourSchemeProperty.getColourName(i));
292 String oldProp = Cache.getDefault(DEFAULT_COLOUR, "None");
293 String newProp = Cache.getDefault(DEFAULT_COLOUR_PROT, null);
294 protColour.setSelectedItem(newProp != null ? newProp : oldProp);
295 newProp = Cache.getDefault(DEFAULT_COLOUR_NUC, null);
296 nucColour.setSelectedItem(newProp != null ? newProp : oldProp);
297 minColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN",
299 maxColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX",
303 * Set Structure tab defaults.
305 final boolean structSelected = Cache.getDefault(STRUCT_FROM_PDB, false);
306 structFromPdb.setSelected(structSelected);
307 useRnaView.setSelected(Cache.getDefault(USE_RNAVIEW, false));
308 useRnaView.setEnabled(structSelected);
309 addSecondaryStructure.setSelected(Cache.getDefault(ADD_SS_ANN, false));
310 addSecondaryStructure.setEnabled(structSelected);
311 addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, false));
312 addTempFactor.setEnabled(structSelected);
313 structViewer.setSelectedItem(Cache.getDefault(STRUCTURE_DISPLAY,
314 ViewerType.JMOL.name()));
315 chimeraPath.setText(Cache.getDefault(CHIMERA_PATH, ""));
316 chimeraPath.addActionListener(new ActionListener()
319 public void actionPerformed(ActionEvent e)
321 validateChimeraPath();
325 if (Cache.getDefault("MAP_WITH_SIFTS", false))
327 siftsMapping.setSelected(true);
331 nwMapping.setSelected(true);
335 .setMapWithSifts(Cache.getDefault("MAP_WITH_SIFTS", false));
338 * Set Connections tab defaults
342 linkUrlTable.setModel(dataModel);
343 final TableRowSorter<TableModel> sorter = new TableRowSorter<>(
344 linkUrlTable.getModel());
345 linkUrlTable.setRowSorter(sorter);
346 List<RowSorter.SortKey> sortKeys = new ArrayList<>();
348 UrlLinkTableModel m = (UrlLinkTableModel) linkUrlTable.getModel();
349 sortKeys.add(new RowSorter.SortKey(m.getDefaultColumn(),
350 SortOrder.DESCENDING));
351 sortKeys.add(new RowSorter.SortKey(m.getSelectedColumn(),
352 SortOrder.DESCENDING));
353 sortKeys.add(new RowSorter.SortKey(m.getNameColumn(),
354 SortOrder.ASCENDING));
356 sorter.setSortKeys(sortKeys);
360 ActionListener onReset;
361 onReset = new ActionListener()
364 public void actionPerformed(ActionEvent e)
366 filterTB.setText("");
367 sorter.setRowFilter(RowFilter.regexFilter(""));
371 doReset.addActionListener(onReset);
373 // filter to display only custom urls
374 final RowFilter<TableModel, Object> customUrlFilter = new RowFilter<TableModel, Object>()
377 public boolean include(
378 Entry<? extends TableModel, ? extends Object> entry)
380 int col = ((UrlLinkTableModel) entry.getModel()).getIdColumn();
381 String id = entry.getStringValue(col);
382 return sequenceUrlLinks.isUserEntry(id);
386 final TableRowSorter<TableModel> customSorter = new TableRowSorter<>(
387 linkUrlTable.getModel());
388 customSorter.setRowFilter(customUrlFilter);
390 ActionListener onCustomOnly;
391 onCustomOnly = new ActionListener()
394 public void actionPerformed(ActionEvent e)
396 filterTB.setText("");
397 sorter.setRowFilter(customUrlFilter);
400 userOnly.addActionListener(onCustomOnly);
402 filterTB.getDocument().addDocumentListener(new DocumentListener()
404 String caseInsensitiveFlag = "(?i)";
407 public void changedUpdate(DocumentEvent e)
409 sorter.setRowFilter(RowFilter.regexFilter(caseInsensitiveFlag
410 + filterTB.getText()));
414 public void removeUpdate(DocumentEvent e)
416 sorter.setRowFilter(RowFilter.regexFilter(caseInsensitiveFlag
417 + filterTB.getText()));
421 public void insertUpdate(DocumentEvent e)
423 sorter.setRowFilter(RowFilter.regexFilter(caseInsensitiveFlag
424 + filterTB.getText()));
428 // set up list selection functionality
429 linkUrlTable.getSelectionModel().addListSelectionListener(
430 new UrlListSelectionHandler());
432 // set up radio buttons
433 int onClickCol = ((UrlLinkTableModel) linkUrlTable.getModel())
435 String onClickName = linkUrlTable.getColumnName(onClickCol);
436 linkUrlTable.getColumn(onClickName).setCellRenderer(
437 new RadioButtonRenderer());
438 linkUrlTable.getColumn(onClickName)
439 .setCellEditor(new RadioButtonEditor());
441 // get boolean columns and resize those to min possible
442 for (int column = 0; column < linkUrlTable.getColumnCount(); column++)
444 if (linkUrlTable.getModel().getColumnClass(column)
445 .equals(Boolean.class))
447 TableColumn tableColumn = linkUrlTable.getColumnModel().getColumn(
449 int preferredWidth = tableColumn.getMinWidth();
451 TableCellRenderer cellRenderer = linkUrlTable.getCellRenderer(0,
453 Component c = linkUrlTable.prepareRenderer(cellRenderer, 0, column);
454 int cwidth = c.getPreferredSize().width
455 + linkUrlTable.getIntercellSpacing().width;
456 preferredWidth = Math.max(preferredWidth, cwidth);
458 tableColumn.setPreferredWidth(preferredWidth);
462 useProxy.setSelected(Cache.getDefault("USE_PROXY", false));
463 useProxy_actionPerformed(); // make sure useProxy is correctly initialised
464 proxyServerTB.setEnabled(useProxy.isSelected());
465 proxyPortTB.setEnabled(useProxy.isSelected());
466 proxyServerTB.setText(Cache.getDefault("PROXY_SERVER", ""));
467 proxyPortTB.setText(Cache.getDefault("PROXY_PORT", ""));
469 defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
471 usagestats.setSelected(Cache.getDefault("USAGESTATS", false));
472 // note antisense here: default is true
474 .setSelected(Cache.getProperty("NOQUESTIONNAIRES") == null);
475 versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true));
478 * Set Output tab defaults
480 epsRendering.addItem(promptEachTimeOpt);
481 epsRendering.addItem(lineArtOpt);
482 epsRendering.addItem(textOpt);
483 String defaultEPS = Cache.getDefault("EPS_RENDERING",
485 if (defaultEPS.equalsIgnoreCase("Text"))
487 epsRendering.setSelectedItem(textOpt);
489 else if (defaultEPS.equalsIgnoreCase("Lineart"))
491 epsRendering.setSelectedItem(lineArtOpt);
495 epsRendering.setSelectedItem(promptEachTimeOpt);
497 autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
498 userIdWidth.setEnabled(!autoIdWidth.isSelected());
499 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
500 Integer wi = Cache.getIntegerProperty("FIGURE_USERIDWIDTH");
501 userIdWidth.setText(wi == null ? "" : wi.toString());
502 blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
503 clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
504 fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
505 msfjv.setSelected(Cache.getDefault("MSF_JVSUFFIX", true));
506 pfamjv.setSelected(Cache.getDefault("PFAM_JVSUFFIX", true));
507 pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true));
508 pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true));
509 modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false));
510 embbedBioJSON.setSelected(Cache.getDefault("EXPORT_EMBBED_BIOJSON",
514 * Set Editing tab defaults
516 autoCalculateConsCheck.setSelected(Cache.getDefault(
517 "AUTO_CALC_CONSENSUS", true));
518 padGaps.setSelected(Cache.getDefault("PAD_GAPS", false));
519 sortByTree.setSelected(Cache.getDefault("SORT_BY_TREE", false));
521 annotations_actionPerformed(null); // update the display of the annotation
526 * Save user selections on the Preferences tabs to the Cache and write out to
532 public void ok_actionPerformed(ActionEvent e)
534 if (!validateSettings())
540 * Save Visual settings
542 Cache.applicationProperties.setProperty("SHOW_JVSUFFIX",
543 Boolean.toString(seqLimit.isSelected()));
544 Cache.applicationProperties.setProperty("RIGHT_ALIGN_IDS",
545 Boolean.toString(rightAlign.isSelected()));
546 Cache.applicationProperties.setProperty("SHOW_FULLSCREEN",
547 Boolean.toString(fullScreen.isSelected()));
548 Cache.applicationProperties.setProperty("SHOW_OVERVIEW",
549 Boolean.toString(openoverv.isSelected()));
550 Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
551 Boolean.toString(annotations.isSelected()));
552 Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
553 Boolean.toString(conservation.isSelected()));
554 Cache.applicationProperties.setProperty("SHOW_QUALITY",
555 Boolean.toString(quality.isSelected()));
556 Cache.applicationProperties.setProperty("SHOW_IDENTITY",
557 Boolean.toString(identity.isSelected()));
559 Cache.applicationProperties.setProperty("GAP_SYMBOL", gapSymbolCB
560 .getSelectedItem().toString());
562 Cache.applicationProperties.setProperty("FONT_NAME", fontNameCB
563 .getSelectedItem().toString());
564 Cache.applicationProperties.setProperty("FONT_STYLE", fontStyleCB
565 .getSelectedItem().toString());
566 Cache.applicationProperties.setProperty("FONT_SIZE", fontSizeCB
567 .getSelectedItem().toString());
569 Cache.applicationProperties.setProperty("ID_ITALICS",
570 Boolean.toString(idItalics.isSelected()));
571 Cache.applicationProperties.setProperty("SHOW_UNCONSERVED",
572 Boolean.toString(showUnconserved.isSelected()));
573 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSENSUS",
574 Boolean.toString(showGroupConsensus.isSelected()));
575 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSERVATION",
576 Boolean.toString(showGroupConservation.isSelected()));
577 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_HISTOGRAM",
578 Boolean.toString(showConsensHistogram.isSelected()));
579 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_LOGO",
580 Boolean.toString(showConsensLogo.isSelected()));
581 Cache.applicationProperties.setProperty("ANTI_ALIAS",
582 Boolean.toString(smoothFont.isSelected()));
583 Cache.applicationProperties.setProperty(SCALE_PROTEIN_TO_CDNA,
584 Boolean.toString(scaleProteinToCdna.isSelected()));
585 Cache.applicationProperties.setProperty("SHOW_NPFEATS_TOOLTIP",
586 Boolean.toString(showNpTooltip.isSelected()));
587 Cache.applicationProperties.setProperty("SHOW_DBREFS_TOOLTIP",
588 Boolean.toString(showDbRefTooltip.isSelected()));
590 Cache.applicationProperties.setProperty("WRAP_ALIGNMENT",
591 Boolean.toString(wrap.isSelected()));
593 Cache.applicationProperties.setProperty("STARTUP_FILE",
594 startupFileTextfield.getText());
595 Cache.applicationProperties.setProperty("SHOW_STARTUP_FILE",
596 Boolean.toString(startupCheckbox.isSelected()));
598 Cache.applicationProperties.setProperty("SORT_ALIGNMENT", sortby
599 .getSelectedItem().toString());
601 // convert description of sort order to enum name for save
602 SequenceAnnotationOrder annSortOrder = SequenceAnnotationOrder
603 .forDescription(sortAnnBy.getSelectedItem().toString());
604 if (annSortOrder != null)
606 Cache.applicationProperties.setProperty(SORT_ANNOTATIONS,
607 annSortOrder.name());
610 final boolean showAutocalcFirst = sortAutocalc.getSelectedIndex() == 0;
611 Cache.applicationProperties.setProperty(SHOW_AUTOCALC_ABOVE, Boolean
612 .valueOf(showAutocalcFirst).toString());
615 * Save Colours settings
617 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_PROT, protColour
618 .getSelectedItem().toString());
619 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_NUC, nucColour
620 .getSelectedItem().toString());
621 Cache.setColourProperty("ANNOTATIONCOLOUR_MIN",
622 minColour.getBackground());
623 Cache.setColourProperty("ANNOTATIONCOLOUR_MAX",
624 maxColour.getBackground());
627 * Save Structure settings
629 Cache.applicationProperties.setProperty(ADD_TEMPFACT_ANN,
630 Boolean.toString(addTempFactor.isSelected()));
631 Cache.applicationProperties.setProperty(ADD_SS_ANN,
632 Boolean.toString(addSecondaryStructure.isSelected()));
633 Cache.applicationProperties.setProperty(USE_RNAVIEW,
634 Boolean.toString(useRnaView.isSelected()));
635 Cache.applicationProperties.setProperty(STRUCT_FROM_PDB,
636 Boolean.toString(structFromPdb.isSelected()));
637 Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY, structViewer
638 .getSelectedItem().toString());
639 Cache.setOrRemove(CHIMERA_PATH, chimeraPath.getText());
640 Cache.applicationProperties.setProperty("MAP_WITH_SIFTS",
641 Boolean.toString(siftsMapping.isSelected()));
642 SiftsSettings.setMapWithSifts(siftsMapping.isSelected());
645 * Save Output settings
647 Cache.applicationProperties.setProperty("EPS_RENDERING",
648 ((OptionsParam) epsRendering.getSelectedItem()).getCode());
651 * Save Connections settings
653 Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
655 jalview.util.BrowserLauncher.resetBrowser();
657 // save user-defined and selected links
658 String menuLinks = sequenceUrlLinks.writeUrlsAsString(true);
659 if (menuLinks.isEmpty())
661 Cache.applicationProperties.remove("SEQUENCE_LINKS");
665 Cache.applicationProperties.setProperty("SEQUENCE_LINKS",
666 menuLinks.toString());
669 String nonMenuLinks = sequenceUrlLinks.writeUrlsAsString(false);
670 if (nonMenuLinks.isEmpty())
672 Cache.applicationProperties.remove("STORED_LINKS");
676 Cache.applicationProperties.setProperty("STORED_LINKS",
677 nonMenuLinks.toString());
680 Cache.applicationProperties.setProperty("DEFAULT_URL",
681 sequenceUrlLinks.getDefaultUrlId());
683 Cache.applicationProperties.setProperty("USE_PROXY",
684 Boolean.toString(useProxy.isSelected()));
686 Cache.setOrRemove("PROXY_SERVER", proxyServerTB.getText());
688 Cache.setOrRemove("PROXY_PORT", proxyPortTB.getText());
690 if (useProxy.isSelected())
692 System.setProperty("http.proxyHost", proxyServerTB.getText());
693 System.setProperty("http.proxyPort", proxyPortTB.getText());
697 System.setProperty("http.proxyHost", "");
698 System.setProperty("http.proxyPort", "");
700 Cache.setProperty("VERSION_CHECK",
701 Boolean.toString(versioncheck.isSelected()));
702 if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
704 // default is false - we only set this if the user has actively agreed
705 Cache.setProperty("USAGESTATS",
706 Boolean.toString(usagestats.isSelected()));
708 if (!questionnaire.isSelected())
710 Cache.setProperty("NOQUESTIONNAIRES", "true");
714 // special - made easy to edit a property file to disable questionnaires
715 // by just adding the given line
716 Cache.removeProperty("NOQUESTIONNAIRES");
720 * Save Output settings
722 Cache.applicationProperties.setProperty("BLC_JVSUFFIX",
723 Boolean.toString(blcjv.isSelected()));
724 Cache.applicationProperties.setProperty("CLUSTAL_JVSUFFIX",
725 Boolean.toString(clustaljv.isSelected()));
726 Cache.applicationProperties.setProperty("FASTA_JVSUFFIX",
727 Boolean.toString(fastajv.isSelected()));
728 Cache.applicationProperties.setProperty("MSF_JVSUFFIX",
729 Boolean.toString(msfjv.isSelected()));
730 Cache.applicationProperties.setProperty("PFAM_JVSUFFIX",
731 Boolean.toString(pfamjv.isSelected()));
732 Cache.applicationProperties.setProperty("PILEUP_JVSUFFIX",
733 Boolean.toString(pileupjv.isSelected()));
734 Cache.applicationProperties.setProperty("PIR_JVSUFFIX",
735 Boolean.toString(pirjv.isSelected()));
736 Cache.applicationProperties.setProperty("PIR_MODELLER",
737 Boolean.toString(modellerOutput.isSelected()));
738 Cache.applicationProperties.setProperty("EXPORT_EMBBED_BIOJSON",
739 Boolean.toString(embbedBioJSON.isSelected()));
740 jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
742 Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH",
743 Boolean.toString(autoIdWidth.isSelected()));
744 userIdWidth_actionPerformed();
745 Cache.applicationProperties.setProperty("FIGURE_USERIDWIDTH",
746 userIdWidth.getText());
749 * Save Editing settings
751 Cache.applicationProperties.setProperty("AUTO_CALC_CONSENSUS",
752 Boolean.toString(autoCalculateConsCheck.isSelected()));
753 Cache.applicationProperties.setProperty("SORT_BY_TREE",
754 Boolean.toString(sortByTree.isSelected()));
755 Cache.applicationProperties.setProperty("PAD_GAPS",
756 Boolean.toString(padGaps.isSelected()));
758 dasSource.saveProperties(Cache.applicationProperties);
759 wsPrefs.updateAndRefreshWsMenuConfig(false);
760 Cache.saveProperties();
761 Desktop.instance.doConfigureStructurePrefs();
764 frame.setClosed(true);
765 } catch (Exception ex)
771 * Do any necessary validation before saving settings. Return focus to the
772 * first tab which fails validation.
776 private boolean validateSettings()
778 if (!validateStructure())
780 structureTab.requestFocusInWindow();
787 protected boolean validateStructure()
789 return validateChimeraPath();
797 public void startupFileTextfield_mouseClicked()
799 JalviewFileChooser chooser = new JalviewFileChooser(
800 jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] {
801 "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc",
802 "jar" }, new String[] { "Fasta", "Clustal", "PFAM", "MSF",
803 "PIR", "BLC", "Jalview" },
804 jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT"));
805 chooser.setFileView(new JalviewFileView());
806 chooser.setDialogTitle(MessageManager
807 .getString("label.select_startup_file"));
809 int value = chooser.showOpenDialog(this);
811 if (value == JalviewFileChooser.APPROVE_OPTION)
813 jalview.bin.Cache.applicationProperties.setProperty(
814 "DEFAULT_FILE_FORMAT", chooser.getSelectedFormat());
815 startupFileTextfield.setText(chooser.getSelectedFile()
827 public void cancel_actionPerformed(ActionEvent e)
831 wsPrefs.updateWsMenuConfig(true);
832 wsPrefs.refreshWs_actionPerformed(e);
833 frame.setClosed(true);
834 } catch (Exception ex)
846 public void annotations_actionPerformed(ActionEvent e)
848 conservation.setEnabled(annotations.isSelected());
849 quality.setEnabled(annotations.isSelected());
850 identity.setEnabled(annotations.isSelected());
851 showGroupConsensus.setEnabled(annotations.isSelected());
852 showGroupConservation.setEnabled(annotations.isSelected());
853 showConsensHistogram.setEnabled(annotations.isSelected()
854 && (identity.isSelected() || showGroupConsensus.isSelected()));
855 showConsensLogo.setEnabled(annotations.isSelected()
856 && (identity.isSelected() || showGroupConsensus.isSelected()));
860 public void newLink_actionPerformed(ActionEvent e)
862 GSequenceLink link = new GSequenceLink();
863 boolean valid = false;
866 if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
867 MessageManager.getString("label.new_sequence_url_link"),
868 JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
870 if (link.checkValid())
872 ((UrlLinkTableModel) linkUrlTable.getModel()).insertRow(
873 link.getName(), link.getURL());
885 public void editLink_actionPerformed(ActionEvent e)
887 GSequenceLink link = new GSequenceLink();
889 int index = linkUrlTable.getSelectedRow();
892 // button no longer enabled if row is not selected
893 Cache.log.debug("Edit with no row selected in linkUrlTable");
897 link.setName(linkUrlTable.getValueAt(index, 0).toString());
898 link.setURL(linkUrlTable.getValueAt(index, 1).toString());
900 boolean valid = false;
903 if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
904 MessageManager.getString("label.edit_sequence_url_link"),
905 JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
907 if (link.checkValid())
909 linkUrlTable.setValueAt(link.getName(), index, 0);
910 linkUrlTable.setValueAt(link.getURL(), index, 1);
922 public void deleteLink_actionPerformed(ActionEvent e)
924 int index = linkUrlTable.getSelectedRow();
928 // button no longer enabled if row is not selected
929 Cache.log.debug("Delete with no row selected in linkUrlTable");
934 modelIndex = linkUrlTable.convertRowIndexToModel(index);
937 // make sure we use the model index to delete, and not the table index
938 ((UrlLinkTableModel) linkUrlTable.getModel()).removeRow(modelIndex);
943 public void defaultBrowser_mouseClicked(MouseEvent e)
945 JFileChooser chooser = new JFileChooser(".");
946 chooser.setDialogTitle(MessageManager
947 .getString("label.select_default_browser"));
949 int value = chooser.showOpenDialog(this);
951 if (value == JFileChooser.APPROVE_OPTION)
953 defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath());
962 * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event
966 protected void showunconserved_actionPerformed(ActionEvent e)
968 // TODO Auto-generated method stub
969 super.showunconserved_actionPerformed(e);
972 public static List<String> getGroupURLLinks()
974 return groupURLLinks;
978 public void minColour_actionPerformed(JPanel panel)
980 Color col = JColorChooser.showDialog(this,
981 MessageManager.getString("label.select_colour_minimum_value"),
982 minColour.getBackground());
985 panel.setBackground(col);
991 public void maxColour_actionPerformed(JPanel panel)
993 Color col = JColorChooser.showDialog(this,
994 MessageManager.getString("label.select_colour_maximum_value"),
995 maxColour.getBackground());
998 panel.setBackground(col);
1004 protected void userIdWidth_actionPerformed()
1008 String val = userIdWidth.getText().trim();
1009 if (val.length() > 0)
1011 Integer iw = Integer.parseInt(val);
1012 if (iw.intValue() < 12)
1014 throw new NumberFormatException();
1016 userIdWidth.setText(iw.toString());
1018 } catch (NumberFormatException x)
1020 JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
1021 .getString("warn.user_defined_width_requirements"),
1022 MessageManager.getString("label.invalid_id_column_width"),
1023 JOptionPane.WARNING_MESSAGE);
1024 userIdWidth.setText("");
1029 protected void autoIdWidth_actionPerformed()
1031 userIdWidth.setEnabled(!autoIdWidth.isSelected());
1032 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
1036 * Returns true if chimera path is to a valid executable, else show an error
1039 private boolean validateChimeraPath()
1041 if (chimeraPath.getText().trim().length() > 0)
1043 File f = new File(chimeraPath.getText());
1044 if (!f.canExecute())
1046 JOptionPane.showInternalMessageDialog(Desktop.desktop,
1047 MessageManager.getString("label.invalid_chimera_path"),
1048 MessageManager.getString("label.invalid_name"),
1049 JOptionPane.ERROR_MESSAGE);
1057 * If Chimera is selected, check it can be found on default or user-specified
1058 * path, if not show a warning/help dialog.
1061 protected void structureViewer_actionPerformed(String selectedItem)
1063 if (!selectedItem.equals(ViewerType.CHIMERA.name()))
1067 boolean found = false;
1070 * Try user-specified and standard paths for Chimera executable.
1072 List<String> paths = StructureManager.getChimeraPaths();
1073 paths.add(0, chimeraPath.getText());
1074 for (String path : paths)
1076 if (new File(path.trim()).canExecute())
1084 String[] options = { "OK", "Help" };
1085 int showHelp = JOptionPane.showInternalOptionDialog(
1087 JvSwingUtils.wrapTooltip(true,
1088 MessageManager.getString("label.chimera_missing")),
1089 "", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE,
1090 null, options, options[0]);
1091 if (showHelp == JOptionPane.NO_OPTION)
1095 Help.showHelpWindow(HelpId.StructureViewer);
1096 } catch (HelpSetException e)
1098 e.printStackTrace();
1104 public class OptionsParam
1106 private String name;
1108 private String code;
1110 public OptionsParam(String name, String code)
1116 public String getName()
1121 public void setName(String name)
1126 public String getCode()
1131 public void setCode(String code)
1137 public String toString()
1143 public boolean equals(Object that)
1145 if (!(that instanceof OptionsParam))
1149 return this.code.equalsIgnoreCase(((OptionsParam) that).code);
1153 public int hashCode()
1155 return name.hashCode() + code.hashCode();
1159 private class UrlListSelectionHandler implements ListSelectionListener
1163 public void valueChanged(ListSelectionEvent e)
1165 ListSelectionModel lsm = (ListSelectionModel) e.getSource();
1167 int index = lsm.getMinSelectionIndex();
1170 // no selection, so disable delete/edit buttons
1171 editLink.setEnabled(false);
1172 deleteLink.setEnabled(false);
1175 int modelIndex = linkUrlTable.convertRowIndexToModel(index);
1177 // determine if the new selection is a custom url or not
1178 int col = ((UrlLinkTableModel) linkUrlTable.getModel())
1180 if (!sequenceUrlLinks.isUserEntry((String) linkUrlTable.getModel()
1181 .getValueAt(modelIndex, col)))
1183 // entry is not a user-defined url and so should not be edited
1184 // disable edit and delete buttons
1185 deleteLink.setEnabled(false);
1186 editLink.setEnabled(false);
1190 deleteLink.setEnabled(true);
1191 editLink.setEnabled(true);
1194 // BUT if it's the default url, don't allow deletion
1195 col = ((UrlLinkTableModel) linkUrlTable.getModel())
1196 .getDefaultColumn();
1197 if ((boolean) linkUrlTable.getValueAt(index, col))
1199 deleteLink.setEnabled(false);