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 private static final int MIN_FONT_SIZE = 1;
114 private static final int MAX_FONT_SIZE = 30;
117 * Holds name and link separated with | character. Sequence ID must be
118 * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$
120 public static UrlProviderI sequenceUrlLinks;
122 public static UrlLinkTableModel dataModel;
125 * Holds name and link separated with | character. Sequence IDS and Sequences
126 * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and
127 * $SEQUENCES$ or $SEQUENCES=/.possible | chars ./=$ and separation character
128 * for first and second token specified after a pipe character at end |,|.
129 * (TODO: proper escape for using | to separate ids or sequences
132 public static List<String> groupURLLinks;
135 // get links selected to be in the menu (SEQUENCE_LINKS)
136 // and links entered by the user but not selected (STORED_LINKS)
137 String inMenuString = Cache.getDefault("SEQUENCE_LINKS", "");
138 String notInMenuString = Cache.getDefault("STORED_LINKS", "");
139 String defaultUrl = Cache.getDefault("DEFAULT_URL",
140 UrlConstants.DEFAULT_LABEL);
142 // if both links lists are empty, add the DEFAULT_URL link
143 // otherwise we assume the default link is in one of the lists
144 if (inMenuString.isEmpty() && notInMenuString.isEmpty())
146 inMenuString = UrlConstants.DEFAULT_STRING;
148 UrlProviderFactoryI factory = new DesktopUrlProviderFactory(defaultUrl,
149 inMenuString, notInMenuString);
150 sequenceUrlLinks = factory.createUrlProvider();
151 dataModel = new UrlLinkTableModel(sequenceUrlLinks);
154 * TODO: reformulate groupURL encoding so two or more can be stored in the
155 * .properties file as '|' separated strings
158 groupURLLinks = new ArrayList<>();
161 JInternalFrame frame;
163 DasSourceBrowser dasSource;
165 private WsPreferences wsPrefs;
167 private OptionsParam promptEachTimeOpt = new OptionsParam(
168 MessageManager.getString("label.prompt_each_time"),
171 private OptionsParam lineArtOpt = new OptionsParam(
172 MessageManager.getString("label.lineart"), "Lineart");
174 private OptionsParam textOpt = new OptionsParam(
175 MessageManager.getString("action.text"), "Text");
178 * Creates a new Preferences object.
183 frame = new JInternalFrame();
184 frame.setContentPane(this);
185 dasSource = new DasSourceBrowser();
186 dasTab.add(dasSource, BorderLayout.CENTER);
187 wsPrefs = new WsPreferences();
188 wsTab.add(wsPrefs, BorderLayout.CENTER);
189 int width = 500, height = 450;
190 new jalview.util.Platform();
191 if (Platform.isAMac())
197 Desktop.addInternalFrame(frame,
198 MessageManager.getString("label.preferences"), width, height);
199 frame.setMinimumSize(new Dimension(width, height));
202 * Set Visual tab defaults
204 seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true));
205 rightAlign.setSelected(Cache.getDefault("RIGHT_ALIGN_IDS", false));
206 fullScreen.setSelected(Cache.getDefault("SHOW_FULLSCREEN", false));
207 annotations.setSelected(Cache.getDefault("SHOW_ANNOTATIONS", true));
209 conservation.setSelected(Cache.getDefault("SHOW_CONSERVATION", true));
210 quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));
211 identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
212 openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false));
214 .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
215 showOccupancy.setSelected(Cache.getDefault(SHOW_OCCUPANCY, false));
216 showGroupConsensus.setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS",
218 showGroupConservation.setSelected(Cache.getDefault(
219 "SHOW_GROUP_CONSERVATION", false));
220 showConsensHistogram.setSelected(Cache.getDefault(
221 "SHOW_CONSENSUS_HISTOGRAM", true));
222 showConsensLogo.setSelected(Cache.getDefault("SHOW_CONSENSUS_LOGO",
224 showInformationHistogram.setSelected(
225 Cache.getDefault("SHOW_INFORMATION_HISTOGRAM", true));
226 showHMMLogo.setSelected(Cache.getDefault("SHOW_HMM_LOGO", false));
227 showNpTooltip.setSelected(Cache
228 .getDefault("SHOW_NPFEATS_TOOLTIP", true));
229 showDbRefTooltip.setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP",
232 String[] fonts = java.awt.GraphicsEnvironment
233 .getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
234 for (int i = 0; i < fonts.length; i++)
236 fontNameCB.addItem(fonts[i]);
239 for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++)
241 fontSizeCB.addItem(i + "");
244 fontStyleCB.addItem("plain");
245 fontStyleCB.addItem("bold");
246 fontStyleCB.addItem("italic");
248 fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif"));
249 fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10"));
250 fontStyleCB.setSelectedItem(Cache.getDefault("FONT_STYLE", Font.PLAIN
253 smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", false));
254 scaleProteinToCdna.setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA,
257 idItalics.setSelected(Cache.getDefault("ID_ITALICS", true));
259 wrap.setSelected(Cache.getDefault("WRAP_ALIGNMENT", false));
261 gapSymbolCB.addItem("-");
262 gapSymbolCB.addItem(".");
264 gapSymbolCB.setSelectedItem(Cache.getDefault("GAP_SYMBOL", "-"));
266 sortby.addItem("No sort");
267 sortby.addItem("Id");
268 sortby.addItem("Pairwise Identity");
269 sortby.setSelectedItem(Cache.getDefault("SORT_ALIGNMENT", "No sort"));
271 sortAnnBy.addItem(SequenceAnnotationOrder.NONE.toString());
273 .addItem(SequenceAnnotationOrder.SEQUENCE_AND_LABEL.toString());
275 .addItem(SequenceAnnotationOrder.LABEL_AND_SEQUENCE.toString());
276 SequenceAnnotationOrder savedSort = SequenceAnnotationOrder
277 .valueOf(Cache.getDefault(SORT_ANNOTATIONS,
278 SequenceAnnotationOrder.NONE.name()));
279 sortAnnBy.setSelectedItem(savedSort.toString());
281 sortAutocalc.addItem("Autocalculated first");
282 sortAutocalc.addItem("Autocalculated last");
283 final boolean showAbove = Cache.getDefault(SHOW_AUTOCALC_ABOVE, true);
284 sortAutocalc.setSelectedItem(showAbove ? sortAutocalc.getItemAt(0)
285 : sortAutocalc.getItemAt(1));
287 .setSelected(Cache.getDefault("SHOW_STARTUP_FILE", true));
288 startupFileTextfield.setText(Cache.getDefault("STARTUP_FILE",
289 Cache.getDefault("www.jalview.org", "http://www.jalview.org")
290 + "/examples/exampleFile_2_3.jar"));
293 * Set Colours tab defaults
295 protColour.addItem(ResidueColourScheme.NONE);
296 nucColour.addItem(ResidueColourScheme.NONE);
297 for (ColourSchemeI cs : ColourSchemes.getInstance().getColourSchemes())
299 String name = cs.getSchemeName();
300 protColour.addItem(name);
301 nucColour.addItem(name);
303 String oldProp = Cache.getDefault(DEFAULT_COLOUR,
304 ResidueColourScheme.NONE);
305 String newProp = Cache.getDefault(DEFAULT_COLOUR_PROT, null);
306 protColour.setSelectedItem(newProp != null ? newProp : oldProp);
307 newProp = Cache.getDefault(DEFAULT_COLOUR_NUC, null);
308 nucColour.setSelectedItem(newProp != null ? newProp : oldProp);
309 minColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN",
311 maxColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX",
315 * Set Structure tab defaults.
317 final boolean structSelected = Cache.getDefault(STRUCT_FROM_PDB, false);
318 structFromPdb.setSelected(structSelected);
319 useRnaView.setSelected(Cache.getDefault(USE_RNAVIEW, false));
320 useRnaView.setEnabled(structSelected);
321 addSecondaryStructure.setSelected(Cache.getDefault(ADD_SS_ANN, false));
322 addSecondaryStructure.setEnabled(structSelected);
323 addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, false));
324 addTempFactor.setEnabled(structSelected);
325 structViewer.setSelectedItem(Cache.getDefault(STRUCTURE_DISPLAY,
326 ViewerType.JMOL.name()));
327 chimeraPath.setText(Cache.getDefault(CHIMERA_PATH, ""));
328 chimeraPath.addActionListener(new ActionListener()
331 public void actionPerformed(ActionEvent e)
333 validateChimeraPath();
337 if (Cache.getDefault("MAP_WITH_SIFTS", false))
339 siftsMapping.setSelected(true);
343 nwMapping.setSelected(true);
347 .setMapWithSifts(Cache.getDefault("MAP_WITH_SIFTS", false));
350 * Set Connections tab defaults
354 linkUrlTable.setModel(dataModel);
355 final TableRowSorter<TableModel> sorter = new TableRowSorter<>(
356 linkUrlTable.getModel());
357 linkUrlTable.setRowSorter(sorter);
358 List<RowSorter.SortKey> sortKeys = new ArrayList<>();
360 UrlLinkTableModel m = (UrlLinkTableModel) linkUrlTable.getModel();
361 sortKeys.add(new RowSorter.SortKey(m.getPrimaryColumn(),
362 SortOrder.DESCENDING));
363 sortKeys.add(new RowSorter.SortKey(m.getSelectedColumn(),
364 SortOrder.DESCENDING));
365 sortKeys.add(new RowSorter.SortKey(m.getNameColumn(),
366 SortOrder.ASCENDING));
368 sorter.setSortKeys(sortKeys);
372 ActionListener onReset;
373 onReset = new ActionListener()
376 public void actionPerformed(ActionEvent e)
378 filterTB.setText("");
379 sorter.setRowFilter(RowFilter.regexFilter(""));
383 doReset.addActionListener(onReset);
385 // filter to display only custom urls
386 final RowFilter<TableModel, Object> customUrlFilter = new RowFilter<TableModel, Object>()
389 public boolean include(
390 Entry<? extends TableModel, ? extends Object> entry)
392 return ((UrlLinkTableModel) entry.getModel()).isUserEntry(entry);
396 final TableRowSorter<TableModel> customSorter = new TableRowSorter<>(
397 linkUrlTable.getModel());
398 customSorter.setRowFilter(customUrlFilter);
400 ActionListener onCustomOnly;
401 onCustomOnly = new ActionListener()
404 public void actionPerformed(ActionEvent e)
406 filterTB.setText("");
407 sorter.setRowFilter(customUrlFilter);
410 userOnly.addActionListener(onCustomOnly);
412 filterTB.getDocument().addDocumentListener(new DocumentListener()
414 String caseInsensitiveFlag = "(?i)";
417 public void changedUpdate(DocumentEvent e)
419 sorter.setRowFilter(RowFilter.regexFilter(caseInsensitiveFlag
420 + filterTB.getText()));
424 public void removeUpdate(DocumentEvent e)
426 sorter.setRowFilter(RowFilter.regexFilter(caseInsensitiveFlag
427 + filterTB.getText()));
431 public void insertUpdate(DocumentEvent e)
433 sorter.setRowFilter(RowFilter.regexFilter(caseInsensitiveFlag
434 + filterTB.getText()));
438 // set up list selection functionality
439 linkUrlTable.getSelectionModel().addListSelectionListener(
440 new UrlListSelectionHandler());
442 // set up radio buttons
443 int onClickCol = ((UrlLinkTableModel) linkUrlTable.getModel())
445 String onClickName = linkUrlTable.getColumnName(onClickCol);
446 linkUrlTable.getColumn(onClickName).setCellRenderer(
447 new RadioButtonRenderer());
448 linkUrlTable.getColumn(onClickName)
449 .setCellEditor(new RadioButtonEditor());
451 // get boolean columns and resize those to min possible
452 for (int column = 0; column < linkUrlTable.getColumnCount(); column++)
454 if (linkUrlTable.getModel().getColumnClass(column)
455 .equals(Boolean.class))
457 TableColumn tableColumn = linkUrlTable.getColumnModel().getColumn(
459 int preferredWidth = tableColumn.getMinWidth();
461 TableCellRenderer cellRenderer = linkUrlTable.getCellRenderer(0,
463 Component c = linkUrlTable.prepareRenderer(cellRenderer, 0, column);
464 int cwidth = c.getPreferredSize().width
465 + linkUrlTable.getIntercellSpacing().width;
466 preferredWidth = Math.max(preferredWidth, cwidth);
468 tableColumn.setPreferredWidth(preferredWidth);
472 useProxy.setSelected(Cache.getDefault("USE_PROXY", false));
473 useProxy_actionPerformed(); // make sure useProxy is correctly initialised
474 proxyServerTB.setText(Cache.getDefault("PROXY_SERVER", ""));
475 proxyPortTB.setText(Cache.getDefault("PROXY_PORT", ""));
477 defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
479 usagestats.setSelected(Cache.getDefault("USAGESTATS", false));
480 // note antisense here: default is true
482 .setSelected(Cache.getProperty("NOQUESTIONNAIRES") == null);
483 versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true));
486 * Set Output tab defaults
488 epsRendering.addItem(promptEachTimeOpt);
489 epsRendering.addItem(lineArtOpt);
490 epsRendering.addItem(textOpt);
491 String defaultEPS = Cache.getDefault("EPS_RENDERING",
493 if (defaultEPS.equalsIgnoreCase("Text"))
495 epsRendering.setSelectedItem(textOpt);
497 else if (defaultEPS.equalsIgnoreCase("Lineart"))
499 epsRendering.setSelectedItem(lineArtOpt);
503 epsRendering.setSelectedItem(promptEachTimeOpt);
505 autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
506 userIdWidth.setEnabled(!autoIdWidth.isSelected());
507 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
508 Integer wi = Cache.getIntegerProperty("FIGURE_USERIDWIDTH");
509 userIdWidth.setText(wi == null ? "" : wi.toString());
510 blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
511 clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
512 fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
513 msfjv.setSelected(Cache.getDefault("MSF_JVSUFFIX", true));
514 pfamjv.setSelected(Cache.getDefault("PFAM_JVSUFFIX", true));
515 pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true));
516 pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true));
517 modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false));
518 embbedBioJSON.setSelected(Cache.getDefault("EXPORT_EMBBED_BIOJSON",
522 * Set Editing tab defaults
524 autoCalculateConsCheck.setSelected(Cache.getDefault(
525 "AUTO_CALC_CONSENSUS", true));
526 padGaps.setSelected(Cache.getDefault("PAD_GAPS", false));
527 sortByTree.setSelected(Cache.getDefault("SORT_BY_TREE", false));
529 annotations_actionPerformed(null); // update the display of the annotation
534 * Save user selections on the Preferences tabs to the Cache and write out to
540 public void ok_actionPerformed(ActionEvent e)
542 if (!validateSettings())
548 * Save Visual settings
550 Cache.applicationProperties.setProperty("SHOW_JVSUFFIX",
551 Boolean.toString(seqLimit.isSelected()));
552 Cache.applicationProperties.setProperty("RIGHT_ALIGN_IDS",
553 Boolean.toString(rightAlign.isSelected()));
554 Cache.applicationProperties.setProperty("SHOW_FULLSCREEN",
555 Boolean.toString(fullScreen.isSelected()));
556 Cache.applicationProperties.setProperty("SHOW_OVERVIEW",
557 Boolean.toString(openoverv.isSelected()));
558 Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
559 Boolean.toString(annotations.isSelected()));
560 Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
561 Boolean.toString(conservation.isSelected()));
562 Cache.applicationProperties.setProperty("SHOW_QUALITY",
563 Boolean.toString(quality.isSelected()));
564 Cache.applicationProperties.setProperty("SHOW_IDENTITY",
565 Boolean.toString(identity.isSelected()));
567 Cache.applicationProperties.setProperty("GAP_SYMBOL", gapSymbolCB
568 .getSelectedItem().toString());
570 Cache.applicationProperties.setProperty("FONT_NAME", fontNameCB
571 .getSelectedItem().toString());
572 Cache.applicationProperties.setProperty("FONT_STYLE", fontStyleCB
573 .getSelectedItem().toString());
574 Cache.applicationProperties.setProperty("FONT_SIZE", fontSizeCB
575 .getSelectedItem().toString());
577 Cache.applicationProperties.setProperty("ID_ITALICS",
578 Boolean.toString(idItalics.isSelected()));
579 Cache.applicationProperties.setProperty("SHOW_UNCONSERVED",
580 Boolean.toString(showUnconserved.isSelected()));
581 Cache.applicationProperties.setProperty(SHOW_OCCUPANCY,
582 Boolean.toString(showOccupancy.isSelected()));
583 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSENSUS",
584 Boolean.toString(showGroupConsensus.isSelected()));
585 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSERVATION",
586 Boolean.toString(showGroupConservation.isSelected()));
587 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_HISTOGRAM",
588 Boolean.toString(showConsensHistogram.isSelected()));
589 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_LOGO",
590 Boolean.toString(showConsensLogo.isSelected()));
591 Cache.applicationProperties.setProperty("SHOW_INFORMATION_HISTOGRAM",
592 Boolean.toString(showConsensHistogram.isSelected()));
593 Cache.applicationProperties.setProperty("SHOW_HMM_LOGO",
594 Boolean.toString(showHMMLogo.isSelected()));
595 Cache.applicationProperties.setProperty("ANTI_ALIAS",
596 Boolean.toString(smoothFont.isSelected()));
597 Cache.applicationProperties.setProperty(SCALE_PROTEIN_TO_CDNA,
598 Boolean.toString(scaleProteinToCdna.isSelected()));
599 Cache.applicationProperties.setProperty("SHOW_NPFEATS_TOOLTIP",
600 Boolean.toString(showNpTooltip.isSelected()));
601 Cache.applicationProperties.setProperty("SHOW_DBREFS_TOOLTIP",
602 Boolean.toString(showDbRefTooltip.isSelected()));
604 Cache.applicationProperties.setProperty("WRAP_ALIGNMENT",
605 Boolean.toString(wrap.isSelected()));
607 Cache.applicationProperties.setProperty("STARTUP_FILE",
608 startupFileTextfield.getText());
609 Cache.applicationProperties.setProperty("SHOW_STARTUP_FILE",
610 Boolean.toString(startupCheckbox.isSelected()));
612 Cache.applicationProperties.setProperty("SORT_ALIGNMENT", sortby
613 .getSelectedItem().toString());
615 // convert description of sort order to enum name for save
616 SequenceAnnotationOrder annSortOrder = SequenceAnnotationOrder
617 .forDescription(sortAnnBy.getSelectedItem().toString());
618 if (annSortOrder != null)
620 Cache.applicationProperties.setProperty(SORT_ANNOTATIONS,
621 annSortOrder.name());
624 final boolean showAutocalcFirst = sortAutocalc.getSelectedIndex() == 0;
625 Cache.applicationProperties.setProperty(SHOW_AUTOCALC_ABOVE, Boolean
626 .valueOf(showAutocalcFirst).toString());
629 * Save Colours settings
631 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_PROT, protColour
632 .getSelectedItem().toString());
633 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_NUC, nucColour
634 .getSelectedItem().toString());
635 Cache.setColourProperty("ANNOTATIONCOLOUR_MIN",
636 minColour.getBackground());
637 Cache.setColourProperty("ANNOTATIONCOLOUR_MAX",
638 maxColour.getBackground());
641 * Save Structure settings
643 Cache.applicationProperties.setProperty(ADD_TEMPFACT_ANN,
644 Boolean.toString(addTempFactor.isSelected()));
645 Cache.applicationProperties.setProperty(ADD_SS_ANN,
646 Boolean.toString(addSecondaryStructure.isSelected()));
647 Cache.applicationProperties.setProperty(USE_RNAVIEW,
648 Boolean.toString(useRnaView.isSelected()));
649 Cache.applicationProperties.setProperty(STRUCT_FROM_PDB,
650 Boolean.toString(structFromPdb.isSelected()));
651 Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY, structViewer
652 .getSelectedItem().toString());
653 Cache.setOrRemove(CHIMERA_PATH, chimeraPath.getText());
654 Cache.applicationProperties.setProperty("MAP_WITH_SIFTS",
655 Boolean.toString(siftsMapping.isSelected()));
656 SiftsSettings.setMapWithSifts(siftsMapping.isSelected());
659 * Save Output settings
661 Cache.applicationProperties.setProperty("EPS_RENDERING",
662 ((OptionsParam) epsRendering.getSelectedItem()).getCode());
665 * Save Connections settings
667 Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
669 jalview.util.BrowserLauncher.resetBrowser();
671 // save user-defined and selected links
672 String menuLinks = sequenceUrlLinks.writeUrlsAsString(true);
673 if (menuLinks.isEmpty())
675 Cache.applicationProperties.remove("SEQUENCE_LINKS");
679 Cache.applicationProperties.setProperty("SEQUENCE_LINKS",
680 menuLinks.toString());
683 String nonMenuLinks = sequenceUrlLinks.writeUrlsAsString(false);
684 if (nonMenuLinks.isEmpty())
686 Cache.applicationProperties.remove("STORED_LINKS");
690 Cache.applicationProperties.setProperty("STORED_LINKS",
691 nonMenuLinks.toString());
694 Cache.applicationProperties.setProperty("DEFAULT_URL",
695 sequenceUrlLinks.getPrimaryUrlId());
697 Cache.applicationProperties.setProperty("USE_PROXY",
698 Boolean.toString(useProxy.isSelected()));
700 Cache.setOrRemove("PROXY_SERVER", proxyServerTB.getText());
702 Cache.setOrRemove("PROXY_PORT", proxyPortTB.getText());
704 if (useProxy.isSelected())
706 System.setProperty("http.proxyHost", proxyServerTB.getText());
707 System.setProperty("http.proxyPort", proxyPortTB.getText());
711 System.setProperty("http.proxyHost", "");
712 System.setProperty("http.proxyPort", "");
714 Cache.setProperty("VERSION_CHECK",
715 Boolean.toString(versioncheck.isSelected()));
716 if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
718 // default is false - we only set this if the user has actively agreed
719 Cache.setProperty("USAGESTATS",
720 Boolean.toString(usagestats.isSelected()));
722 if (!questionnaire.isSelected())
724 Cache.setProperty("NOQUESTIONNAIRES", "true");
728 // special - made easy to edit a property file to disable questionnaires
729 // by just adding the given line
730 Cache.removeProperty("NOQUESTIONNAIRES");
734 * Save Output settings
736 Cache.applicationProperties.setProperty("BLC_JVSUFFIX",
737 Boolean.toString(blcjv.isSelected()));
738 Cache.applicationProperties.setProperty("CLUSTAL_JVSUFFIX",
739 Boolean.toString(clustaljv.isSelected()));
740 Cache.applicationProperties.setProperty("FASTA_JVSUFFIX",
741 Boolean.toString(fastajv.isSelected()));
742 Cache.applicationProperties.setProperty("MSF_JVSUFFIX",
743 Boolean.toString(msfjv.isSelected()));
744 Cache.applicationProperties.setProperty("PFAM_JVSUFFIX",
745 Boolean.toString(pfamjv.isSelected()));
746 Cache.applicationProperties.setProperty("PILEUP_JVSUFFIX",
747 Boolean.toString(pileupjv.isSelected()));
748 Cache.applicationProperties.setProperty("PIR_JVSUFFIX",
749 Boolean.toString(pirjv.isSelected()));
750 Cache.applicationProperties.setProperty("PIR_MODELLER",
751 Boolean.toString(modellerOutput.isSelected()));
752 Cache.applicationProperties.setProperty("EXPORT_EMBBED_BIOJSON",
753 Boolean.toString(embbedBioJSON.isSelected()));
754 jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
756 Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH",
757 Boolean.toString(autoIdWidth.isSelected()));
758 userIdWidth_actionPerformed();
759 Cache.applicationProperties.setProperty("FIGURE_USERIDWIDTH",
760 userIdWidth.getText());
763 * Save Editing settings
765 Cache.applicationProperties.setProperty("AUTO_CALC_CONSENSUS",
766 Boolean.toString(autoCalculateConsCheck.isSelected()));
767 Cache.applicationProperties.setProperty("SORT_BY_TREE",
768 Boolean.toString(sortByTree.isSelected()));
769 Cache.applicationProperties.setProperty("PAD_GAPS",
770 Boolean.toString(padGaps.isSelected()));
772 dasSource.saveProperties(Cache.applicationProperties);
773 wsPrefs.updateAndRefreshWsMenuConfig(false);
774 Cache.saveProperties();
775 Desktop.instance.doConfigureStructurePrefs();
778 frame.setClosed(true);
779 } catch (Exception ex)
785 * Do any necessary validation before saving settings. Return focus to the
786 * first tab which fails validation.
790 private boolean validateSettings()
792 if (!validateStructure())
794 structureTab.requestFocusInWindow();
801 protected boolean validateStructure()
803 return validateChimeraPath();
811 public void startupFileTextfield_mouseClicked()
813 String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
814 JalviewFileChooser chooser = JalviewFileChooser.forRead(
815 Cache.getProperty("LAST_DIRECTORY"), fileFormat);
816 chooser.setFileView(new JalviewFileView());
817 chooser.setDialogTitle(MessageManager
818 .getString("label.select_startup_file"));
820 int value = chooser.showOpenDialog(this);
822 if (value == JalviewFileChooser.APPROVE_OPTION)
824 FileFormatI format = chooser.getSelectedFormat();
827 Cache.applicationProperties.setProperty("DEFAULT_FILE_FORMAT",
830 startupFileTextfield.setText(chooser.getSelectedFile()
842 public void cancel_actionPerformed(ActionEvent e)
846 wsPrefs.updateWsMenuConfig(true);
847 wsPrefs.refreshWs_actionPerformed(e);
848 frame.setClosed(true);
849 } catch (Exception ex)
861 public void annotations_actionPerformed(ActionEvent e)
863 conservation.setEnabled(annotations.isSelected());
864 quality.setEnabled(annotations.isSelected());
865 identity.setEnabled(annotations.isSelected());
866 showOccupancy.setEnabled(annotations.isSelected());
867 showGroupConsensus.setEnabled(annotations.isSelected());
868 showGroupConservation.setEnabled(annotations.isSelected());
869 showConsensHistogram.setEnabled(annotations.isSelected()
870 && (identity.isSelected() || showGroupConsensus.isSelected()));
871 showConsensLogo.setEnabled(annotations.isSelected()
872 && (identity.isSelected() || showGroupConsensus.isSelected()));
873 showInformationHistogram.setEnabled(annotations.isSelected());
874 showHMMLogo.setEnabled(annotations.isSelected());
878 public void newLink_actionPerformed(ActionEvent e)
880 GSequenceLink link = new GSequenceLink();
881 boolean valid = false;
884 if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
885 MessageManager.getString("label.new_sequence_url_link"),
886 JvOptionPane.OK_CANCEL_OPTION, -1, null) == JvOptionPane.OK_OPTION)
888 if (link.checkValid())
890 if (((UrlLinkTableModel) linkUrlTable.getModel())
891 .isUniqueName(link.getName()))
893 ((UrlLinkTableModel) linkUrlTable.getModel()).insertRow(
894 link.getName(), link.getURL());
899 link.notifyDuplicate();
912 public void editLink_actionPerformed(ActionEvent e)
914 GSequenceLink link = new GSequenceLink();
916 int index = linkUrlTable.getSelectedRow();
919 // button no longer enabled if row is not selected
920 Cache.log.debug("Edit with no row selected in linkUrlTable");
924 int nameCol = ((UrlLinkTableModel) linkUrlTable.getModel())
926 int urlCol = ((UrlLinkTableModel) linkUrlTable.getModel())
928 String oldName = linkUrlTable.getValueAt(index, nameCol).toString();
929 link.setName(oldName);
930 link.setURL(linkUrlTable.getValueAt(index, urlCol).toString());
932 boolean valid = false;
935 if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
936 MessageManager.getString("label.edit_sequence_url_link"),
937 JvOptionPane.OK_CANCEL_OPTION, -1, null) == JvOptionPane.OK_OPTION)
939 if (link.checkValid())
941 if ((oldName.equals(link.getName()))
942 || (((UrlLinkTableModel) linkUrlTable.getModel())
943 .isUniqueName(link.getName())))
945 linkUrlTable.setValueAt(link.getName(), index, nameCol);
946 linkUrlTable.setValueAt(link.getURL(), index, urlCol);
951 link.notifyDuplicate();
964 public void deleteLink_actionPerformed(ActionEvent e)
966 int index = linkUrlTable.getSelectedRow();
970 // button no longer enabled if row is not selected
971 Cache.log.debug("Delete with no row selected in linkUrlTable");
976 modelIndex = linkUrlTable.convertRowIndexToModel(index);
979 // make sure we use the model index to delete, and not the table index
980 ((UrlLinkTableModel) linkUrlTable.getModel()).removeRow(modelIndex);
985 public void defaultBrowser_mouseClicked(MouseEvent e)
987 JFileChooser chooser = new JFileChooser(".");
988 chooser.setDialogTitle(MessageManager
989 .getString("label.select_default_browser"));
991 int value = chooser.showOpenDialog(this);
993 if (value == JFileChooser.APPROVE_OPTION)
995 defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath());
1004 * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event
1008 protected void showunconserved_actionPerformed(ActionEvent e)
1010 // TODO Auto-generated method stub
1011 super.showunconserved_actionPerformed(e);
1014 public static List<String> getGroupURLLinks()
1016 return groupURLLinks;
1020 public void minColour_actionPerformed(JPanel panel)
1022 Color col = JColorChooser.showDialog(this,
1023 MessageManager.getString("label.select_colour_minimum_value"),
1024 minColour.getBackground());
1027 panel.setBackground(col);
1033 public void maxColour_actionPerformed(JPanel panel)
1035 Color col = JColorChooser.showDialog(this,
1036 MessageManager.getString("label.select_colour_maximum_value"),
1037 maxColour.getBackground());
1040 panel.setBackground(col);
1046 protected void userIdWidth_actionPerformed()
1050 String val = userIdWidth.getText().trim();
1051 if (val.length() > 0)
1053 Integer iw = Integer.parseInt(val);
1054 if (iw.intValue() < 12)
1056 throw new NumberFormatException();
1058 userIdWidth.setText(iw.toString());
1060 } catch (NumberFormatException x)
1062 JvOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
1063 .getString("warn.user_defined_width_requirements"),
1064 MessageManager.getString("label.invalid_id_column_width"),
1065 JvOptionPane.WARNING_MESSAGE);
1066 userIdWidth.setText("");
1071 protected void autoIdWidth_actionPerformed()
1073 userIdWidth.setEnabled(!autoIdWidth.isSelected());
1074 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
1078 * Returns true if chimera path is to a valid executable, else show an error
1081 private boolean validateChimeraPath()
1083 if (chimeraPath.getText().trim().length() > 0)
1085 File f = new File(chimeraPath.getText());
1086 if (!f.canExecute())
1088 JvOptionPane.showInternalMessageDialog(Desktop.desktop,
1089 MessageManager.getString("label.invalid_chimera_path"),
1090 MessageManager.getString("label.invalid_name"),
1091 JvOptionPane.ERROR_MESSAGE);
1099 * If Chimera is selected, check it can be found on default or user-specified
1100 * path, if not show a warning/help dialog.
1103 protected void structureViewer_actionPerformed(String selectedItem)
1105 if (!selectedItem.equals(ViewerType.CHIMERA.name()))
1109 boolean found = false;
1112 * Try user-specified and standard paths for Chimera executable.
1114 List<String> paths = StructureManager.getChimeraPaths();
1115 paths.add(0, chimeraPath.getText());
1116 for (String path : paths)
1118 if (new File(path.trim()).canExecute())
1126 String[] options = { "OK", "Help" };
1127 int showHelp = JvOptionPane.showInternalOptionDialog(
1129 JvSwingUtils.wrapTooltip(true,
1130 MessageManager.getString("label.chimera_missing")),
1131 "", JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE,
1132 null, options, options[0]);
1133 if (showHelp == JvOptionPane.NO_OPTION)
1137 Help.showHelpWindow(HelpId.StructureViewer);
1138 } catch (HelpSetException e)
1140 e.printStackTrace();
1146 public class OptionsParam
1148 private String name;
1150 private String code;
1152 public OptionsParam(String name, String code)
1158 public String getName()
1163 public void setName(String name)
1168 public String getCode()
1173 public void setCode(String code)
1179 public String toString()
1185 public boolean equals(Object that)
1187 if (!(that instanceof OptionsParam))
1191 return this.code.equalsIgnoreCase(((OptionsParam) that).code);
1195 public int hashCode()
1197 return name.hashCode() + code.hashCode();
1201 private class UrlListSelectionHandler implements ListSelectionListener
1205 public void valueChanged(ListSelectionEvent e)
1207 ListSelectionModel lsm = (ListSelectionModel) e.getSource();
1209 int index = lsm.getMinSelectionIndex();
1212 // no selection, so disable delete/edit buttons
1213 editLink.setEnabled(false);
1214 deleteLink.setEnabled(false);
1217 int modelIndex = linkUrlTable.convertRowIndexToModel(index);
1219 // enable/disable edit and delete link buttons
1220 if (((UrlLinkTableModel) linkUrlTable.getModel())
1221 .isRowDeletable(modelIndex))
1223 deleteLink.setEnabled(true);
1227 deleteLink.setEnabled(false);
1230 if (((UrlLinkTableModel) linkUrlTable.getModel())
1231 .isRowEditable(modelIndex))
1233 editLink.setEnabled(true);
1237 editLink.setEnabled(false);