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 static jalview.util.UrlConstants.DB_ACCESSION;
24 import static jalview.util.UrlConstants.EMBLEBI_STRING;
25 import static jalview.util.UrlConstants.SEQUENCE_ID;
26 import static jalview.util.UrlConstants.SRS_STRING;
28 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
29 import jalview.bin.Cache;
30 import jalview.gui.Help.HelpId;
31 import jalview.gui.StructureViewer.ViewerType;
32 import jalview.io.FileFormatI;
33 import jalview.io.JalviewFileChooser;
34 import jalview.io.JalviewFileView;
35 import jalview.jbgui.GPreferences;
36 import jalview.jbgui.GSequenceLink;
37 import jalview.schemes.ColourSchemeProperty;
38 import jalview.util.MessageManager;
39 import jalview.util.Platform;
40 import jalview.ws.sifts.SiftsSettings;
42 import java.awt.BorderLayout;
43 import java.awt.Color;
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;
52 import java.util.StringTokenizer;
53 import java.util.Vector;
55 import javax.help.HelpSetException;
56 import javax.swing.JColorChooser;
57 import javax.swing.JFileChooser;
58 import javax.swing.JInternalFrame;
59 import javax.swing.JOptionPane;
60 import javax.swing.JPanel;
62 import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
70 public class Preferences extends GPreferences
72 public static final String ENABLE_SPLIT_FRAME = "ENABLE_SPLIT_FRAME";
74 public static final String SCALE_PROTEIN_TO_CDNA = "SCALE_PROTEIN_TO_CDNA";
76 public static final String DEFAULT_COLOUR = "DEFAULT_COLOUR";
78 public static final String DEFAULT_COLOUR_PROT = "DEFAULT_COLOUR_PROT";
80 public static final String DEFAULT_COLOUR_NUC = "DEFAULT_COLOUR_NUC";
82 public static final String ADD_TEMPFACT_ANN = "ADD_TEMPFACT_ANN";
84 public static final String ADD_SS_ANN = "ADD_SS_ANN";
86 public static final String USE_RNAVIEW = "USE_RNAVIEW";
88 public static final String STRUCT_FROM_PDB = "STRUCT_FROM_PDB";
90 public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY";
92 public static final String CHIMERA_PATH = "CHIMERA_PATH";
94 public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS";
96 public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE";
98 private static final int MIN_FONT_SIZE = 1;
100 private static final int MAX_FONT_SIZE = 30;
103 * Holds name and link separated with | character. Sequence ID must be
104 * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$
106 public static Vector<String> sequenceURLLinks;
109 * Holds name and link separated with | character. Sequence IDS and Sequences
110 * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and
111 * $SEQUENCES$ or $SEQUENCES=/.possible | chars ./=$ and separation character
112 * for first and second token specified after a pipe character at end |,|.
113 * (TODO: proper escape for using | to separate ids or sequences
116 public static List<String> groupURLLinks;
119 String string = Cache.getDefault("SEQUENCE_LINKS", EMBLEBI_STRING);
120 sequenceURLLinks = new Vector<String>();
124 StringTokenizer st = new StringTokenizer(string, "|");
125 while (st.hasMoreElements())
127 String name = st.nextToken();
128 String url = st.nextToken();
129 // check for '|' within a regex
130 int rxstart = url.indexOf("$" + DB_ACCESSION + "$");
133 rxstart = url.indexOf("$" + SEQUENCE_ID + "$");
135 while (rxstart == -1 && url.indexOf("/=$") == -1)
137 url = url + "|" + st.nextToken();
139 sequenceURLLinks.addElement(name + "|" + url);
141 } catch (Exception ex)
143 System.out.println(ex + "\nError parsing sequence links");
146 // upgrade old SRS link
147 int srsPos = sequenceURLLinks.indexOf(SRS_STRING);
150 sequenceURLLinks.setElementAt(EMBLEBI_STRING, srsPos);
155 * TODO: reformulate groupURL encoding so two or more can be stored in the
156 * .properties file as '|' separated strings
159 groupURLLinks = new ArrayList<String>();
162 Vector<String> nameLinks, urlLinks;
164 JInternalFrame frame;
166 DasSourceBrowser dasSource;
168 private WsPreferences wsPrefs;
170 private OptionsParam promptEachTimeOpt = new OptionsParam(
171 MessageManager.getString("label.prompt_each_time"),
174 private OptionsParam lineArtOpt = new OptionsParam(
175 MessageManager.getString("label.lineart"), "Lineart");
177 private OptionsParam textOpt = new OptionsParam(
178 MessageManager.getString("action.text"), "Text");
181 * Creates a new Preferences object.
186 frame = new JInternalFrame();
187 frame.setContentPane(this);
188 dasSource = new DasSourceBrowser();
189 dasTab.add(dasSource, BorderLayout.CENTER);
190 wsPrefs = new WsPreferences();
191 wsTab.add(wsPrefs, BorderLayout.CENTER);
192 int width = 500, height = 450;
193 new jalview.util.Platform();
194 if (Platform.isAMac())
200 Desktop.addInternalFrame(frame,
201 MessageManager.getString("label.preferences"), width, height);
202 frame.setMinimumSize(new Dimension(width, height));
205 * Set Visual tab defaults
207 seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true));
208 rightAlign.setSelected(Cache.getDefault("RIGHT_ALIGN_IDS", false));
209 fullScreen.setSelected(Cache.getDefault("SHOW_FULLSCREEN", false));
210 annotations.setSelected(Cache.getDefault("SHOW_ANNOTATIONS", true));
212 conservation.setSelected(Cache.getDefault("SHOW_CONSERVATION", true));
213 quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));
214 identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
215 openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false));
217 .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
218 showGroupConsensus.setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS",
220 showGroupConservation.setSelected(Cache.getDefault(
221 "SHOW_GROUP_CONSERVATION", false));
222 showConsensHistogram.setSelected(Cache.getDefault(
223 "SHOW_CONSENSUS_HISTOGRAM", true));
224 showConsensLogo.setSelected(Cache.getDefault("SHOW_CONSENSUS_LOGO",
226 showNpTooltip.setSelected(Cache
227 .getDefault("SHOW_NPFEATS_TOOLTIP", true));
228 showDbRefTooltip.setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP",
231 String[] fonts = java.awt.GraphicsEnvironment
232 .getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
233 for (int i = 0; i < fonts.length; i++)
235 fontNameCB.addItem(fonts[i]);
238 for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++)
240 fontSizeCB.addItem(i + "");
243 fontStyleCB.addItem("plain");
244 fontStyleCB.addItem("bold");
245 fontStyleCB.addItem("italic");
247 fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif"));
248 fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10"));
249 fontStyleCB.setSelectedItem(Cache.getDefault("FONT_STYLE", Font.PLAIN
252 smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", false));
253 scaleProteinToCdna.setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA,
256 idItalics.setSelected(Cache.getDefault("ID_ITALICS", true));
258 wrap.setSelected(Cache.getDefault("WRAP_ALIGNMENT", false));
260 gapSymbolCB.addItem("-");
261 gapSymbolCB.addItem(".");
263 gapSymbolCB.setSelectedItem(Cache.getDefault("GAP_SYMBOL", "-"));
265 sortby.addItem("No sort");
266 sortby.addItem("Id");
267 sortby.addItem("Pairwise Identity");
268 sortby.setSelectedItem(Cache.getDefault("SORT_ALIGNMENT", "No sort"));
270 sortAnnBy.addItem(SequenceAnnotationOrder.NONE.toString());
272 .addItem(SequenceAnnotationOrder.SEQUENCE_AND_LABEL.toString());
274 .addItem(SequenceAnnotationOrder.LABEL_AND_SEQUENCE.toString());
275 SequenceAnnotationOrder savedSort = SequenceAnnotationOrder
276 .valueOf(Cache.getDefault(SORT_ANNOTATIONS,
277 SequenceAnnotationOrder.NONE.name()));
278 sortAnnBy.setSelectedItem(savedSort.toString());
280 sortAutocalc.addItem("Autocalculated first");
281 sortAutocalc.addItem("Autocalculated last");
282 final boolean showAbove = Cache.getDefault(SHOW_AUTOCALC_ABOVE, true);
283 sortAutocalc.setSelectedItem(showAbove ? sortAutocalc.getItemAt(0)
284 : sortAutocalc.getItemAt(1));
286 .setSelected(Cache.getDefault("SHOW_STARTUP_FILE", true));
287 startupFileTextfield.setText(Cache.getDefault("STARTUP_FILE",
288 Cache.getDefault("www.jalview.org", "http://www.jalview.org")
289 + "/examples/exampleFile_2_3.jar"));
292 * Set Colours tab defaults
294 for (int i = ColourSchemeProperty.FIRST_COLOUR; i <= ColourSchemeProperty.LAST_COLOUR; i++)
296 protColour.addItem(ColourSchemeProperty.getColourName(i));
297 nucColour.addItem(ColourSchemeProperty.getColourName(i));
299 String oldProp = Cache.getDefault(DEFAULT_COLOUR, "None");
300 String newProp = Cache.getDefault(DEFAULT_COLOUR_PROT, null);
301 protColour.setSelectedItem(newProp != null ? newProp : oldProp);
302 newProp = Cache.getDefault(DEFAULT_COLOUR_NUC, null);
303 nucColour.setSelectedItem(newProp != null ? newProp : oldProp);
304 minColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN",
306 maxColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX",
310 * Set Structure tab defaults.
312 final boolean structSelected = Cache.getDefault(STRUCT_FROM_PDB, false);
313 structFromPdb.setSelected(structSelected);
314 useRnaView.setSelected(Cache.getDefault(USE_RNAVIEW, false));
315 useRnaView.setEnabled(structSelected);
316 addSecondaryStructure.setSelected(Cache.getDefault(ADD_SS_ANN, false));
317 addSecondaryStructure.setEnabled(structSelected);
318 addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, false));
319 addTempFactor.setEnabled(structSelected);
320 structViewer.setSelectedItem(Cache.getDefault(STRUCTURE_DISPLAY,
321 ViewerType.JMOL.name()));
322 chimeraPath.setText(Cache.getDefault(CHIMERA_PATH, ""));
323 chimeraPath.addActionListener(new ActionListener()
326 public void actionPerformed(ActionEvent e)
328 validateChimeraPath();
332 if (Cache.getDefault("MAP_WITH_SIFTS", false))
334 siftsMapping.setSelected(true);
338 nwMapping.setSelected(true);
342 .setMapWithSifts(Cache.getDefault("MAP_WITH_SIFTS", false));
345 * Set Connections tab defaults
347 nameLinks = new Vector<String>();
348 urlLinks = new Vector<String>();
349 for (int i = 0; i < sequenceURLLinks.size(); i++)
351 String link = sequenceURLLinks.elementAt(i).toString();
352 nameLinks.addElement(link.substring(0, link.indexOf("|")));
353 urlLinks.addElement(link.substring(link.indexOf("|") + 1));
358 useProxy.setSelected(Cache.getDefault("USE_PROXY", false));
359 proxyServerTB.setEnabled(useProxy.isSelected());
360 proxyPortTB.setEnabled(useProxy.isSelected());
361 proxyServerTB.setText(Cache.getDefault("PROXY_SERVER", ""));
362 proxyPortTB.setText(Cache.getDefault("PROXY_PORT", ""));
364 defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
366 usagestats.setSelected(Cache.getDefault("USAGESTATS", false));
367 // note antisense here: default is true
369 .setSelected(Cache.getProperty("NOQUESTIONNAIRES") == null);
370 versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true));
373 * Set Output tab defaults
375 epsRendering.addItem(promptEachTimeOpt);
376 epsRendering.addItem(lineArtOpt);
377 epsRendering.addItem(textOpt);
378 String defaultEPS = Cache.getDefault("EPS_RENDERING",
380 if (defaultEPS.equalsIgnoreCase("Text"))
382 epsRendering.setSelectedItem(textOpt);
384 else if (defaultEPS.equalsIgnoreCase("Lineart"))
386 epsRendering.setSelectedItem(lineArtOpt);
390 epsRendering.setSelectedItem(promptEachTimeOpt);
392 autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
393 userIdWidth.setEnabled(!autoIdWidth.isSelected());
394 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
395 Integer wi = Cache.getIntegerProperty("FIGURE_USERIDWIDTH");
396 userIdWidth.setText(wi == null ? "" : wi.toString());
397 blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
398 clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
399 fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
400 msfjv.setSelected(Cache.getDefault("MSF_JVSUFFIX", true));
401 pfamjv.setSelected(Cache.getDefault("PFAM_JVSUFFIX", true));
402 pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true));
403 pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true));
404 modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false));
405 embbedBioJSON.setSelected(Cache.getDefault("EXPORT_EMBBED_BIOJSON",
409 * Set Editing tab defaults
411 autoCalculateConsCheck.setSelected(Cache.getDefault(
412 "AUTO_CALC_CONSENSUS", true));
413 padGaps.setSelected(Cache.getDefault("PAD_GAPS", false));
414 sortByTree.setSelected(Cache.getDefault("SORT_BY_TREE", false));
416 annotations_actionPerformed(null); // update the display of the annotation
421 * Save user selections on the Preferences tabs to the Cache and write out to
427 public void ok_actionPerformed(ActionEvent e)
429 if (!validateSettings())
435 * Save Visual settings
437 Cache.applicationProperties.setProperty("SHOW_JVSUFFIX",
438 Boolean.toString(seqLimit.isSelected()));
439 Cache.applicationProperties.setProperty("RIGHT_ALIGN_IDS",
440 Boolean.toString(rightAlign.isSelected()));
441 Cache.applicationProperties.setProperty("SHOW_FULLSCREEN",
442 Boolean.toString(fullScreen.isSelected()));
443 Cache.applicationProperties.setProperty("SHOW_OVERVIEW",
444 Boolean.toString(openoverv.isSelected()));
445 Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
446 Boolean.toString(annotations.isSelected()));
447 Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
448 Boolean.toString(conservation.isSelected()));
449 Cache.applicationProperties.setProperty("SHOW_QUALITY",
450 Boolean.toString(quality.isSelected()));
451 Cache.applicationProperties.setProperty("SHOW_IDENTITY",
452 Boolean.toString(identity.isSelected()));
454 Cache.applicationProperties.setProperty("GAP_SYMBOL", gapSymbolCB
455 .getSelectedItem().toString());
457 Cache.applicationProperties.setProperty("FONT_NAME", fontNameCB
458 .getSelectedItem().toString());
459 Cache.applicationProperties.setProperty("FONT_STYLE", fontStyleCB
460 .getSelectedItem().toString());
461 Cache.applicationProperties.setProperty("FONT_SIZE", fontSizeCB
462 .getSelectedItem().toString());
464 Cache.applicationProperties.setProperty("ID_ITALICS",
465 Boolean.toString(idItalics.isSelected()));
466 Cache.applicationProperties.setProperty("SHOW_UNCONSERVED",
467 Boolean.toString(showUnconserved.isSelected()));
468 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSENSUS",
469 Boolean.toString(showGroupConsensus.isSelected()));
470 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSERVATION",
471 Boolean.toString(showGroupConservation.isSelected()));
472 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_HISTOGRAM",
473 Boolean.toString(showConsensHistogram.isSelected()));
474 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_LOGO",
475 Boolean.toString(showConsensLogo.isSelected()));
476 Cache.applicationProperties.setProperty("ANTI_ALIAS",
477 Boolean.toString(smoothFont.isSelected()));
478 Cache.applicationProperties.setProperty(SCALE_PROTEIN_TO_CDNA,
479 Boolean.toString(scaleProteinToCdna.isSelected()));
480 Cache.applicationProperties.setProperty("SHOW_NPFEATS_TOOLTIP",
481 Boolean.toString(showNpTooltip.isSelected()));
482 Cache.applicationProperties.setProperty("SHOW_DBREFS_TOOLTIP",
483 Boolean.toString(showDbRefTooltip.isSelected()));
485 Cache.applicationProperties.setProperty("WRAP_ALIGNMENT",
486 Boolean.toString(wrap.isSelected()));
488 Cache.applicationProperties.setProperty("STARTUP_FILE",
489 startupFileTextfield.getText());
490 Cache.applicationProperties.setProperty("SHOW_STARTUP_FILE",
491 Boolean.toString(startupCheckbox.isSelected()));
493 Cache.applicationProperties.setProperty("SORT_ALIGNMENT", sortby
494 .getSelectedItem().toString());
496 // convert description of sort order to enum name for save
497 SequenceAnnotationOrder annSortOrder = SequenceAnnotationOrder
498 .forDescription(sortAnnBy.getSelectedItem().toString());
499 if (annSortOrder != null)
501 Cache.applicationProperties.setProperty(SORT_ANNOTATIONS,
502 annSortOrder.name());
505 final boolean showAutocalcFirst = sortAutocalc.getSelectedIndex() == 0;
506 Cache.applicationProperties.setProperty(SHOW_AUTOCALC_ABOVE, Boolean
507 .valueOf(showAutocalcFirst).toString());
510 * Save Colours settings
512 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_PROT, protColour
513 .getSelectedItem().toString());
514 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_NUC, nucColour
515 .getSelectedItem().toString());
516 Cache.setColourProperty("ANNOTATIONCOLOUR_MIN",
517 minColour.getBackground());
518 Cache.setColourProperty("ANNOTATIONCOLOUR_MAX",
519 maxColour.getBackground());
522 * Save Structure settings
524 Cache.applicationProperties.setProperty(ADD_TEMPFACT_ANN,
525 Boolean.toString(addTempFactor.isSelected()));
526 Cache.applicationProperties.setProperty(ADD_SS_ANN,
527 Boolean.toString(addSecondaryStructure.isSelected()));
528 Cache.applicationProperties.setProperty(USE_RNAVIEW,
529 Boolean.toString(useRnaView.isSelected()));
530 Cache.applicationProperties.setProperty(STRUCT_FROM_PDB,
531 Boolean.toString(structFromPdb.isSelected()));
532 Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY, structViewer
533 .getSelectedItem().toString());
534 Cache.setOrRemove(CHIMERA_PATH, chimeraPath.getText());
535 Cache.applicationProperties.setProperty("MAP_WITH_SIFTS",
536 Boolean.toString(siftsMapping.isSelected()));
537 SiftsSettings.setMapWithSifts(siftsMapping.isSelected());
540 * Save Output settings
542 Cache.applicationProperties.setProperty("EPS_RENDERING",
543 ((OptionsParam) epsRendering.getSelectedItem()).getCode());
546 * Save Connections settings
548 Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
550 jalview.util.BrowserLauncher.resetBrowser();
552 if (nameLinks.size() > 0)
554 StringBuffer links = new StringBuffer();
555 sequenceURLLinks = new Vector<String>();
556 for (int i = 0; i < nameLinks.size(); i++)
558 sequenceURLLinks.addElement(nameLinks.elementAt(i) + "|"
559 + urlLinks.elementAt(i));
560 links.append(sequenceURLLinks.elementAt(i).toString());
564 links.setLength(links.length() - 1);
565 Cache.applicationProperties.setProperty("SEQUENCE_LINKS",
570 Cache.applicationProperties.remove("SEQUENCE_LINKS");
571 sequenceURLLinks.clear();
574 Cache.applicationProperties.setProperty("USE_PROXY",
575 Boolean.toString(useProxy.isSelected()));
577 Cache.setOrRemove("PROXY_SERVER", proxyServerTB.getText());
579 Cache.setOrRemove("PROXY_PORT", proxyPortTB.getText());
581 if (useProxy.isSelected())
583 System.setProperty("http.proxyHost", proxyServerTB.getText());
584 System.setProperty("http.proxyPort", proxyPortTB.getText());
588 System.setProperty("http.proxyHost", "");
589 System.setProperty("http.proxyPort", "");
591 Cache.setProperty("VERSION_CHECK",
592 Boolean.toString(versioncheck.isSelected()));
593 if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
595 // default is false - we only set this if the user has actively agreed
596 Cache.setProperty("USAGESTATS",
597 Boolean.toString(usagestats.isSelected()));
599 if (!questionnaire.isSelected())
601 Cache.setProperty("NOQUESTIONNAIRES", "true");
605 // special - made easy to edit a property file to disable questionnaires
606 // by just adding the given line
607 Cache.removeProperty("NOQUESTIONNAIRES");
611 * Save Output settings
613 Cache.applicationProperties.setProperty("BLC_JVSUFFIX",
614 Boolean.toString(blcjv.isSelected()));
615 Cache.applicationProperties.setProperty("CLUSTAL_JVSUFFIX",
616 Boolean.toString(clustaljv.isSelected()));
617 Cache.applicationProperties.setProperty("FASTA_JVSUFFIX",
618 Boolean.toString(fastajv.isSelected()));
619 Cache.applicationProperties.setProperty("MSF_JVSUFFIX",
620 Boolean.toString(msfjv.isSelected()));
621 Cache.applicationProperties.setProperty("PFAM_JVSUFFIX",
622 Boolean.toString(pfamjv.isSelected()));
623 Cache.applicationProperties.setProperty("PILEUP_JVSUFFIX",
624 Boolean.toString(pileupjv.isSelected()));
625 Cache.applicationProperties.setProperty("PIR_JVSUFFIX",
626 Boolean.toString(pirjv.isSelected()));
627 Cache.applicationProperties.setProperty("PIR_MODELLER",
628 Boolean.toString(modellerOutput.isSelected()));
629 Cache.applicationProperties.setProperty("EXPORT_EMBBED_BIOJSON",
630 Boolean.toString(embbedBioJSON.isSelected()));
631 jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
633 Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH",
634 Boolean.toString(autoIdWidth.isSelected()));
635 userIdWidth_actionPerformed();
636 Cache.applicationProperties.setProperty("FIGURE_USERIDWIDTH",
637 userIdWidth.getText());
640 * Save Editing settings
642 Cache.applicationProperties.setProperty("AUTO_CALC_CONSENSUS",
643 Boolean.toString(autoCalculateConsCheck.isSelected()));
644 Cache.applicationProperties.setProperty("SORT_BY_TREE",
645 Boolean.toString(sortByTree.isSelected()));
646 Cache.applicationProperties.setProperty("PAD_GAPS",
647 Boolean.toString(padGaps.isSelected()));
649 dasSource.saveProperties(Cache.applicationProperties);
650 wsPrefs.updateAndRefreshWsMenuConfig(false);
651 Cache.saveProperties();
652 Desktop.instance.doConfigureStructurePrefs();
655 frame.setClosed(true);
656 } catch (Exception ex)
662 * Do any necessary validation before saving settings. Return focus to the
663 * first tab which fails validation.
667 private boolean validateSettings()
669 if (!validateStructure())
671 structureTab.requestFocusInWindow();
678 protected boolean validateStructure()
680 return validateChimeraPath();
688 public void startupFileTextfield_mouseClicked()
690 String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
691 JalviewFileChooser chooser = JalviewFileChooser.forRead(
692 Cache.getProperty("LAST_DIRECTORY"), fileFormat, true);
694 // "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc",
695 // "jar" }, new String[] { "Fasta", "Clustal", "PFAM", "MSF",
696 // "PIR", "BLC", "Jalview" },
698 chooser.setFileView(new JalviewFileView());
699 chooser.setDialogTitle(MessageManager
700 .getString("label.select_startup_file"));
702 int value = chooser.showOpenDialog(this);
704 if (value == JalviewFileChooser.APPROVE_OPTION)
706 FileFormatI format = chooser.getSelectedFormat();
709 Cache.applicationProperties.setProperty("DEFAULT_FILE_FORMAT",
712 startupFileTextfield.setText(chooser.getSelectedFile()
724 public void cancel_actionPerformed(ActionEvent e)
728 wsPrefs.updateWsMenuConfig(true);
729 wsPrefs.refreshWs_actionPerformed(e);
730 frame.setClosed(true);
731 } catch (Exception ex)
743 public void annotations_actionPerformed(ActionEvent e)
745 conservation.setEnabled(annotations.isSelected());
746 quality.setEnabled(annotations.isSelected());
747 identity.setEnabled(annotations.isSelected());
748 showGroupConsensus.setEnabled(annotations.isSelected());
749 showGroupConservation.setEnabled(annotations.isSelected());
750 showConsensHistogram.setEnabled(annotations.isSelected()
751 && (identity.isSelected() || showGroupConsensus.isSelected()));
752 showConsensLogo.setEnabled(annotations.isSelected()
753 && (identity.isSelected() || showGroupConsensus.isSelected()));
757 public void newLink_actionPerformed(ActionEvent e)
760 GSequenceLink link = new GSequenceLink();
761 boolean valid = false;
764 if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
765 MessageManager.getString("label.new_sequence_url_link"),
766 JvOptionPane.OK_CANCEL_OPTION, -1, null) == JvOptionPane.OK_OPTION)
768 if (link.checkValid())
770 nameLinks.addElement(link.getName());
771 urlLinks.addElement(link.getURL());
784 public void editLink_actionPerformed(ActionEvent e)
786 GSequenceLink link = new GSequenceLink();
788 int index = linkNameList.getSelectedIndex();
791 JvOptionPane.showInternalMessageDialog(Desktop.desktop,
792 MessageManager.getString("label.no_link_selected"),
793 MessageManager.getString("label.no_link_selected"),
794 JvOptionPane.WARNING_MESSAGE);
798 link.setName(nameLinks.elementAt(index).toString());
799 link.setURL(urlLinks.elementAt(index).toString());
801 boolean valid = false;
805 if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
806 MessageManager.getString("label.new_sequence_url_link"),
807 JvOptionPane.OK_CANCEL_OPTION, -1, null) == JvOptionPane.OK_OPTION)
809 if (link.checkValid())
811 nameLinks.setElementAt(link.getName(), index);
812 urlLinks.setElementAt(link.getURL(), index);
826 public void deleteLink_actionPerformed(ActionEvent e)
828 int index = linkNameList.getSelectedIndex();
831 JvOptionPane.showInternalMessageDialog(Desktop.desktop,
832 MessageManager.getString("label.no_link_selected"),
833 MessageManager.getString("label.no_link_selected"),
834 JvOptionPane.WARNING_MESSAGE);
837 nameLinks.removeElementAt(index);
838 urlLinks.removeElementAt(index);
842 void updateLinkData()
844 linkNameList.setListData(nameLinks);
845 linkURLList.setListData(urlLinks);
849 public void defaultBrowser_mouseClicked(MouseEvent e)
851 JFileChooser chooser = new JFileChooser(".");
852 chooser.setDialogTitle(MessageManager
853 .getString("label.select_default_browser"));
855 int value = chooser.showOpenDialog(this);
857 if (value == JFileChooser.APPROVE_OPTION)
859 defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath());
868 * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event
872 protected void showunconserved_actionPerformed(ActionEvent e)
874 // TODO Auto-generated method stub
875 super.showunconserved_actionPerformed(e);
878 public static List<String> getGroupURLLinks()
880 return groupURLLinks;
884 public void minColour_actionPerformed(JPanel panel)
886 Color col = JColorChooser.showDialog(this,
887 MessageManager.getString("label.select_colour_minimum_value"),
888 minColour.getBackground());
891 panel.setBackground(col);
897 public void maxColour_actionPerformed(JPanel panel)
899 Color col = JColorChooser.showDialog(this,
900 MessageManager.getString("label.select_colour_maximum_value"),
901 maxColour.getBackground());
904 panel.setBackground(col);
910 protected void userIdWidth_actionPerformed()
914 String val = userIdWidth.getText().trim();
915 if (val.length() > 0)
917 Integer iw = Integer.parseInt(val);
918 if (iw.intValue() < 12)
920 throw new NumberFormatException();
922 userIdWidth.setText(iw.toString());
924 } catch (NumberFormatException x)
926 JvOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
927 .getString("warn.user_defined_width_requirements"),
928 MessageManager.getString("label.invalid_id_column_width"),
929 JvOptionPane.WARNING_MESSAGE);
930 userIdWidth.setText("");
935 protected void autoIdWidth_actionPerformed()
937 userIdWidth.setEnabled(!autoIdWidth.isSelected());
938 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
942 * Returns true if chimera path is to a valid executable, else show an error
945 private boolean validateChimeraPath()
947 if (chimeraPath.getText().trim().length() > 0)
949 File f = new File(chimeraPath.getText());
952 JvOptionPane.showInternalMessageDialog(Desktop.desktop,
953 MessageManager.getString("label.invalid_chimera_path"),
954 MessageManager.getString("label.invalid_name"),
955 JvOptionPane.ERROR_MESSAGE);
963 * If Chimera is selected, check it can be found on default or user-specified
964 * path, if not show a warning/help dialog.
967 protected void structureViewer_actionPerformed(String selectedItem)
969 if (!selectedItem.equals(ViewerType.CHIMERA.name()))
973 boolean found = false;
976 * Try user-specified and standard paths for Chimera executable.
978 List<String> paths = StructureManager.getChimeraPaths();
979 paths.add(0, chimeraPath.getText());
980 for (String path : paths)
982 if (new File(path.trim()).canExecute())
990 String[] options = { "OK", "Help" };
991 int showHelp = JvOptionPane.showInternalOptionDialog(
993 JvSwingUtils.wrapTooltip(true,
994 MessageManager.getString("label.chimera_missing")),
995 "", JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE,
996 null, options, options[0]);
997 if (showHelp == JvOptionPane.NO_OPTION)
1001 Help.showHelpWindow(HelpId.StructureViewer);
1002 } catch (HelpSetException e)
1004 e.printStackTrace();
1010 public class OptionsParam
1012 private String name;
1014 private String code;
1016 public OptionsParam(String name, String code)
1022 public String getName()
1027 public void setName(String name)
1032 public String getCode()
1037 public void setCode(String code)
1043 public String toString()
1049 public boolean equals(Object that)
1051 if (!(that instanceof OptionsParam))
1055 return this.code.equalsIgnoreCase(((OptionsParam) that).code);
1059 public int hashCode()
1061 return name.hashCode() + code.hashCode();