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.EMBLEBI_STRING;
24 import static jalview.util.UrlConstants.OLD_EMBLEBI_STRING;
25 import static jalview.util.UrlConstants.SEQUENCE_ID;
26 import static jalview.util.UrlConstants.SEQUENCE_NAME;
27 import static jalview.util.UrlConstants.SRS_STRING;
29 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
30 import jalview.bin.Cache;
31 import jalview.gui.Help.HelpId;
32 import jalview.gui.StructureViewer.ViewerType;
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("$" + SEQUENCE_ID + "$");
133 rxstart = url.indexOf("$" + SEQUENCE_NAME + "$");
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);
152 // upgrade old EMBL-EBI link
153 int emblPos = sequenceURLLinks.indexOf(OLD_EMBLEBI_STRING);
156 sequenceURLLinks.setElementAt(EMBLEBI_STRING, emblPos);
161 * TODO: reformulate groupURL encoding so two or more can be stored in the
162 * .properties file as '|' separated strings
165 groupURLLinks = new ArrayList<String>();
168 Vector<String> nameLinks, urlLinks;
170 JInternalFrame frame;
172 DasSourceBrowser dasSource;
174 private WsPreferences wsPrefs;
176 private OptionsParam promptEachTimeOpt = new OptionsParam(
177 MessageManager.getString("label.prompt_each_time"),
180 private OptionsParam lineArtOpt = new OptionsParam(
181 MessageManager.getString("label.lineart"), "Lineart");
183 private OptionsParam textOpt = new OptionsParam(
184 MessageManager.getString("action.text"), "Text");
187 * Creates a new Preferences object.
192 frame = new JInternalFrame();
193 frame.setContentPane(this);
194 dasSource = new DasSourceBrowser();
195 dasTab.add(dasSource, BorderLayout.CENTER);
196 wsPrefs = new WsPreferences();
197 wsTab.add(wsPrefs, BorderLayout.CENTER);
198 int width = 500, height = 450;
199 new jalview.util.Platform();
200 if (Platform.isAMac())
206 Desktop.addInternalFrame(frame,
207 MessageManager.getString("label.preferences"), width, height);
208 frame.setMinimumSize(new Dimension(width, height));
211 * Set Visual tab defaults
213 seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true));
214 rightAlign.setSelected(Cache.getDefault("RIGHT_ALIGN_IDS", false));
215 fullScreen.setSelected(Cache.getDefault("SHOW_FULLSCREEN", false));
216 annotations.setSelected(Cache.getDefault("SHOW_ANNOTATIONS", true));
218 conservation.setSelected(Cache.getDefault("SHOW_CONSERVATION", true));
219 quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));
220 identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
221 openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false));
223 .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
224 showGroupConsensus.setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS",
226 showGroupConservation.setSelected(Cache.getDefault(
227 "SHOW_GROUP_CONSERVATION", false));
228 showConsensHistogram.setSelected(Cache.getDefault(
229 "SHOW_CONSENSUS_HISTOGRAM", true));
230 showConsensLogo.setSelected(Cache.getDefault("SHOW_CONSENSUS_LOGO",
232 showNpTooltip.setSelected(Cache
233 .getDefault("SHOW_NPFEATS_TOOLTIP", true));
234 showDbRefTooltip.setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP",
237 String[] fonts = java.awt.GraphicsEnvironment
238 .getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
239 for (int i = 0; i < fonts.length; i++)
241 fontNameCB.addItem(fonts[i]);
244 for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++)
246 fontSizeCB.addItem(i + "");
249 fontStyleCB.addItem("plain");
250 fontStyleCB.addItem("bold");
251 fontStyleCB.addItem("italic");
253 fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif"));
254 fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10"));
255 fontStyleCB.setSelectedItem(Cache.getDefault("FONT_STYLE", Font.PLAIN
258 smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", false));
259 scaleProteinToCdna.setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA,
262 idItalics.setSelected(Cache.getDefault("ID_ITALICS", true));
264 wrap.setSelected(Cache.getDefault("WRAP_ALIGNMENT", false));
266 gapSymbolCB.addItem("-");
267 gapSymbolCB.addItem(".");
269 gapSymbolCB.setSelectedItem(Cache.getDefault("GAP_SYMBOL", "-"));
271 sortby.addItem("No sort");
272 sortby.addItem("Id");
273 sortby.addItem("Pairwise Identity");
274 sortby.setSelectedItem(Cache.getDefault("SORT_ALIGNMENT", "No sort"));
276 sortAnnBy.addItem(SequenceAnnotationOrder.NONE.toString());
278 .addItem(SequenceAnnotationOrder.SEQUENCE_AND_LABEL.toString());
280 .addItem(SequenceAnnotationOrder.LABEL_AND_SEQUENCE.toString());
281 SequenceAnnotationOrder savedSort = SequenceAnnotationOrder
282 .valueOf(Cache.getDefault(SORT_ANNOTATIONS,
283 SequenceAnnotationOrder.NONE.name()));
284 sortAnnBy.setSelectedItem(savedSort.toString());
286 sortAutocalc.addItem("Autocalculated first");
287 sortAutocalc.addItem("Autocalculated last");
288 final boolean showAbove = Cache.getDefault(SHOW_AUTOCALC_ABOVE, true);
289 sortAutocalc.setSelectedItem(showAbove ? sortAutocalc.getItemAt(0)
290 : sortAutocalc.getItemAt(1));
292 .setSelected(Cache.getDefault("SHOW_STARTUP_FILE", true));
293 startupFileTextfield.setText(Cache.getDefault("STARTUP_FILE",
294 Cache.getDefault("www.jalview.org", "http://www.jalview.org")
295 + "/examples/exampleFile_2_3.jar"));
298 * Set Colours tab defaults
300 for (int i = ColourSchemeProperty.FIRST_COLOUR; i <= ColourSchemeProperty.LAST_COLOUR; i++)
302 protColour.addItem(ColourSchemeProperty.getColourName(i));
303 nucColour.addItem(ColourSchemeProperty.getColourName(i));
305 String oldProp = Cache.getDefault(DEFAULT_COLOUR, "None");
306 String newProp = Cache.getDefault(DEFAULT_COLOUR_PROT, null);
307 protColour.setSelectedItem(newProp != null ? newProp : oldProp);
308 newProp = Cache.getDefault(DEFAULT_COLOUR_NUC, null);
309 nucColour.setSelectedItem(newProp != null ? newProp : oldProp);
310 minColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN",
312 maxColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX",
316 * Set Structure tab defaults.
318 final boolean structSelected = Cache.getDefault(STRUCT_FROM_PDB, false);
319 structFromPdb.setSelected(structSelected);
320 useRnaView.setSelected(Cache.getDefault(USE_RNAVIEW, false));
321 useRnaView.setEnabled(structSelected);
322 addSecondaryStructure.setSelected(Cache.getDefault(ADD_SS_ANN, false));
323 addSecondaryStructure.setEnabled(structSelected);
324 addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, false));
325 addTempFactor.setEnabled(structSelected);
326 structViewer.setSelectedItem(Cache.getDefault(STRUCTURE_DISPLAY,
327 ViewerType.JMOL.name()));
328 chimeraPath.setText(Cache.getDefault(CHIMERA_PATH, ""));
329 chimeraPath.addActionListener(new ActionListener()
332 public void actionPerformed(ActionEvent e)
334 validateChimeraPath();
338 if (Cache.getDefault("MAP_WITH_SIFTS", false))
340 siftsMapping.setSelected(true);
344 nwMapping.setSelected(true);
348 .setMapWithSifts(Cache.getDefault("MAP_WITH_SIFTS", false));
351 * Set Connections tab defaults
353 nameLinks = new Vector<String>();
354 urlLinks = new Vector<String>();
355 for (int i = 0; i < sequenceURLLinks.size(); i++)
357 String link = sequenceURLLinks.elementAt(i).toString();
358 nameLinks.addElement(link.substring(0, link.indexOf("|")));
359 urlLinks.addElement(link.substring(link.indexOf("|") + 1));
364 useProxy.setSelected(Cache.getDefault("USE_PROXY", false));
365 proxyServerTB.setEnabled(useProxy.isSelected());
366 proxyPortTB.setEnabled(useProxy.isSelected());
367 proxyServerTB.setText(Cache.getDefault("PROXY_SERVER", ""));
368 proxyPortTB.setText(Cache.getDefault("PROXY_PORT", ""));
370 defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
372 usagestats.setSelected(Cache.getDefault("USAGESTATS", false));
373 // note antisense here: default is true
375 .setSelected(Cache.getProperty("NOQUESTIONNAIRES") == null);
376 versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true));
379 * Set Output tab defaults
381 epsRendering.addItem(promptEachTimeOpt);
382 epsRendering.addItem(lineArtOpt);
383 epsRendering.addItem(textOpt);
384 String defaultEPS = Cache.getDefault("EPS_RENDERING",
386 if (defaultEPS.equalsIgnoreCase("Text"))
388 epsRendering.setSelectedItem(textOpt);
390 else if (defaultEPS.equalsIgnoreCase("Lineart"))
392 epsRendering.setSelectedItem(lineArtOpt);
396 epsRendering.setSelectedItem(promptEachTimeOpt);
398 autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
399 userIdWidth.setEnabled(!autoIdWidth.isSelected());
400 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
401 Integer wi = Cache.getIntegerProperty("FIGURE_USERIDWIDTH");
402 userIdWidth.setText(wi == null ? "" : wi.toString());
403 blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
404 clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
405 fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
406 msfjv.setSelected(Cache.getDefault("MSF_JVSUFFIX", true));
407 pfamjv.setSelected(Cache.getDefault("PFAM_JVSUFFIX", true));
408 pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true));
409 pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true));
410 modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false));
411 embbedBioJSON.setSelected(Cache.getDefault("EXPORT_EMBBED_BIOJSON",
415 * Set Editing tab defaults
417 autoCalculateConsCheck.setSelected(Cache.getDefault(
418 "AUTO_CALC_CONSENSUS", true));
419 padGaps.setSelected(Cache.getDefault("PAD_GAPS", false));
420 sortByTree.setSelected(Cache.getDefault("SORT_BY_TREE", false));
422 annotations_actionPerformed(null); // update the display of the annotation
427 * Save user selections on the Preferences tabs to the Cache and write out to
433 public void ok_actionPerformed(ActionEvent e)
435 if (!validateSettings())
441 * Save Visual settings
443 Cache.applicationProperties.setProperty("SHOW_JVSUFFIX",
444 Boolean.toString(seqLimit.isSelected()));
445 Cache.applicationProperties.setProperty("RIGHT_ALIGN_IDS",
446 Boolean.toString(rightAlign.isSelected()));
447 Cache.applicationProperties.setProperty("SHOW_FULLSCREEN",
448 Boolean.toString(fullScreen.isSelected()));
449 Cache.applicationProperties.setProperty("SHOW_OVERVIEW",
450 Boolean.toString(openoverv.isSelected()));
451 Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
452 Boolean.toString(annotations.isSelected()));
453 Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
454 Boolean.toString(conservation.isSelected()));
455 Cache.applicationProperties.setProperty("SHOW_QUALITY",
456 Boolean.toString(quality.isSelected()));
457 Cache.applicationProperties.setProperty("SHOW_IDENTITY",
458 Boolean.toString(identity.isSelected()));
460 Cache.applicationProperties.setProperty("GAP_SYMBOL", gapSymbolCB
461 .getSelectedItem().toString());
463 Cache.applicationProperties.setProperty("FONT_NAME", fontNameCB
464 .getSelectedItem().toString());
465 Cache.applicationProperties.setProperty("FONT_STYLE", fontStyleCB
466 .getSelectedItem().toString());
467 Cache.applicationProperties.setProperty("FONT_SIZE", fontSizeCB
468 .getSelectedItem().toString());
470 Cache.applicationProperties.setProperty("ID_ITALICS",
471 Boolean.toString(idItalics.isSelected()));
472 Cache.applicationProperties.setProperty("SHOW_UNCONSERVED",
473 Boolean.toString(showUnconserved.isSelected()));
474 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSENSUS",
475 Boolean.toString(showGroupConsensus.isSelected()));
476 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSERVATION",
477 Boolean.toString(showGroupConservation.isSelected()));
478 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_HISTOGRAM",
479 Boolean.toString(showConsensHistogram.isSelected()));
480 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_LOGO",
481 Boolean.toString(showConsensLogo.isSelected()));
482 Cache.applicationProperties.setProperty("ANTI_ALIAS",
483 Boolean.toString(smoothFont.isSelected()));
484 Cache.applicationProperties.setProperty(SCALE_PROTEIN_TO_CDNA,
485 Boolean.toString(scaleProteinToCdna.isSelected()));
486 Cache.applicationProperties.setProperty("SHOW_NPFEATS_TOOLTIP",
487 Boolean.toString(showNpTooltip.isSelected()));
488 Cache.applicationProperties.setProperty("SHOW_DBREFS_TOOLTIP",
489 Boolean.toString(showDbRefTooltip.isSelected()));
491 Cache.applicationProperties.setProperty("WRAP_ALIGNMENT",
492 Boolean.toString(wrap.isSelected()));
494 Cache.applicationProperties.setProperty("STARTUP_FILE",
495 startupFileTextfield.getText());
496 Cache.applicationProperties.setProperty("SHOW_STARTUP_FILE",
497 Boolean.toString(startupCheckbox.isSelected()));
499 Cache.applicationProperties.setProperty("SORT_ALIGNMENT", sortby
500 .getSelectedItem().toString());
502 // convert description of sort order to enum name for save
503 SequenceAnnotationOrder annSortOrder = SequenceAnnotationOrder
504 .forDescription(sortAnnBy.getSelectedItem().toString());
505 if (annSortOrder != null)
507 Cache.applicationProperties.setProperty(SORT_ANNOTATIONS,
508 annSortOrder.name());
511 final boolean showAutocalcFirst = sortAutocalc.getSelectedIndex() == 0;
512 Cache.applicationProperties.setProperty(SHOW_AUTOCALC_ABOVE, Boolean
513 .valueOf(showAutocalcFirst).toString());
516 * Save Colours settings
518 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_PROT, protColour
519 .getSelectedItem().toString());
520 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_NUC, nucColour
521 .getSelectedItem().toString());
522 Cache.setColourProperty("ANNOTATIONCOLOUR_MIN",
523 minColour.getBackground());
524 Cache.setColourProperty("ANNOTATIONCOLOUR_MAX",
525 maxColour.getBackground());
528 * Save Structure settings
530 Cache.applicationProperties.setProperty(ADD_TEMPFACT_ANN,
531 Boolean.toString(addTempFactor.isSelected()));
532 Cache.applicationProperties.setProperty(ADD_SS_ANN,
533 Boolean.toString(addSecondaryStructure.isSelected()));
534 Cache.applicationProperties.setProperty(USE_RNAVIEW,
535 Boolean.toString(useRnaView.isSelected()));
536 Cache.applicationProperties.setProperty(STRUCT_FROM_PDB,
537 Boolean.toString(structFromPdb.isSelected()));
538 Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY, structViewer
539 .getSelectedItem().toString());
540 Cache.setOrRemove(CHIMERA_PATH, chimeraPath.getText());
541 Cache.applicationProperties.setProperty("MAP_WITH_SIFTS",
542 Boolean.toString(siftsMapping.isSelected()));
543 SiftsSettings.setMapWithSifts(siftsMapping.isSelected());
546 * Save Output settings
548 Cache.applicationProperties.setProperty("EPS_RENDERING",
549 ((OptionsParam) epsRendering.getSelectedItem()).getCode());
552 * Save Connections settings
554 Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
556 jalview.util.BrowserLauncher.resetBrowser();
558 if (nameLinks.size() > 0)
560 StringBuffer links = new StringBuffer();
561 sequenceURLLinks = new Vector<String>();
562 for (int i = 0; i < nameLinks.size(); i++)
564 sequenceURLLinks.addElement(nameLinks.elementAt(i) + "|"
565 + urlLinks.elementAt(i));
566 links.append(sequenceURLLinks.elementAt(i).toString());
570 links.setLength(links.length() - 1);
571 Cache.applicationProperties.setProperty("SEQUENCE_LINKS",
576 Cache.applicationProperties.remove("SEQUENCE_LINKS");
579 Cache.applicationProperties.setProperty("USE_PROXY",
580 Boolean.toString(useProxy.isSelected()));
582 Cache.setOrRemove("PROXY_SERVER", proxyServerTB.getText());
584 Cache.setOrRemove("PROXY_PORT", proxyPortTB.getText());
586 if (useProxy.isSelected())
588 System.setProperty("http.proxyHost", proxyServerTB.getText());
589 System.setProperty("http.proxyPort", proxyPortTB.getText());
593 System.setProperty("http.proxyHost", "");
594 System.setProperty("http.proxyPort", "");
596 Cache.setProperty("VERSION_CHECK",
597 Boolean.toString(versioncheck.isSelected()));
598 if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
600 // default is false - we only set this if the user has actively agreed
601 Cache.setProperty("USAGESTATS",
602 Boolean.toString(usagestats.isSelected()));
604 if (!questionnaire.isSelected())
606 Cache.setProperty("NOQUESTIONNAIRES", "true");
610 // special - made easy to edit a property file to disable questionnaires
611 // by just adding the given line
612 Cache.removeProperty("NOQUESTIONNAIRES");
616 * Save Output settings
618 Cache.applicationProperties.setProperty("BLC_JVSUFFIX",
619 Boolean.toString(blcjv.isSelected()));
620 Cache.applicationProperties.setProperty("CLUSTAL_JVSUFFIX",
621 Boolean.toString(clustaljv.isSelected()));
622 Cache.applicationProperties.setProperty("FASTA_JVSUFFIX",
623 Boolean.toString(fastajv.isSelected()));
624 Cache.applicationProperties.setProperty("MSF_JVSUFFIX",
625 Boolean.toString(msfjv.isSelected()));
626 Cache.applicationProperties.setProperty("PFAM_JVSUFFIX",
627 Boolean.toString(pfamjv.isSelected()));
628 Cache.applicationProperties.setProperty("PILEUP_JVSUFFIX",
629 Boolean.toString(pileupjv.isSelected()));
630 Cache.applicationProperties.setProperty("PIR_JVSUFFIX",
631 Boolean.toString(pirjv.isSelected()));
632 Cache.applicationProperties.setProperty("PIR_MODELLER",
633 Boolean.toString(modellerOutput.isSelected()));
634 Cache.applicationProperties.setProperty("EXPORT_EMBBED_BIOJSON",
635 Boolean.toString(embbedBioJSON.isSelected()));
636 jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
638 Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH",
639 Boolean.toString(autoIdWidth.isSelected()));
640 userIdWidth_actionPerformed();
641 Cache.applicationProperties.setProperty("FIGURE_USERIDWIDTH",
642 userIdWidth.getText());
645 * Save Editing settings
647 Cache.applicationProperties.setProperty("AUTO_CALC_CONSENSUS",
648 Boolean.toString(autoCalculateConsCheck.isSelected()));
649 Cache.applicationProperties.setProperty("SORT_BY_TREE",
650 Boolean.toString(sortByTree.isSelected()));
651 Cache.applicationProperties.setProperty("PAD_GAPS",
652 Boolean.toString(padGaps.isSelected()));
654 dasSource.saveProperties(Cache.applicationProperties);
655 wsPrefs.updateAndRefreshWsMenuConfig(false);
656 Cache.saveProperties();
657 Desktop.instance.doConfigureStructurePrefs();
660 frame.setClosed(true);
661 } catch (Exception ex)
667 * Do any necessary validation before saving settings. Return focus to the
668 * first tab which fails validation.
672 private boolean validateSettings()
674 if (!validateStructure())
676 structureTab.requestFocusInWindow();
683 protected boolean validateStructure()
685 return validateChimeraPath();
693 public void startupFileTextfield_mouseClicked()
695 JalviewFileChooser chooser = new JalviewFileChooser(
696 jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] {
697 "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc",
698 "jar" }, new String[] { "Fasta", "Clustal", "PFAM", "MSF",
699 "PIR", "BLC", "Jalview" },
700 jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT"));
701 chooser.setFileView(new JalviewFileView());
702 chooser.setDialogTitle(MessageManager
703 .getString("label.select_startup_file"));
705 int value = chooser.showOpenDialog(this);
707 if (value == JalviewFileChooser.APPROVE_OPTION)
709 jalview.bin.Cache.applicationProperties.setProperty(
710 "DEFAULT_FILE_FORMAT", chooser.getSelectedFormat());
711 startupFileTextfield.setText(chooser.getSelectedFile()
723 public void cancel_actionPerformed(ActionEvent e)
727 wsPrefs.updateWsMenuConfig(true);
728 wsPrefs.refreshWs_actionPerformed(e);
729 frame.setClosed(true);
730 } catch (Exception ex)
742 public void annotations_actionPerformed(ActionEvent e)
744 conservation.setEnabled(annotations.isSelected());
745 quality.setEnabled(annotations.isSelected());
746 identity.setEnabled(annotations.isSelected());
747 showGroupConsensus.setEnabled(annotations.isSelected());
748 showGroupConservation.setEnabled(annotations.isSelected());
749 showConsensHistogram.setEnabled(annotations.isSelected()
750 && (identity.isSelected() || showGroupConsensus.isSelected()));
751 showConsensLogo.setEnabled(annotations.isSelected()
752 && (identity.isSelected() || showGroupConsensus.isSelected()));
756 public void newLink_actionPerformed(ActionEvent e)
759 GSequenceLink link = new GSequenceLink();
760 boolean valid = false;
763 if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
764 MessageManager.getString("label.new_sequence_url_link"),
765 JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
767 if (link.checkValid())
769 nameLinks.addElement(link.getName());
770 urlLinks.addElement(link.getURL());
783 public void editLink_actionPerformed(ActionEvent e)
785 GSequenceLink link = new GSequenceLink();
787 int index = linkNameList.getSelectedIndex();
790 JOptionPane.showInternalMessageDialog(Desktop.desktop,
791 MessageManager.getString("label.no_link_selected"),
792 MessageManager.getString("label.no_link_selected"),
793 JOptionPane.WARNING_MESSAGE);
797 link.setName(nameLinks.elementAt(index).toString());
798 link.setURL(urlLinks.elementAt(index).toString());
800 boolean valid = false;
804 if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
805 MessageManager.getString("label.new_sequence_url_link"),
806 JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
808 if (link.checkValid())
810 nameLinks.setElementAt(link.getName(), index);
811 urlLinks.setElementAt(link.getURL(), index);
825 public void deleteLink_actionPerformed(ActionEvent e)
827 int index = linkNameList.getSelectedIndex();
830 JOptionPane.showInternalMessageDialog(Desktop.desktop,
831 MessageManager.getString("label.no_link_selected"),
832 MessageManager.getString("label.no_link_selected"),
833 JOptionPane.WARNING_MESSAGE);
836 nameLinks.removeElementAt(index);
837 urlLinks.removeElementAt(index);
841 void updateLinkData()
843 linkNameList.setListData(nameLinks);
844 linkURLList.setListData(urlLinks);
848 public void defaultBrowser_mouseClicked(MouseEvent e)
850 JFileChooser chooser = new JFileChooser(".");
851 chooser.setDialogTitle(MessageManager
852 .getString("label.select_default_browser"));
854 int value = chooser.showOpenDialog(this);
856 if (value == JFileChooser.APPROVE_OPTION)
858 defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath());
867 * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event
871 protected void showunconserved_actionPerformed(ActionEvent e)
873 // TODO Auto-generated method stub
874 super.showunconserved_actionPerformed(e);
877 public static List<String> getGroupURLLinks()
879 return groupURLLinks;
883 public void minColour_actionPerformed(JPanel panel)
885 Color col = JColorChooser.showDialog(this,
886 MessageManager.getString("label.select_colour_minimum_value"),
887 minColour.getBackground());
890 panel.setBackground(col);
896 public void maxColour_actionPerformed(JPanel panel)
898 Color col = JColorChooser.showDialog(this,
899 MessageManager.getString("label.select_colour_maximum_value"),
900 maxColour.getBackground());
903 panel.setBackground(col);
909 protected void userIdWidth_actionPerformed()
913 String val = userIdWidth.getText().trim();
914 if (val.length() > 0)
916 Integer iw = Integer.parseInt(val);
917 if (iw.intValue() < 12)
919 throw new NumberFormatException();
921 userIdWidth.setText(iw.toString());
923 } catch (NumberFormatException x)
925 JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
926 .getString("warn.user_defined_width_requirements"),
927 MessageManager.getString("label.invalid_id_column_width"),
928 JOptionPane.WARNING_MESSAGE);
929 userIdWidth.setText("");
934 protected void autoIdWidth_actionPerformed()
936 userIdWidth.setEnabled(!autoIdWidth.isSelected());
937 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
941 * Returns true if chimera path is to a valid executable, else show an error
944 private boolean validateChimeraPath()
946 if (chimeraPath.getText().trim().length() > 0)
948 File f = new File(chimeraPath.getText());
951 JOptionPane.showInternalMessageDialog(Desktop.desktop,
952 MessageManager.getString("label.invalid_chimera_path"),
953 MessageManager.getString("label.invalid_name"),
954 JOptionPane.ERROR_MESSAGE);
962 * If Chimera is selected, check it can be found on default or user-specified
963 * path, if not show a warning/help dialog.
966 protected void structureViewer_actionPerformed(String selectedItem)
968 if (!selectedItem.equals(ViewerType.CHIMERA.name()))
972 boolean found = false;
975 * Try user-specified and standard paths for Chimera executable.
977 List<String> paths = StructureManager.getChimeraPaths();
978 paths.add(0, chimeraPath.getText());
979 for (String path : paths)
981 if (new File(path.trim()).canExecute())
989 String[] options = { "OK", "Help" };
990 int showHelp = JOptionPane.showInternalOptionDialog(
992 JvSwingUtils.wrapTooltip(true,
993 MessageManager.getString("label.chimera_missing")),
994 "", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE,
995 null, options, options[0]);
996 if (showHelp == JOptionPane.NO_OPTION)
1000 Help.showHelpWindow(HelpId.StructureViewer);
1001 } catch (HelpSetException e)
1003 e.printStackTrace();
1009 public class OptionsParam
1011 private String name;
1013 private String code;
1015 public OptionsParam(String name, String code)
1021 public String getName()
1026 public void setName(String name)
1031 public String getCode()
1036 public void setCode(String code)
1042 public String toString()
1048 public boolean equals(Object that)
1050 if (!(that instanceof OptionsParam))
1054 return this.code.equalsIgnoreCase(((OptionsParam) that).code);
1058 public int hashCode()
1060 return name.hashCode() + code.hashCode();