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;
168 * Creates a new Preferences object.
173 frame = new JInternalFrame();
174 frame.setContentPane(this);
175 dasSource = new DasSourceBrowser();
176 dasTab.add(dasSource, BorderLayout.CENTER);
177 wsPrefs = new WsPreferences();
178 wsTab.add(wsPrefs, BorderLayout.CENTER);
179 int width = 500, height = 450;
180 new jalview.util.Platform();
181 if (Platform.isAMac())
187 Desktop.addInternalFrame(frame,
188 MessageManager.getString("label.preferences"), width, height);
189 frame.setMinimumSize(new Dimension(width, height));
192 * Set Visual tab defaults
194 seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true));
195 rightAlign.setSelected(Cache.getDefault("RIGHT_ALIGN_IDS", false));
196 fullScreen.setSelected(Cache.getDefault("SHOW_FULLSCREEN", false));
197 annotations.setSelected(Cache.getDefault("SHOW_ANNOTATIONS", true));
199 conservation.setSelected(Cache.getDefault("SHOW_CONSERVATION", true));
200 quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));
201 identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
202 openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false));
204 .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
205 showGroupConsensus.setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS",
207 showGroupConservation.setSelected(Cache.getDefault(
208 "SHOW_GROUP_CONSERVATION", false));
209 showConsensHistogram.setSelected(Cache.getDefault(
210 "SHOW_CONSENSUS_HISTOGRAM", true));
211 showConsensLogo.setSelected(Cache.getDefault("SHOW_CONSENSUS_LOGO",
213 showNpTooltip.setSelected(Cache
214 .getDefault("SHOW_NPFEATS_TOOLTIP", true));
215 showDbRefTooltip.setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP",
218 String[] fonts = java.awt.GraphicsEnvironment
219 .getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
220 for (int i = 0; i < fonts.length; i++)
222 fontNameCB.addItem(fonts[i]);
225 for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++)
227 fontSizeCB.addItem(i + "");
230 fontStyleCB.addItem("plain");
231 fontStyleCB.addItem("bold");
232 fontStyleCB.addItem("italic");
234 fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif"));
235 fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10"));
236 fontStyleCB.setSelectedItem(Cache.getDefault("FONT_STYLE", Font.PLAIN
239 smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", false));
240 scaleProteinToCdna.setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA,
243 idItalics.setSelected(Cache.getDefault("ID_ITALICS", true));
245 wrap.setSelected(Cache.getDefault("WRAP_ALIGNMENT", false));
247 gapSymbolCB.addItem("-");
248 gapSymbolCB.addItem(".");
250 gapSymbolCB.setSelectedItem(Cache.getDefault("GAP_SYMBOL", "-"));
252 sortby.addItem("No sort");
253 sortby.addItem("Id");
254 sortby.addItem("Pairwise Identity");
255 sortby.setSelectedItem(Cache.getDefault("SORT_ALIGNMENT", "No sort"));
257 sortAnnBy.addItem(SequenceAnnotationOrder.NONE.toString());
259 .addItem(SequenceAnnotationOrder.SEQUENCE_AND_LABEL.toString());
261 .addItem(SequenceAnnotationOrder.LABEL_AND_SEQUENCE.toString());
262 SequenceAnnotationOrder savedSort = SequenceAnnotationOrder
263 .valueOf(Cache.getDefault(SORT_ANNOTATIONS,
264 SequenceAnnotationOrder.NONE.name()));
265 sortAnnBy.setSelectedItem(savedSort.toString());
267 sortAutocalc.addItem("Autocalculated first");
268 sortAutocalc.addItem("Autocalculated last");
269 final boolean showAbove = Cache.getDefault(SHOW_AUTOCALC_ABOVE, true);
270 sortAutocalc.setSelectedItem(showAbove ? sortAutocalc.getItemAt(0)
271 : sortAutocalc.getItemAt(1));
273 .setSelected(Cache.getDefault("SHOW_STARTUP_FILE", true));
274 startupFileTextfield.setText(Cache.getDefault("STARTUP_FILE",
275 Cache.getDefault("www.jalview.org", "http://www.jalview.org")
276 + "/examples/exampleFile_2_3.jar"));
279 * Set Colours tab defaults
281 for (int i = ColourSchemeProperty.FIRST_COLOUR; i <= ColourSchemeProperty.LAST_COLOUR; i++)
283 protColour.addItem(ColourSchemeProperty.getColourName(i));
284 nucColour.addItem(ColourSchemeProperty.getColourName(i));
286 String oldProp = Cache.getDefault(DEFAULT_COLOUR, "None");
287 String newProp = Cache.getDefault(DEFAULT_COLOUR_PROT, null);
288 protColour.setSelectedItem(newProp != null ? newProp : oldProp);
289 newProp = Cache.getDefault(DEFAULT_COLOUR_NUC, null);
290 nucColour.setSelectedItem(newProp != null ? newProp : oldProp);
291 minColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN",
293 maxColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX",
297 * Set Structure tab defaults.
299 final boolean structSelected = Cache.getDefault(STRUCT_FROM_PDB, false);
300 structFromPdb.setSelected(structSelected);
301 useRnaView.setSelected(Cache.getDefault(USE_RNAVIEW, false));
302 useRnaView.setEnabled(structSelected);
303 addSecondaryStructure.setSelected(Cache.getDefault(ADD_SS_ANN, false));
304 addSecondaryStructure.setEnabled(structSelected);
305 addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, false));
306 addTempFactor.setEnabled(structSelected);
307 structViewer.setSelectedItem(Cache.getDefault(STRUCTURE_DISPLAY,
308 ViewerType.JMOL.name()));
309 chimeraPath.setText(Cache.getDefault(CHIMERA_PATH, ""));
310 chimeraPath.addActionListener(new ActionListener()
313 public void actionPerformed(ActionEvent e)
315 validateChimeraPath();
319 if (Cache.getDefault("MAP_WITH_SIFTS", false))
321 siftsMapping.setSelected(true);
325 nwMapping.setSelected(true);
329 .setMapWithSifts(Cache.getDefault("MAP_WITH_SIFTS", false));
332 * Set Connections tab defaults
334 nameLinks = new Vector<String>();
335 urlLinks = new Vector<String>();
336 for (int i = 0; i < sequenceURLLinks.size(); i++)
338 String link = sequenceURLLinks.elementAt(i).toString();
339 nameLinks.addElement(link.substring(0, link.indexOf("|")));
340 urlLinks.addElement(link.substring(link.indexOf("|") + 1));
345 useProxy.setSelected(Cache.getDefault("USE_PROXY", false));
346 proxyServerTB.setEnabled(useProxy.isSelected());
347 proxyPortTB.setEnabled(useProxy.isSelected());
348 proxyServerTB.setText(Cache.getDefault("PROXY_SERVER", ""));
349 proxyPortTB.setText(Cache.getDefault("PROXY_PORT", ""));
351 defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
353 usagestats.setSelected(Cache.getDefault("USAGESTATS", false));
354 // note antisense here: default is true
356 .setSelected(Cache.getProperty("NOQUESTIONNAIRES") == null);
357 versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true));
360 * Set Output tab defaults
363 .addItem(MessageManager.getString("label.prompt_each_time"));
364 epsRendering.addItem(MessageManager.getString("label.lineart"));
365 epsRendering.addItem(MessageManager.getString("action.text"));
366 epsRendering.setSelectedItem(Cache.getDefault("EPS_RENDERING",
367 "Prompt each time"));
368 autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
369 userIdWidth.setEnabled(!autoIdWidth.isSelected());
370 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
371 Integer wi = Cache.getIntegerProperty("FIGURE_USERIDWIDTH");
372 userIdWidth.setText(wi == null ? "" : wi.toString());
373 blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
374 clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
375 fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
376 msfjv.setSelected(Cache.getDefault("MSF_JVSUFFIX", true));
377 pfamjv.setSelected(Cache.getDefault("PFAM_JVSUFFIX", true));
378 pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true));
379 pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true));
380 modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false));
381 embbedBioJSON.setSelected(Cache.getDefault("EXPORT_EMBBED_BIOJSON",
385 * Set Editing tab defaults
387 autoCalculateConsCheck.setSelected(Cache.getDefault(
388 "AUTO_CALC_CONSENSUS", true));
389 padGaps.setSelected(Cache.getDefault("PAD_GAPS", false));
390 sortByTree.setSelected(Cache.getDefault("SORT_BY_TREE", false));
392 annotations_actionPerformed(null); // update the display of the annotation
397 * Save user selections on the Preferences tabs to the Cache and write out to
403 public void ok_actionPerformed(ActionEvent e)
405 if (!validateSettings())
411 * Save Visual settings
413 Cache.applicationProperties.setProperty("SHOW_JVSUFFIX",
414 Boolean.toString(seqLimit.isSelected()));
415 Cache.applicationProperties.setProperty("RIGHT_ALIGN_IDS",
416 Boolean.toString(rightAlign.isSelected()));
417 Cache.applicationProperties.setProperty("SHOW_FULLSCREEN",
418 Boolean.toString(fullScreen.isSelected()));
419 Cache.applicationProperties.setProperty("SHOW_OVERVIEW",
420 Boolean.toString(openoverv.isSelected()));
421 Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
422 Boolean.toString(annotations.isSelected()));
423 Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
424 Boolean.toString(conservation.isSelected()));
425 Cache.applicationProperties.setProperty("SHOW_QUALITY",
426 Boolean.toString(quality.isSelected()));
427 Cache.applicationProperties.setProperty("SHOW_IDENTITY",
428 Boolean.toString(identity.isSelected()));
430 Cache.applicationProperties.setProperty("GAP_SYMBOL", gapSymbolCB
431 .getSelectedItem().toString());
433 Cache.applicationProperties.setProperty("FONT_NAME", fontNameCB
434 .getSelectedItem().toString());
435 Cache.applicationProperties.setProperty("FONT_STYLE", fontStyleCB
436 .getSelectedItem().toString());
437 Cache.applicationProperties.setProperty("FONT_SIZE", fontSizeCB
438 .getSelectedItem().toString());
440 Cache.applicationProperties.setProperty("ID_ITALICS",
441 Boolean.toString(idItalics.isSelected()));
442 Cache.applicationProperties.setProperty("SHOW_UNCONSERVED",
443 Boolean.toString(showUnconserved.isSelected()));
444 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSENSUS",
445 Boolean.toString(showGroupConsensus.isSelected()));
446 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSERVATION",
447 Boolean.toString(showGroupConservation.isSelected()));
448 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_HISTOGRAM",
449 Boolean.toString(showConsensHistogram.isSelected()));
450 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_LOGO",
451 Boolean.toString(showConsensLogo.isSelected()));
452 Cache.applicationProperties.setProperty("ANTI_ALIAS",
453 Boolean.toString(smoothFont.isSelected()));
454 Cache.applicationProperties.setProperty(SCALE_PROTEIN_TO_CDNA,
455 Boolean.toString(scaleProteinToCdna.isSelected()));
456 Cache.applicationProperties.setProperty("SHOW_NPFEATS_TOOLTIP",
457 Boolean.toString(showNpTooltip.isSelected()));
458 Cache.applicationProperties.setProperty("SHOW_DBREFS_TOOLTIP",
459 Boolean.toString(showDbRefTooltip.isSelected()));
461 Cache.applicationProperties.setProperty("WRAP_ALIGNMENT",
462 Boolean.toString(wrap.isSelected()));
464 Cache.applicationProperties.setProperty("STARTUP_FILE",
465 startupFileTextfield.getText());
466 Cache.applicationProperties.setProperty("SHOW_STARTUP_FILE",
467 Boolean.toString(startupCheckbox.isSelected()));
469 Cache.applicationProperties.setProperty("SORT_ALIGNMENT", sortby
470 .getSelectedItem().toString());
472 // convert description of sort order to enum name for save
473 SequenceAnnotationOrder annSortOrder = SequenceAnnotationOrder
474 .forDescription(sortAnnBy.getSelectedItem().toString());
475 if (annSortOrder != null)
477 Cache.applicationProperties.setProperty(SORT_ANNOTATIONS,
478 annSortOrder.name());
481 final boolean showAutocalcFirst = sortAutocalc.getSelectedIndex() == 0;
482 Cache.applicationProperties.setProperty(SHOW_AUTOCALC_ABOVE, Boolean
483 .valueOf(showAutocalcFirst).toString());
486 * Save Colours settings
488 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_PROT, protColour
489 .getSelectedItem().toString());
490 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_NUC, nucColour
491 .getSelectedItem().toString());
492 Cache.setColourProperty("ANNOTATIONCOLOUR_MIN",
493 minColour.getBackground());
494 Cache.setColourProperty("ANNOTATIONCOLOUR_MAX",
495 maxColour.getBackground());
498 * Save Structure settings
500 Cache.applicationProperties.setProperty(ADD_TEMPFACT_ANN,
501 Boolean.toString(addTempFactor.isSelected()));
502 Cache.applicationProperties.setProperty(ADD_SS_ANN,
503 Boolean.toString(addSecondaryStructure.isSelected()));
504 Cache.applicationProperties.setProperty(USE_RNAVIEW,
505 Boolean.toString(useRnaView.isSelected()));
506 Cache.applicationProperties.setProperty(STRUCT_FROM_PDB,
507 Boolean.toString(structFromPdb.isSelected()));
508 Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY, structViewer
509 .getSelectedItem().toString());
510 Cache.setOrRemove(CHIMERA_PATH, chimeraPath.getText());
511 Cache.applicationProperties.setProperty("MAP_WITH_SIFTS",
512 Boolean.toString(siftsMapping.isSelected()));
513 SiftsSettings.setMapWithSifts(siftsMapping.isSelected());
516 * Save Output settings
518 if (epsRendering.getSelectedItem().equals("Prompt each time"))
520 Cache.applicationProperties.remove("EPS_RENDERING");
524 Cache.applicationProperties.setProperty("EPS_RENDERING", epsRendering
525 .getSelectedItem().toString());
529 * Save Connections settings
531 Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
533 jalview.util.BrowserLauncher.resetBrowser();
535 if (nameLinks.size() > 0)
537 StringBuffer links = new StringBuffer();
538 sequenceURLLinks = new Vector<String>();
539 for (int i = 0; i < nameLinks.size(); i++)
541 sequenceURLLinks.addElement(nameLinks.elementAt(i) + "|"
542 + urlLinks.elementAt(i));
543 links.append(sequenceURLLinks.elementAt(i).toString());
547 links.setLength(links.length() - 1);
548 Cache.applicationProperties.setProperty("SEQUENCE_LINKS",
553 Cache.applicationProperties.remove("SEQUENCE_LINKS");
556 Cache.applicationProperties.setProperty("USE_PROXY",
557 Boolean.toString(useProxy.isSelected()));
559 Cache.setOrRemove("PROXY_SERVER", proxyServerTB.getText());
561 Cache.setOrRemove("PROXY_PORT", proxyPortTB.getText());
563 if (useProxy.isSelected())
565 System.setProperty("http.proxyHost", proxyServerTB.getText());
566 System.setProperty("http.proxyPort", proxyPortTB.getText());
570 System.setProperty("http.proxyHost", "");
571 System.setProperty("http.proxyPort", "");
573 Cache.setProperty("VERSION_CHECK",
574 Boolean.toString(versioncheck.isSelected()));
575 if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
577 // default is false - we only set this if the user has actively agreed
578 Cache.setProperty("USAGESTATS",
579 Boolean.toString(usagestats.isSelected()));
581 if (!questionnaire.isSelected())
583 Cache.setProperty("NOQUESTIONNAIRES", "true");
587 // special - made easy to edit a property file to disable questionnaires
588 // by just adding the given line
589 Cache.removeProperty("NOQUESTIONNAIRES");
593 * Save Output settings
595 Cache.applicationProperties.setProperty("BLC_JVSUFFIX",
596 Boolean.toString(blcjv.isSelected()));
597 Cache.applicationProperties.setProperty("CLUSTAL_JVSUFFIX",
598 Boolean.toString(clustaljv.isSelected()));
599 Cache.applicationProperties.setProperty("FASTA_JVSUFFIX",
600 Boolean.toString(fastajv.isSelected()));
601 Cache.applicationProperties.setProperty("MSF_JVSUFFIX",
602 Boolean.toString(msfjv.isSelected()));
603 Cache.applicationProperties.setProperty("PFAM_JVSUFFIX",
604 Boolean.toString(pfamjv.isSelected()));
605 Cache.applicationProperties.setProperty("PILEUP_JVSUFFIX",
606 Boolean.toString(pileupjv.isSelected()));
607 Cache.applicationProperties.setProperty("PIR_JVSUFFIX",
608 Boolean.toString(pirjv.isSelected()));
609 Cache.applicationProperties.setProperty("PIR_MODELLER",
610 Boolean.toString(modellerOutput.isSelected()));
611 Cache.applicationProperties.setProperty("EXPORT_EMBBED_BIOJSON",
612 Boolean.toString(embbedBioJSON.isSelected()));
613 jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
615 Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH",
616 Boolean.toString(autoIdWidth.isSelected()));
617 userIdWidth_actionPerformed();
618 Cache.applicationProperties.setProperty("FIGURE_USERIDWIDTH",
619 userIdWidth.getText());
622 * Save Editing settings
624 Cache.applicationProperties.setProperty("AUTO_CALC_CONSENSUS",
625 Boolean.toString(autoCalculateConsCheck.isSelected()));
626 Cache.applicationProperties.setProperty("SORT_BY_TREE",
627 Boolean.toString(sortByTree.isSelected()));
628 Cache.applicationProperties.setProperty("PAD_GAPS",
629 Boolean.toString(padGaps.isSelected()));
631 dasSource.saveProperties(Cache.applicationProperties);
632 wsPrefs.updateAndRefreshWsMenuConfig(false);
633 Cache.saveProperties();
634 Desktop.instance.doConfigureStructurePrefs();
637 frame.setClosed(true);
638 } catch (Exception ex)
644 * Do any necessary validation before saving settings. Return focus to the
645 * first tab which fails validation.
649 private boolean validateSettings()
651 if (!validateStructure())
653 structureTab.requestFocusInWindow();
660 protected boolean validateStructure()
662 return validateChimeraPath();
670 public void startupFileTextfield_mouseClicked()
672 JalviewFileChooser chooser = new JalviewFileChooser(
673 jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] {
674 "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc",
675 "jar" }, new String[] { "Fasta", "Clustal", "PFAM", "MSF",
676 "PIR", "BLC", "Jalview" },
677 jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT"));
678 chooser.setFileView(new JalviewFileView());
679 chooser.setDialogTitle(MessageManager
680 .getString("label.select_startup_file"));
682 int value = chooser.showOpenDialog(this);
684 if (value == JalviewFileChooser.APPROVE_OPTION)
686 jalview.bin.Cache.applicationProperties.setProperty(
687 "DEFAULT_FILE_FORMAT", chooser.getSelectedFormat());
688 startupFileTextfield.setText(chooser.getSelectedFile()
700 public void cancel_actionPerformed(ActionEvent e)
704 wsPrefs.updateWsMenuConfig(true);
705 wsPrefs.refreshWs_actionPerformed(e);
706 frame.setClosed(true);
707 } catch (Exception ex)
719 public void annotations_actionPerformed(ActionEvent e)
721 conservation.setEnabled(annotations.isSelected());
722 quality.setEnabled(annotations.isSelected());
723 identity.setEnabled(annotations.isSelected());
724 showGroupConsensus.setEnabled(annotations.isSelected());
725 showGroupConservation.setEnabled(annotations.isSelected());
726 showConsensHistogram.setEnabled(annotations.isSelected()
727 && (identity.isSelected() || showGroupConsensus.isSelected()));
728 showConsensLogo.setEnabled(annotations.isSelected()
729 && (identity.isSelected() || showGroupConsensus.isSelected()));
733 public void newLink_actionPerformed(ActionEvent e)
736 GSequenceLink link = new GSequenceLink();
737 boolean valid = false;
740 if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
741 MessageManager.getString("label.new_sequence_url_link"),
742 JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
744 if (link.checkValid())
746 nameLinks.addElement(link.getName());
747 urlLinks.addElement(link.getURL());
760 public void editLink_actionPerformed(ActionEvent e)
762 GSequenceLink link = new GSequenceLink();
764 int index = linkNameList.getSelectedIndex();
767 JOptionPane.showInternalMessageDialog(Desktop.desktop,
768 MessageManager.getString("label.no_link_selected"),
769 MessageManager.getString("label.no_link_selected"),
770 JOptionPane.WARNING_MESSAGE);
774 link.setName(nameLinks.elementAt(index).toString());
775 link.setURL(urlLinks.elementAt(index).toString());
777 boolean valid = false;
781 if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
782 MessageManager.getString("label.new_sequence_url_link"),
783 JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
785 if (link.checkValid())
787 nameLinks.setElementAt(link.getName(), index);
788 urlLinks.setElementAt(link.getURL(), index);
802 public void deleteLink_actionPerformed(ActionEvent e)
804 int index = linkNameList.getSelectedIndex();
807 JOptionPane.showInternalMessageDialog(Desktop.desktop,
808 MessageManager.getString("label.no_link_selected"),
809 MessageManager.getString("label.no_link_selected"),
810 JOptionPane.WARNING_MESSAGE);
813 nameLinks.removeElementAt(index);
814 urlLinks.removeElementAt(index);
818 void updateLinkData()
820 linkNameList.setListData(nameLinks);
821 linkURLList.setListData(urlLinks);
825 public void defaultBrowser_mouseClicked(MouseEvent e)
827 JFileChooser chooser = new JFileChooser(".");
828 chooser.setDialogTitle(MessageManager
829 .getString("label.select_default_browser"));
831 int value = chooser.showOpenDialog(this);
833 if (value == JFileChooser.APPROVE_OPTION)
835 defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath());
844 * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event
848 protected void showunconserved_actionPerformed(ActionEvent e)
850 // TODO Auto-generated method stub
851 super.showunconserved_actionPerformed(e);
854 public static List<String> getGroupURLLinks()
856 return groupURLLinks;
860 public void minColour_actionPerformed(JPanel panel)
862 Color col = JColorChooser.showDialog(this,
863 MessageManager.getString("label.select_colour_minimum_value"),
864 minColour.getBackground());
867 panel.setBackground(col);
873 public void maxColour_actionPerformed(JPanel panel)
875 Color col = JColorChooser.showDialog(this,
876 MessageManager.getString("label.select_colour_maximum_value"),
877 maxColour.getBackground());
880 panel.setBackground(col);
886 protected void userIdWidth_actionPerformed()
890 String val = userIdWidth.getText().trim();
891 if (val.length() > 0)
893 Integer iw = Integer.parseInt(val);
894 if (iw.intValue() < 12)
896 throw new NumberFormatException();
898 userIdWidth.setText(iw.toString());
900 } catch (NumberFormatException x)
902 JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
903 .getString("warn.user_defined_width_requirements"),
904 MessageManager.getString("label.invalid_id_column_width"),
905 JOptionPane.WARNING_MESSAGE);
906 userIdWidth.setText("");
911 protected void autoIdWidth_actionPerformed()
913 userIdWidth.setEnabled(!autoIdWidth.isSelected());
914 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
918 * Returns true if chimera path is to a valid executable, else show an error
921 private boolean validateChimeraPath()
923 if (chimeraPath.getText().trim().length() > 0)
925 File f = new File(chimeraPath.getText());
928 JOptionPane.showInternalMessageDialog(Desktop.desktop,
929 MessageManager.getString("label.invalid_chimera_path"),
930 MessageManager.getString("label.invalid_name"),
931 JOptionPane.ERROR_MESSAGE);
939 * If Chimera is selected, check it can be found on default or user-specified
940 * path, if not show a warning/help dialog.
943 protected void structureViewer_actionPerformed(String selectedItem)
945 if (!selectedItem.equals(ViewerType.CHIMERA.name()))
949 boolean found = false;
952 * Try user-specified and standard paths for Chimera executable.
954 List<String> paths = StructureManager.getChimeraPaths();
955 paths.add(0, chimeraPath.getText());
956 for (String path : paths)
958 if (new File(path.trim()).canExecute())
966 String[] options = { "OK", "Help" };
967 int showHelp = JOptionPane.showInternalOptionDialog(
969 JvSwingUtils.wrapTooltip(true,
970 MessageManager.getString("label.chimera_missing")),
971 "", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE,
972 null, options, options[0]);
973 if (showHelp == JOptionPane.NO_OPTION)
977 Help.showHelpWindow(HelpId.StructureViewer);
978 } catch (HelpSetException e)