2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
24 import jalview.bin.Cache;
25 import jalview.gui.Help.HelpId;
26 import jalview.gui.StructureViewer.ViewerType;
27 import jalview.io.JalviewFileChooser;
28 import jalview.io.JalviewFileView;
29 import jalview.jbgui.GPreferences;
30 import jalview.jbgui.GSequenceLink;
31 import jalview.schemes.ColourSchemeProperty;
32 import jalview.util.MessageManager;
33 import jalview.util.Platform;
34 import jalview.ws.sifts.SiftsSettings;
36 import java.awt.BorderLayout;
37 import java.awt.Color;
38 import java.awt.Dimension;
40 import java.awt.event.ActionEvent;
41 import java.awt.event.ActionListener;
42 import java.awt.event.MouseEvent;
44 import java.util.ArrayList;
45 import java.util.List;
46 import java.util.StringTokenizer;
47 import java.util.Vector;
49 import javax.help.HelpSetException;
50 import javax.swing.JColorChooser;
51 import javax.swing.JFileChooser;
52 import javax.swing.JInternalFrame;
53 import javax.swing.JOptionPane;
54 import javax.swing.JPanel;
56 import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
64 public class Preferences extends GPreferences
66 public static final String ENABLE_SPLIT_FRAME = "ENABLE_SPLIT_FRAME";
68 public static final String SCALE_PROTEIN_TO_CDNA = "SCALE_PROTEIN_TO_CDNA";
70 public static final String DEFAULT_COLOUR = "DEFAULT_COLOUR";
72 public static final String DEFAULT_COLOUR_PROT = "DEFAULT_COLOUR_PROT";
74 public static final String DEFAULT_COLOUR_NUC = "DEFAULT_COLOUR_NUC";
76 public static final String ADD_TEMPFACT_ANN = "ADD_TEMPFACT_ANN";
78 public static final String ADD_SS_ANN = "ADD_SS_ANN";
80 public static final String USE_RNAVIEW = "USE_RNAVIEW";
82 public static final String STRUCT_FROM_PDB = "STRUCT_FROM_PDB";
84 public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY";
86 public static final String CHIMERA_PATH = "CHIMERA_PATH";
88 public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS";
90 public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE";
92 private static final int MIN_FONT_SIZE = 1;
94 private static final int MAX_FONT_SIZE = 30;
97 * Holds name and link separated with | character. Sequence ID must be
98 * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$
100 public static Vector<String> sequenceURLLinks;
103 * Holds name and link separated with | character. Sequence IDS and Sequences
104 * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and
105 * $SEQUENCES$ or $SEQUENCES=/.possible | chars ./=$ and separation character
106 * for first and second token specified after a pipe character at end |,|.
107 * (TODO: proper escape for using | to separate ids or sequences
110 public static List<String> groupURLLinks;
113 String string = Cache
116 "EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$");
117 sequenceURLLinks = new Vector<String>();
121 StringTokenizer st = new StringTokenizer(string, "|");
122 while (st.hasMoreElements())
124 String name = st.nextToken();
125 String url = st.nextToken();
126 // check for '|' within a regex
127 int rxstart = url.indexOf("$SEQUENCE_ID$");
128 while (rxstart == -1 && url.indexOf("/=$") == -1)
130 url = url + "|" + st.nextToken();
132 sequenceURLLinks.addElement(name + "|" + url);
134 } catch (Exception ex)
136 System.out.println(ex + "\nError parsing sequence links");
139 // upgrade old SRS link
140 int srsPos = sequenceURLLinks
141 .indexOf("SRS|http://srs.ebi.ac.uk/srsbin/cgi-bin/wgetz?-newId+(([uniprot-all:$SEQUENCE_ID$]))+-view+SwissEntry");
146 "EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$",
152 * TODO: reformulate groupURL encoding so two or more can be stored in the
153 * .properties file as '|' separated strings
156 groupURLLinks = new ArrayList<String>();
159 Vector<String> nameLinks, urlLinks;
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 showGroupConsensus.setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS",
217 showGroupConservation.setSelected(Cache.getDefault(
218 "SHOW_GROUP_CONSERVATION", false));
219 showConsensHistogram.setSelected(Cache.getDefault(
220 "SHOW_CONSENSUS_HISTOGRAM", true));
221 showConsensLogo.setSelected(Cache.getDefault("SHOW_CONSENSUS_LOGO",
223 showNpTooltip.setSelected(Cache
224 .getDefault("SHOW_NPFEATS_TOOLTIP", true));
225 showDbRefTooltip.setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP",
228 String[] fonts = java.awt.GraphicsEnvironment
229 .getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
230 for (int i = 0; i < fonts.length; i++)
232 fontNameCB.addItem(fonts[i]);
235 for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++)
237 fontSizeCB.addItem(i + "");
240 fontStyleCB.addItem("plain");
241 fontStyleCB.addItem("bold");
242 fontStyleCB.addItem("italic");
244 fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif"));
245 fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10"));
246 fontStyleCB.setSelectedItem(Cache.getDefault("FONT_STYLE", Font.PLAIN
249 smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", false));
250 scaleProteinToCdna.setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA,
253 idItalics.setSelected(Cache.getDefault("ID_ITALICS", true));
255 wrap.setSelected(Cache.getDefault("WRAP_ALIGNMENT", false));
257 gapSymbolCB.addItem("-");
258 gapSymbolCB.addItem(".");
260 gapSymbolCB.setSelectedItem(Cache.getDefault("GAP_SYMBOL", "-"));
262 sortby.addItem("No sort");
263 sortby.addItem("Id");
264 sortby.addItem("Pairwise Identity");
265 sortby.setSelectedItem(Cache.getDefault("SORT_ALIGNMENT", "No sort"));
267 sortAnnBy.addItem(SequenceAnnotationOrder.NONE.toString());
269 .addItem(SequenceAnnotationOrder.SEQUENCE_AND_LABEL.toString());
271 .addItem(SequenceAnnotationOrder.LABEL_AND_SEQUENCE.toString());
272 SequenceAnnotationOrder savedSort = SequenceAnnotationOrder
273 .valueOf(Cache.getDefault(SORT_ANNOTATIONS,
274 SequenceAnnotationOrder.NONE.name()));
275 sortAnnBy.setSelectedItem(savedSort.toString());
277 sortAutocalc.addItem("Autocalculated first");
278 sortAutocalc.addItem("Autocalculated last");
279 final boolean showAbove = Cache.getDefault(SHOW_AUTOCALC_ABOVE, true);
280 sortAutocalc.setSelectedItem(showAbove ? sortAutocalc.getItemAt(0)
281 : sortAutocalc.getItemAt(1));
283 .setSelected(Cache.getDefault("SHOW_STARTUP_FILE", true));
284 startupFileTextfield.setText(Cache.getDefault("STARTUP_FILE",
285 Cache.getDefault("www.jalview.org", "http://www.jalview.org")
286 + "/examples/exampleFile_2_3.jar"));
289 * Set Colours tab defaults
291 for (int i = ColourSchemeProperty.FIRST_COLOUR; i <= ColourSchemeProperty.LAST_COLOUR; i++)
293 protColour.addItem(ColourSchemeProperty.getColourName(i));
294 nucColour.addItem(ColourSchemeProperty.getColourName(i));
296 String oldProp = Cache.getDefault(DEFAULT_COLOUR, "None");
297 String newProp = Cache.getDefault(DEFAULT_COLOUR_PROT, null);
298 protColour.setSelectedItem(newProp != null ? newProp : oldProp);
299 newProp = Cache.getDefault(DEFAULT_COLOUR_NUC, null);
300 nucColour.setSelectedItem(newProp != null ? newProp : oldProp);
301 minColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN",
303 maxColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX",
307 * Set Structure tab defaults.
309 final boolean structSelected = Cache.getDefault(STRUCT_FROM_PDB, false);
310 structFromPdb.setSelected(structSelected);
311 useRnaView.setSelected(Cache.getDefault(USE_RNAVIEW, false));
312 useRnaView.setEnabled(structSelected);
313 addSecondaryStructure.setSelected(Cache.getDefault(ADD_SS_ANN, false));
314 addSecondaryStructure.setEnabled(structSelected);
315 addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, false));
316 addTempFactor.setEnabled(structSelected);
317 structViewer.setSelectedItem(Cache.getDefault(STRUCTURE_DISPLAY,
318 ViewerType.JMOL.name()));
319 chimeraPath.setText(Cache.getDefault(CHIMERA_PATH, ""));
320 chimeraPath.addActionListener(new ActionListener()
323 public void actionPerformed(ActionEvent e)
325 validateChimeraPath();
329 if (Cache.getDefault("MAP_WITH_SIFTS", false))
331 siftsMapping.setSelected(true);
335 nwMapping.setSelected(true);
339 .setMapWithSifts(Cache.getDefault("MAP_WITH_SIFTS", false));
342 * Set Connections tab defaults
344 nameLinks = new Vector<String>();
345 urlLinks = new Vector<String>();
346 for (int i = 0; i < sequenceURLLinks.size(); i++)
348 String link = sequenceURLLinks.elementAt(i).toString();
349 nameLinks.addElement(link.substring(0, link.indexOf("|")));
350 urlLinks.addElement(link.substring(link.indexOf("|") + 1));
355 useProxy.setSelected(Cache.getDefault("USE_PROXY", false));
356 proxyServerTB.setEnabled(useProxy.isSelected());
357 proxyPortTB.setEnabled(useProxy.isSelected());
358 proxyServerTB.setText(Cache.getDefault("PROXY_SERVER", ""));
359 proxyPortTB.setText(Cache.getDefault("PROXY_PORT", ""));
361 defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
363 usagestats.setSelected(Cache.getDefault("USAGESTATS", false));
364 // note antisense here: default is true
366 .setSelected(Cache.getProperty("NOQUESTIONNAIRES") == null);
367 versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true));
370 * Set Output tab defaults
372 epsRendering.addItem(promptEachTimeOpt);
373 epsRendering.addItem(lineArtOpt);
374 epsRendering.addItem(textOpt);
375 String defaultEPS = Cache.getDefault("EPS_RENDERING",
377 if (defaultEPS.equalsIgnoreCase("Text"))
379 epsRendering.setSelectedItem(textOpt);
381 else if (defaultEPS.equalsIgnoreCase("Lineart"))
383 epsRendering.setSelectedItem(lineArtOpt);
387 epsRendering.setSelectedItem(promptEachTimeOpt);
389 autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
390 userIdWidth.setEnabled(!autoIdWidth.isSelected());
391 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
392 Integer wi = Cache.getIntegerProperty("FIGURE_USERIDWIDTH");
393 userIdWidth.setText(wi == null ? "" : wi.toString());
394 blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
395 clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
396 fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
397 msfjv.setSelected(Cache.getDefault("MSF_JVSUFFIX", true));
398 pfamjv.setSelected(Cache.getDefault("PFAM_JVSUFFIX", true));
399 pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true));
400 pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true));
401 modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false));
402 embbedBioJSON.setSelected(Cache.getDefault("EXPORT_EMBBED_BIOJSON",
406 * Set Editing tab defaults
408 autoCalculateConsCheck.setSelected(Cache.getDefault(
409 "AUTO_CALC_CONSENSUS", true));
410 padGaps.setSelected(Cache.getDefault("PAD_GAPS", false));
411 sortByTree.setSelected(Cache.getDefault("SORT_BY_TREE", false));
413 annotations_actionPerformed(null); // update the display of the annotation
418 * Save user selections on the Preferences tabs to the Cache and write out to
424 public void ok_actionPerformed(ActionEvent e)
426 if (!validateSettings())
432 * Save Visual settings
434 Cache.applicationProperties.setProperty("SHOW_JVSUFFIX",
435 Boolean.toString(seqLimit.isSelected()));
436 Cache.applicationProperties.setProperty("RIGHT_ALIGN_IDS",
437 Boolean.toString(rightAlign.isSelected()));
438 Cache.applicationProperties.setProperty("SHOW_FULLSCREEN",
439 Boolean.toString(fullScreen.isSelected()));
440 Cache.applicationProperties.setProperty("SHOW_OVERVIEW",
441 Boolean.toString(openoverv.isSelected()));
442 Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
443 Boolean.toString(annotations.isSelected()));
444 Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
445 Boolean.toString(conservation.isSelected()));
446 Cache.applicationProperties.setProperty("SHOW_QUALITY",
447 Boolean.toString(quality.isSelected()));
448 Cache.applicationProperties.setProperty("SHOW_IDENTITY",
449 Boolean.toString(identity.isSelected()));
451 Cache.applicationProperties.setProperty("GAP_SYMBOL", gapSymbolCB
452 .getSelectedItem().toString());
454 Cache.applicationProperties.setProperty("FONT_NAME", fontNameCB
455 .getSelectedItem().toString());
456 Cache.applicationProperties.setProperty("FONT_STYLE", fontStyleCB
457 .getSelectedItem().toString());
458 Cache.applicationProperties.setProperty("FONT_SIZE", fontSizeCB
459 .getSelectedItem().toString());
461 Cache.applicationProperties.setProperty("ID_ITALICS",
462 Boolean.toString(idItalics.isSelected()));
463 Cache.applicationProperties.setProperty("SHOW_UNCONSERVED",
464 Boolean.toString(showUnconserved.isSelected()));
465 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSENSUS",
466 Boolean.toString(showGroupConsensus.isSelected()));
467 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSERVATION",
468 Boolean.toString(showGroupConservation.isSelected()));
469 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_HISTOGRAM",
470 Boolean.toString(showConsensHistogram.isSelected()));
471 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_LOGO",
472 Boolean.toString(showConsensLogo.isSelected()));
473 Cache.applicationProperties.setProperty("ANTI_ALIAS",
474 Boolean.toString(smoothFont.isSelected()));
475 Cache.applicationProperties.setProperty(SCALE_PROTEIN_TO_CDNA,
476 Boolean.toString(scaleProteinToCdna.isSelected()));
477 Cache.applicationProperties.setProperty("SHOW_NPFEATS_TOOLTIP",
478 Boolean.toString(showNpTooltip.isSelected()));
479 Cache.applicationProperties.setProperty("SHOW_DBREFS_TOOLTIP",
480 Boolean.toString(showDbRefTooltip.isSelected()));
482 Cache.applicationProperties.setProperty("WRAP_ALIGNMENT",
483 Boolean.toString(wrap.isSelected()));
485 Cache.applicationProperties.setProperty("STARTUP_FILE",
486 startupFileTextfield.getText());
487 Cache.applicationProperties.setProperty("SHOW_STARTUP_FILE",
488 Boolean.toString(startupCheckbox.isSelected()));
490 Cache.applicationProperties.setProperty("SORT_ALIGNMENT", sortby
491 .getSelectedItem().toString());
493 // convert description of sort order to enum name for save
494 SequenceAnnotationOrder annSortOrder = SequenceAnnotationOrder
495 .forDescription(sortAnnBy.getSelectedItem().toString());
496 if (annSortOrder != null)
498 Cache.applicationProperties.setProperty(SORT_ANNOTATIONS,
499 annSortOrder.name());
502 final boolean showAutocalcFirst = sortAutocalc.getSelectedIndex() == 0;
503 Cache.applicationProperties.setProperty(SHOW_AUTOCALC_ABOVE, Boolean
504 .valueOf(showAutocalcFirst).toString());
507 * Save Colours settings
509 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_PROT, protColour
510 .getSelectedItem().toString());
511 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_NUC, nucColour
512 .getSelectedItem().toString());
513 Cache.setColourProperty("ANNOTATIONCOLOUR_MIN",
514 minColour.getBackground());
515 Cache.setColourProperty("ANNOTATIONCOLOUR_MAX",
516 maxColour.getBackground());
519 * Save Structure settings
521 Cache.applicationProperties.setProperty(ADD_TEMPFACT_ANN,
522 Boolean.toString(addTempFactor.isSelected()));
523 Cache.applicationProperties.setProperty(ADD_SS_ANN,
524 Boolean.toString(addSecondaryStructure.isSelected()));
525 Cache.applicationProperties.setProperty(USE_RNAVIEW,
526 Boolean.toString(useRnaView.isSelected()));
527 Cache.applicationProperties.setProperty(STRUCT_FROM_PDB,
528 Boolean.toString(structFromPdb.isSelected()));
529 Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY, structViewer
530 .getSelectedItem().toString());
531 Cache.setOrRemove(CHIMERA_PATH, chimeraPath.getText());
532 Cache.applicationProperties.setProperty("MAP_WITH_SIFTS",
533 Boolean.toString(siftsMapping.isSelected()));
534 SiftsSettings.setMapWithSifts(siftsMapping.isSelected());
537 * Save Output settings
539 Cache.applicationProperties.setProperty("EPS_RENDERING",
540 ((OptionsParam) epsRendering.getSelectedItem()).getCode());
543 * Save Connections settings
545 Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
547 jalview.util.BrowserLauncher.resetBrowser();
549 if (nameLinks.size() > 0)
551 StringBuffer links = new StringBuffer();
552 sequenceURLLinks = new Vector<String>();
553 for (int i = 0; i < nameLinks.size(); i++)
555 sequenceURLLinks.addElement(nameLinks.elementAt(i) + "|"
556 + urlLinks.elementAt(i));
557 links.append(sequenceURLLinks.elementAt(i).toString());
561 links.setLength(links.length() - 1);
562 Cache.applicationProperties.setProperty("SEQUENCE_LINKS",
567 Cache.applicationProperties.remove("SEQUENCE_LINKS");
570 Cache.applicationProperties.setProperty("USE_PROXY",
571 Boolean.toString(useProxy.isSelected()));
573 Cache.setOrRemove("PROXY_SERVER", proxyServerTB.getText());
575 Cache.setOrRemove("PROXY_PORT", proxyPortTB.getText());
577 if (useProxy.isSelected())
579 System.setProperty("http.proxyHost", proxyServerTB.getText());
580 System.setProperty("http.proxyPort", proxyPortTB.getText());
584 System.setProperty("http.proxyHost", "");
585 System.setProperty("http.proxyPort", "");
587 Cache.setProperty("VERSION_CHECK",
588 Boolean.toString(versioncheck.isSelected()));
589 if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
591 // default is false - we only set this if the user has actively agreed
592 Cache.setProperty("USAGESTATS",
593 Boolean.toString(usagestats.isSelected()));
595 if (!questionnaire.isSelected())
597 Cache.setProperty("NOQUESTIONNAIRES", "true");
601 // special - made easy to edit a property file to disable questionnaires
602 // by just adding the given line
603 Cache.removeProperty("NOQUESTIONNAIRES");
607 * Save Output settings
609 Cache.applicationProperties.setProperty("BLC_JVSUFFIX",
610 Boolean.toString(blcjv.isSelected()));
611 Cache.applicationProperties.setProperty("CLUSTAL_JVSUFFIX",
612 Boolean.toString(clustaljv.isSelected()));
613 Cache.applicationProperties.setProperty("FASTA_JVSUFFIX",
614 Boolean.toString(fastajv.isSelected()));
615 Cache.applicationProperties.setProperty("MSF_JVSUFFIX",
616 Boolean.toString(msfjv.isSelected()));
617 Cache.applicationProperties.setProperty("PFAM_JVSUFFIX",
618 Boolean.toString(pfamjv.isSelected()));
619 Cache.applicationProperties.setProperty("PILEUP_JVSUFFIX",
620 Boolean.toString(pileupjv.isSelected()));
621 Cache.applicationProperties.setProperty("PIR_JVSUFFIX",
622 Boolean.toString(pirjv.isSelected()));
623 Cache.applicationProperties.setProperty("PIR_MODELLER",
624 Boolean.toString(modellerOutput.isSelected()));
625 Cache.applicationProperties.setProperty("EXPORT_EMBBED_BIOJSON",
626 Boolean.toString(embbedBioJSON.isSelected()));
627 jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
629 Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH",
630 Boolean.toString(autoIdWidth.isSelected()));
631 userIdWidth_actionPerformed();
632 Cache.applicationProperties.setProperty("FIGURE_USERIDWIDTH",
633 userIdWidth.getText());
636 * Save Editing settings
638 Cache.applicationProperties.setProperty("AUTO_CALC_CONSENSUS",
639 Boolean.toString(autoCalculateConsCheck.isSelected()));
640 Cache.applicationProperties.setProperty("SORT_BY_TREE",
641 Boolean.toString(sortByTree.isSelected()));
642 Cache.applicationProperties.setProperty("PAD_GAPS",
643 Boolean.toString(padGaps.isSelected()));
645 dasSource.saveProperties(Cache.applicationProperties);
646 wsPrefs.updateAndRefreshWsMenuConfig(false);
647 Cache.saveProperties();
648 Desktop.instance.doConfigureStructurePrefs();
651 frame.setClosed(true);
652 } catch (Exception ex)
658 * Do any necessary validation before saving settings. Return focus to the
659 * first tab which fails validation.
663 private boolean validateSettings()
665 if (!validateStructure())
667 structureTab.requestFocusInWindow();
674 protected boolean validateStructure()
676 return validateChimeraPath();
684 public void startupFileTextfield_mouseClicked()
686 JalviewFileChooser chooser = new JalviewFileChooser(
687 jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] {
688 "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc",
689 "jar" }, new String[] { "Fasta", "Clustal", "PFAM", "MSF",
690 "PIR", "BLC", "Jalview" },
691 jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT"));
692 chooser.setFileView(new JalviewFileView());
693 chooser.setDialogTitle(MessageManager
694 .getString("label.select_startup_file"));
696 int value = chooser.showOpenDialog(this);
698 if (value == JalviewFileChooser.APPROVE_OPTION)
700 jalview.bin.Cache.applicationProperties.setProperty(
701 "DEFAULT_FILE_FORMAT", chooser.getSelectedFormat());
702 startupFileTextfield.setText(chooser.getSelectedFile()
714 public void cancel_actionPerformed(ActionEvent e)
718 wsPrefs.updateWsMenuConfig(true);
719 wsPrefs.refreshWs_actionPerformed(e);
720 frame.setClosed(true);
721 } catch (Exception ex)
733 public void annotations_actionPerformed(ActionEvent e)
735 conservation.setEnabled(annotations.isSelected());
736 quality.setEnabled(annotations.isSelected());
737 identity.setEnabled(annotations.isSelected());
738 showGroupConsensus.setEnabled(annotations.isSelected());
739 showGroupConservation.setEnabled(annotations.isSelected());
740 showConsensHistogram.setEnabled(annotations.isSelected()
741 && (identity.isSelected() || showGroupConsensus.isSelected()));
742 showConsensLogo.setEnabled(annotations.isSelected()
743 && (identity.isSelected() || showGroupConsensus.isSelected()));
747 public void newLink_actionPerformed(ActionEvent e)
750 GSequenceLink link = new GSequenceLink();
751 boolean valid = false;
754 if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
755 MessageManager.getString("label.new_sequence_url_link"),
756 JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
758 if (link.checkValid())
760 nameLinks.addElement(link.getName());
761 urlLinks.addElement(link.getURL());
774 public void editLink_actionPerformed(ActionEvent e)
776 GSequenceLink link = new GSequenceLink();
778 int index = linkNameList.getSelectedIndex();
781 JOptionPane.showInternalMessageDialog(Desktop.desktop,
782 MessageManager.getString("label.no_link_selected"),
783 MessageManager.getString("label.no_link_selected"),
784 JOptionPane.WARNING_MESSAGE);
788 link.setName(nameLinks.elementAt(index).toString());
789 link.setURL(urlLinks.elementAt(index).toString());
791 boolean valid = false;
795 if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
796 MessageManager.getString("label.new_sequence_url_link"),
797 JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
799 if (link.checkValid())
801 nameLinks.setElementAt(link.getName(), index);
802 urlLinks.setElementAt(link.getURL(), index);
816 public void deleteLink_actionPerformed(ActionEvent e)
818 int index = linkNameList.getSelectedIndex();
821 JOptionPane.showInternalMessageDialog(Desktop.desktop,
822 MessageManager.getString("label.no_link_selected"),
823 MessageManager.getString("label.no_link_selected"),
824 JOptionPane.WARNING_MESSAGE);
827 nameLinks.removeElementAt(index);
828 urlLinks.removeElementAt(index);
832 void updateLinkData()
834 linkNameList.setListData(nameLinks);
835 linkURLList.setListData(urlLinks);
839 public void defaultBrowser_mouseClicked(MouseEvent e)
841 JFileChooser chooser = new JFileChooser(".");
842 chooser.setDialogTitle(MessageManager
843 .getString("label.select_default_browser"));
845 int value = chooser.showOpenDialog(this);
847 if (value == JFileChooser.APPROVE_OPTION)
849 defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath());
858 * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event
862 protected void showunconserved_actionPerformed(ActionEvent e)
864 // TODO Auto-generated method stub
865 super.showunconserved_actionPerformed(e);
868 public static List<String> getGroupURLLinks()
870 return groupURLLinks;
874 public void minColour_actionPerformed(JPanel panel)
876 Color col = JColorChooser.showDialog(this,
877 MessageManager.getString("label.select_colour_minimum_value"),
878 minColour.getBackground());
881 panel.setBackground(col);
887 public void maxColour_actionPerformed(JPanel panel)
889 Color col = JColorChooser.showDialog(this,
890 MessageManager.getString("label.select_colour_maximum_value"),
891 maxColour.getBackground());
894 panel.setBackground(col);
900 protected void userIdWidth_actionPerformed()
904 String val = userIdWidth.getText().trim();
905 if (val.length() > 0)
907 Integer iw = Integer.parseInt(val);
908 if (iw.intValue() < 12)
910 throw new NumberFormatException();
912 userIdWidth.setText(iw.toString());
914 } catch (NumberFormatException x)
916 JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
917 .getString("warn.user_defined_width_requirements"),
918 MessageManager.getString("label.invalid_id_column_width"),
919 JOptionPane.WARNING_MESSAGE);
920 userIdWidth.setText("");
925 protected void autoIdWidth_actionPerformed()
927 userIdWidth.setEnabled(!autoIdWidth.isSelected());
928 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
932 * Returns true if chimera path is to a valid executable, else show an error
935 private boolean validateChimeraPath()
937 if (chimeraPath.getText().trim().length() > 0)
939 File f = new File(chimeraPath.getText());
942 JOptionPane.showInternalMessageDialog(Desktop.desktop,
943 MessageManager.getString("label.invalid_chimera_path"),
944 MessageManager.getString("label.invalid_name"),
945 JOptionPane.ERROR_MESSAGE);
953 * If Chimera is selected, check it can be found on default or user-specified
954 * path, if not show a warning/help dialog.
957 protected void structureViewer_actionPerformed(String selectedItem)
959 if (!selectedItem.equals(ViewerType.CHIMERA.name()))
963 boolean found = false;
966 * Try user-specified and standard paths for Chimera executable.
968 List<String> paths = StructureManager.getChimeraPaths();
969 paths.add(0, chimeraPath.getText());
970 for (String path : paths)
972 if (new File(path.trim()).canExecute())
980 String[] options = { "OK", "Help" };
981 int showHelp = JOptionPane.showInternalOptionDialog(
983 JvSwingUtils.wrapTooltip(true,
984 MessageManager.getString("label.chimera_missing")),
985 "", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE,
986 null, options, options[0]);
987 if (showHelp == JOptionPane.NO_OPTION)
991 Help.showHelpWindow(HelpId.StructureViewer);
992 } catch (HelpSetException e)
1000 public class OptionsParam
1002 private String name;
1004 private String code;
1006 public OptionsParam(String name, String code)
1012 public String getName()
1017 public void setName(String name)
1022 public String getCode()
1027 public void setCode(String code)
1033 public String toString()
1039 public boolean equals(Object that)
1041 if (!(that instanceof OptionsParam))
1045 return this.code.equalsIgnoreCase(((OptionsParam) that).code);
1049 public int hashCode(){
1050 return name.hashCode() + code.hashCode();