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.ws.sifts.SiftsSettings;
35 import java.awt.BorderLayout;
36 import java.awt.Color;
37 import java.awt.Dimension;
39 import java.awt.event.ActionEvent;
40 import java.awt.event.ActionListener;
41 import java.awt.event.MouseEvent;
43 import java.util.Collection;
44 import java.util.List;
45 import java.util.StringTokenizer;
46 import java.util.Vector;
48 import javax.help.HelpSetException;
49 import javax.swing.JColorChooser;
50 import javax.swing.JFileChooser;
51 import javax.swing.JInternalFrame;
52 import javax.swing.JOptionPane;
53 import javax.swing.JPanel;
55 import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
63 public class Preferences extends GPreferences
65 public static final String ENABLE_SPLIT_FRAME = "ENABLE_SPLIT_FRAME";
67 public static final String SCALE_PROTEIN_TO_CDNA = "SCALE_PROTEIN_TO_CDNA";
69 public static final String DEFAULT_COLOUR = "DEFAULT_COLOUR";
71 public static final String DEFAULT_COLOUR_PROT = "DEFAULT_COLOUR_PROT";
73 public static final String DEFAULT_COLOUR_NUC = "DEFAULT_COLOUR_NUC";
75 public static final String ADD_TEMPFACT_ANN = "ADD_TEMPFACT_ANN";
77 public static final String ADD_SS_ANN = "ADD_SS_ANN";
79 public static final String USE_RNAVIEW = "USE_RNAVIEW";
81 public static final String STRUCT_FROM_PDB = "STRUCT_FROM_PDB";
83 public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY";
85 public static final String CHIMERA_PATH = "CHIMERA_PATH";
87 public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS";
89 public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE";
91 private static final int MIN_FONT_SIZE = 1;
93 private static final int MAX_FONT_SIZE = 30;
96 * Holds name and link separated with | character. Sequence ID must be
97 * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$
99 public static Vector sequenceURLLinks;
102 * Holds name and link separated with | character. Sequence IDS and Sequences
103 * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and
104 * $SEQUENCES$ or $SEQUENCES=/.possible | chars ./=$ and separation character
105 * for first and second token specified after a pipe character at end |,|.
106 * (TODO: proper escape for using | to separate ids or sequences
109 public static Vector groupURLLinks;
112 String string = Cache
115 "EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$");
116 sequenceURLLinks = new Vector();
120 StringTokenizer st = new StringTokenizer(string, "|");
121 while (st.hasMoreElements())
123 String name = st.nextToken();
124 String url = st.nextToken();
125 // check for '|' within a regex
126 int rxstart = url.indexOf("$SEQUENCE_ID$");
127 while (rxstart == -1 && url.indexOf("/=$") == -1)
129 url = url + "|" + st.nextToken();
131 sequenceURLLinks.addElement(name + "|" + url);
133 } catch (Exception ex)
135 System.out.println(ex + "\nError parsing sequence links");
138 // upgrade old SRS link
139 int srsPos = sequenceURLLinks
140 .indexOf("SRS|http://srs.ebi.ac.uk/srsbin/cgi-bin/wgetz?-newId+(([uniprot-all:$SEQUENCE_ID$]))+-view+SwissEntry");
145 "EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$",
151 * TODO: reformulate groupURL encoding so two or more can be stored in the
152 * .properties file as '|' separated strings
155 groupURLLinks = new Vector();
158 Vector nameLinks, urlLinks;
160 JInternalFrame frame;
162 DasSourceBrowser dasSource;
164 private WsPreferences wsPrefs;
167 * Creates a new Preferences object.
172 frame = new JInternalFrame();
173 frame.setContentPane(this);
174 dasSource = new DasSourceBrowser();
175 dasTab.add(dasSource, BorderLayout.CENTER);
176 wsPrefs = new WsPreferences();
177 wsTab.add(wsPrefs, BorderLayout.CENTER);
178 int width = 500, height = 450;
179 if (new jalview.util.Platform().isAMac())
185 Desktop.addInternalFrame(frame,
186 MessageManager.getString("label.preferences"), width, height);
187 frame.setMinimumSize(new Dimension(width, height));
190 * Set Visual tab defaults
192 seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true));
193 rightAlign.setSelected(Cache.getDefault("RIGHT_ALIGN_IDS", false));
194 fullScreen.setSelected(Cache.getDefault("SHOW_FULLSCREEN", false));
195 annotations.setSelected(Cache.getDefault("SHOW_ANNOTATIONS", true));
197 conservation.setSelected(Cache.getDefault("SHOW_CONSERVATION", true));
198 quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));
199 identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
200 openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false));
202 .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
203 showGroupConsensus.setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS",
205 showGroupConservation.setSelected(Cache.getDefault(
206 "SHOW_GROUP_CONSERVATION", false));
207 showConsensHistogram.setSelected(Cache.getDefault(
208 "SHOW_CONSENSUS_HISTOGRAM", true));
209 showConsensLogo.setSelected(Cache.getDefault("SHOW_CONSENSUS_LOGO",
211 showNpTooltip.setSelected(Cache
212 .getDefault("SHOW_NPFEATS_TOOLTIP", true));
213 showDbRefTooltip.setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP",
216 String[] fonts = java.awt.GraphicsEnvironment
217 .getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
218 for (int i = 0; i < fonts.length; i++)
220 fontNameCB.addItem(fonts[i]);
223 for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++)
225 fontSizeCB.addItem(i + "");
228 fontStyleCB.addItem("plain");
229 fontStyleCB.addItem("bold");
230 fontStyleCB.addItem("italic");
232 fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif"));
233 fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10"));
234 fontStyleCB.setSelectedItem(Cache.getDefault("FONT_STYLE", Font.PLAIN
237 smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", false));
238 scaleProteinToCdna.setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA,
241 idItalics.setSelected(Cache.getDefault("ID_ITALICS", true));
243 wrap.setSelected(Cache.getDefault("WRAP_ALIGNMENT", false));
245 gapSymbolCB.addItem("-");
246 gapSymbolCB.addItem(".");
248 gapSymbolCB.setSelectedItem(Cache.getDefault("GAP_SYMBOL", "-"));
250 sortby.addItem("No sort");
251 sortby.addItem("Id");
252 sortby.addItem("Pairwise Identity");
253 sortby.setSelectedItem(Cache.getDefault("SORT_ALIGNMENT", "No sort"));
255 sortAnnBy.addItem(SequenceAnnotationOrder.NONE.toString());
257 .addItem(SequenceAnnotationOrder.SEQUENCE_AND_LABEL.toString());
259 .addItem(SequenceAnnotationOrder.LABEL_AND_SEQUENCE.toString());
260 SequenceAnnotationOrder savedSort = SequenceAnnotationOrder
261 .valueOf(Cache.getDefault(SORT_ANNOTATIONS,
262 SequenceAnnotationOrder.NONE.name()));
263 sortAnnBy.setSelectedItem(savedSort.toString());
265 sortAutocalc.addItem("Autocalculated first");
266 sortAutocalc.addItem("Autocalculated last");
267 final boolean showAbove = Cache.getDefault(SHOW_AUTOCALC_ABOVE, true);
268 sortAutocalc.setSelectedItem(showAbove ? sortAutocalc.getItemAt(0)
269 : sortAutocalc.getItemAt(1));
271 .setSelected(Cache.getDefault("SHOW_STARTUP_FILE", true));
272 startupFileTextfield.setText(Cache.getDefault("STARTUP_FILE",
273 Cache.getDefault("www.jalview.org", "http://www.jalview.org")
274 + "/examples/exampleFile_2_3.jar"));
277 * Set Colours tab defaults
279 for (int i = ColourSchemeProperty.FIRST_COLOUR; i <= ColourSchemeProperty.LAST_COLOUR; i++)
281 protColour.addItem(ColourSchemeProperty.getColourName(i));
282 nucColour.addItem(ColourSchemeProperty.getColourName(i));
284 String oldProp = Cache.getDefault(DEFAULT_COLOUR, "None");
285 String newProp = Cache.getDefault(DEFAULT_COLOUR_PROT, null);
286 protColour.setSelectedItem(newProp != null ? newProp : oldProp);
287 newProp = Cache.getDefault(DEFAULT_COLOUR_NUC, null);
288 nucColour.setSelectedItem(newProp != null ? newProp : oldProp);
289 minColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN",
291 maxColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX",
295 * Set Structure tab defaults.
297 final boolean structSelected = Cache.getDefault(STRUCT_FROM_PDB, false);
298 structFromPdb.setSelected(structSelected);
299 useRnaView.setSelected(Cache.getDefault(USE_RNAVIEW, false));
300 useRnaView.setEnabled(structSelected);
301 addSecondaryStructure.setSelected(Cache.getDefault(ADD_SS_ANN, false));
302 addSecondaryStructure.setEnabled(structSelected);
303 addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, false));
304 addTempFactor.setEnabled(structSelected);
305 structViewer.setSelectedItem(Cache.getDefault(STRUCTURE_DISPLAY,
306 ViewerType.JMOL.name()));
307 chimeraPath.setText(Cache.getDefault(CHIMERA_PATH, ""));
308 chimeraPath.addActionListener(new ActionListener()
311 public void actionPerformed(ActionEvent e)
313 validateChimeraPath();
317 if (Cache.getDefault("MAP_WITH_SIFTS", false))
319 siftsMapping.setSelected(true);
323 nwMapping.setSelected(true);
327 .setMapWithSifts(Cache.getDefault("MAP_WITH_SIFTS", false));
330 * Set Connections tab defaults
332 nameLinks = new Vector();
333 urlLinks = new Vector();
334 for (int i = 0; i < sequenceURLLinks.size(); i++)
336 String link = sequenceURLLinks.elementAt(i).toString();
337 nameLinks.addElement(link.substring(0, link.indexOf("|")));
338 urlLinks.addElement(link.substring(link.indexOf("|") + 1));
343 useProxy.setSelected(Cache.getDefault("USE_PROXY", false));
344 proxyServerTB.setEnabled(useProxy.isSelected());
345 proxyPortTB.setEnabled(useProxy.isSelected());
346 proxyServerTB.setText(Cache.getDefault("PROXY_SERVER", ""));
347 proxyPortTB.setText(Cache.getDefault("PROXY_PORT", ""));
349 defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
351 usagestats.setSelected(Cache.getDefault("USAGESTATS", false));
352 // note antisense here: default is true
354 .setSelected(Cache.getProperty("NOQUESTIONNAIRES") == null);
355 versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true));
358 * Set Output tab defaults
361 .addItem(MessageManager.getString("label.prompt_each_time"));
362 epsRendering.addItem(MessageManager.getString("label.lineart"));
363 epsRendering.addItem(MessageManager.getString("action.text"));
364 epsRendering.setSelectedItem(Cache.getDefault("EPS_RENDERING",
365 "Prompt each time"));
366 autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
367 userIdWidth.setEnabled(!autoIdWidth.isSelected());
368 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
369 Integer wi = Cache.getIntegerProperty("FIGURE_USERIDWIDTH");
370 userIdWidth.setText(wi == null ? "" : wi.toString());
371 blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
372 clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
373 fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
374 msfjv.setSelected(Cache.getDefault("MSF_JVSUFFIX", true));
375 pfamjv.setSelected(Cache.getDefault("PFAM_JVSUFFIX", true));
376 pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true));
377 pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true));
378 modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false));
379 embbedBioJSON.setSelected(Cache.getDefault("EXPORT_EMBBED_BIOJSON",
383 * Set Editing tab defaults
385 autoCalculateConsCheck.setSelected(Cache.getDefault(
386 "AUTO_CALC_CONSENSUS", true));
387 padGaps.setSelected(Cache.getDefault("PAD_GAPS", false));
388 sortByTree.setSelected(Cache.getDefault("SORT_BY_TREE", false));
390 annotations_actionPerformed(null); // update the display of the annotation
395 * Save user selections on the Preferences tabs to the Cache and write out to
401 public void ok_actionPerformed(ActionEvent e)
403 if (!validateSettings())
409 * Save Visual settings
411 Cache.applicationProperties.setProperty("SHOW_JVSUFFIX",
412 Boolean.toString(seqLimit.isSelected()));
413 Cache.applicationProperties.setProperty("RIGHT_ALIGN_IDS",
414 Boolean.toString(rightAlign.isSelected()));
415 Cache.applicationProperties.setProperty("SHOW_FULLSCREEN",
416 Boolean.toString(fullScreen.isSelected()));
417 Cache.applicationProperties.setProperty("SHOW_OVERVIEW",
418 Boolean.toString(openoverv.isSelected()));
419 Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
420 Boolean.toString(annotations.isSelected()));
421 Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
422 Boolean.toString(conservation.isSelected()));
423 Cache.applicationProperties.setProperty("SHOW_QUALITY",
424 Boolean.toString(quality.isSelected()));
425 Cache.applicationProperties.setProperty("SHOW_IDENTITY",
426 Boolean.toString(identity.isSelected()));
428 Cache.applicationProperties.setProperty("GAP_SYMBOL", gapSymbolCB
429 .getSelectedItem().toString());
431 Cache.applicationProperties.setProperty("FONT_NAME", fontNameCB
432 .getSelectedItem().toString());
433 Cache.applicationProperties.setProperty("FONT_STYLE", fontStyleCB
434 .getSelectedItem().toString());
435 Cache.applicationProperties.setProperty("FONT_SIZE", fontSizeCB
436 .getSelectedItem().toString());
438 Cache.applicationProperties.setProperty("ID_ITALICS",
439 Boolean.toString(idItalics.isSelected()));
440 Cache.applicationProperties.setProperty("SHOW_UNCONSERVED",
441 Boolean.toString(showUnconserved.isSelected()));
442 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSENSUS",
443 Boolean.toString(showGroupConsensus.isSelected()));
444 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSERVATION",
445 Boolean.toString(showGroupConservation.isSelected()));
446 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_HISTOGRAM",
447 Boolean.toString(showConsensHistogram.isSelected()));
448 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_LOGO",
449 Boolean.toString(showConsensLogo.isSelected()));
450 Cache.applicationProperties.setProperty("ANTI_ALIAS",
451 Boolean.toString(smoothFont.isSelected()));
452 Cache.applicationProperties.setProperty(SCALE_PROTEIN_TO_CDNA,
453 Boolean.toString(scaleProteinToCdna.isSelected()));
454 Cache.applicationProperties.setProperty("SHOW_NPFEATS_TOOLTIP",
455 Boolean.toString(showNpTooltip.isSelected()));
456 Cache.applicationProperties.setProperty("SHOW_DBREFS_TOOLTIP",
457 Boolean.toString(showDbRefTooltip.isSelected()));
459 Cache.applicationProperties.setProperty("WRAP_ALIGNMENT",
460 Boolean.toString(wrap.isSelected()));
462 Cache.applicationProperties.setProperty("STARTUP_FILE",
463 startupFileTextfield.getText());
464 Cache.applicationProperties.setProperty("SHOW_STARTUP_FILE",
465 Boolean.toString(startupCheckbox.isSelected()));
467 Cache.applicationProperties.setProperty("SORT_ALIGNMENT", sortby
468 .getSelectedItem().toString());
470 // convert description of sort order to enum name for save
471 SequenceAnnotationOrder annSortOrder = SequenceAnnotationOrder
472 .forDescription(sortAnnBy.getSelectedItem().toString());
473 if (annSortOrder != null)
475 Cache.applicationProperties.setProperty(SORT_ANNOTATIONS,
476 annSortOrder.name());
479 final boolean showAutocalcFirst = sortAutocalc.getSelectedIndex() == 0;
480 Cache.applicationProperties.setProperty(SHOW_AUTOCALC_ABOVE, Boolean
481 .valueOf(showAutocalcFirst).toString());
484 * Save Colours settings
486 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_PROT, protColour
487 .getSelectedItem().toString());
488 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_NUC, nucColour
489 .getSelectedItem().toString());
490 Cache.setColourProperty("ANNOTATIONCOLOUR_MIN",
491 minColour.getBackground());
492 Cache.setColourProperty("ANNOTATIONCOLOUR_MAX",
493 maxColour.getBackground());
496 * Save Structure settings
498 Cache.applicationProperties.setProperty(ADD_TEMPFACT_ANN,
499 Boolean.toString(addTempFactor.isSelected()));
500 Cache.applicationProperties.setProperty(ADD_SS_ANN,
501 Boolean.toString(addSecondaryStructure.isSelected()));
502 Cache.applicationProperties.setProperty(USE_RNAVIEW,
503 Boolean.toString(useRnaView.isSelected()));
504 Cache.applicationProperties.setProperty(STRUCT_FROM_PDB,
505 Boolean.toString(structFromPdb.isSelected()));
506 Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY, structViewer
507 .getSelectedItem().toString());
508 Cache.setOrRemove(CHIMERA_PATH, chimeraPath.getText());
509 Cache.applicationProperties.setProperty("MAP_WITH_SIFTS",
510 Boolean.toString(siftsMapping.isSelected()));
511 SiftsSettings.setMapWithSifts(siftsMapping.isSelected());
514 * Save Output settings
516 if (epsRendering.getSelectedItem().equals("Prompt each time"))
518 Cache.applicationProperties.remove("EPS_RENDERING");
522 Cache.applicationProperties.setProperty("EPS_RENDERING", epsRendering
523 .getSelectedItem().toString());
527 * Save Connections settings
529 Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
531 jalview.util.BrowserLauncher.resetBrowser();
533 if (nameLinks.size() > 0)
535 StringBuffer links = new StringBuffer();
536 sequenceURLLinks = new Vector();
537 for (int i = 0; i < nameLinks.size(); i++)
539 sequenceURLLinks.addElement(nameLinks.elementAt(i) + "|"
540 + urlLinks.elementAt(i));
541 links.append(sequenceURLLinks.elementAt(i).toString());
545 links.setLength(links.length() - 1);
546 Cache.applicationProperties.setProperty("SEQUENCE_LINKS",
551 Cache.applicationProperties.remove("SEQUENCE_LINKS");
554 Cache.applicationProperties.setProperty("USE_PROXY",
555 Boolean.toString(useProxy.isSelected()));
557 Cache.setOrRemove("PROXY_SERVER", proxyServerTB.getText());
559 Cache.setOrRemove("PROXY_PORT", proxyPortTB.getText());
561 if (useProxy.isSelected())
563 System.setProperty("http.proxyHost", proxyServerTB.getText());
564 System.setProperty("http.proxyPort", proxyPortTB.getText());
568 System.setProperty("http.proxyHost", "");
569 System.setProperty("http.proxyPort", "");
571 Cache.setProperty("VERSION_CHECK",
572 Boolean.toString(versioncheck.isSelected()));
573 if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
575 // default is false - we only set this if the user has actively agreed
576 Cache.setProperty("USAGESTATS",
577 Boolean.toString(usagestats.isSelected()));
579 if (!questionnaire.isSelected())
581 Cache.setProperty("NOQUESTIONNAIRES", "true");
585 // special - made easy to edit a property file to disable questionnaires
586 // by just adding the given line
587 Cache.removeProperty("NOQUESTIONNAIRES");
591 * Save Output settings
593 Cache.applicationProperties.setProperty("BLC_JVSUFFIX",
594 Boolean.toString(blcjv.isSelected()));
595 Cache.applicationProperties.setProperty("CLUSTAL_JVSUFFIX",
596 Boolean.toString(clustaljv.isSelected()));
597 Cache.applicationProperties.setProperty("FASTA_JVSUFFIX",
598 Boolean.toString(fastajv.isSelected()));
599 Cache.applicationProperties.setProperty("MSF_JVSUFFIX",
600 Boolean.toString(msfjv.isSelected()));
601 Cache.applicationProperties.setProperty("PFAM_JVSUFFIX",
602 Boolean.toString(pfamjv.isSelected()));
603 Cache.applicationProperties.setProperty("PILEUP_JVSUFFIX",
604 Boolean.toString(pileupjv.isSelected()));
605 Cache.applicationProperties.setProperty("PIR_JVSUFFIX",
606 Boolean.toString(pirjv.isSelected()));
607 Cache.applicationProperties.setProperty("PIR_MODELLER",
608 Boolean.toString(modellerOutput.isSelected()));
609 Cache.applicationProperties.setProperty("EXPORT_EMBBED_BIOJSON",
610 Boolean.toString(embbedBioJSON.isSelected()));
611 jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
613 Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH",
614 Boolean.toString(autoIdWidth.isSelected()));
615 userIdWidth_actionPerformed();
616 Cache.applicationProperties.setProperty("FIGURE_USERIDWIDTH",
617 userIdWidth.getText());
620 * Save Editing settings
622 Cache.applicationProperties.setProperty("AUTO_CALC_CONSENSUS",
623 Boolean.toString(autoCalculateConsCheck.isSelected()));
624 Cache.applicationProperties.setProperty("SORT_BY_TREE",
625 Boolean.toString(sortByTree.isSelected()));
626 Cache.applicationProperties.setProperty("PAD_GAPS",
627 Boolean.toString(padGaps.isSelected()));
629 dasSource.saveProperties(Cache.applicationProperties);
630 wsPrefs.updateAndRefreshWsMenuConfig(false);
631 Cache.saveProperties();
632 Desktop.instance.doConfigureStructurePrefs();
635 frame.setClosed(true);
636 } catch (Exception ex)
642 * Do any necessary validation before saving settings. Return focus to the
643 * first tab which fails validation.
647 private boolean validateSettings()
649 if (!validateStructure())
651 structureTab.requestFocusInWindow();
658 protected boolean validateStructure()
660 return validateChimeraPath();
668 public void startupFileTextfield_mouseClicked()
670 JalviewFileChooser chooser = new JalviewFileChooser(
671 jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] {
672 "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc",
673 "jar" }, new String[] { "Fasta", "Clustal", "PFAM", "MSF",
674 "PIR", "BLC", "Jalview" },
675 jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT"));
676 chooser.setFileView(new JalviewFileView());
677 chooser.setDialogTitle(MessageManager
678 .getString("label.select_startup_file"));
680 int value = chooser.showOpenDialog(this);
682 if (value == JalviewFileChooser.APPROVE_OPTION)
684 jalview.bin.Cache.applicationProperties.setProperty(
685 "DEFAULT_FILE_FORMAT", chooser.getSelectedFormat());
686 startupFileTextfield.setText(chooser.getSelectedFile()
698 public void cancel_actionPerformed(ActionEvent e)
702 wsPrefs.updateWsMenuConfig(true);
703 wsPrefs.refreshWs_actionPerformed(e);
704 frame.setClosed(true);
705 } catch (Exception ex)
717 public void annotations_actionPerformed(ActionEvent e)
719 conservation.setEnabled(annotations.isSelected());
720 quality.setEnabled(annotations.isSelected());
721 identity.setEnabled(annotations.isSelected());
722 showGroupConsensus.setEnabled(annotations.isSelected());
723 showGroupConservation.setEnabled(annotations.isSelected());
724 showConsensHistogram.setEnabled(annotations.isSelected()
725 && (identity.isSelected() || showGroupConsensus.isSelected()));
726 showConsensLogo.setEnabled(annotations.isSelected()
727 && (identity.isSelected() || showGroupConsensus.isSelected()));
731 public void newLink_actionPerformed(ActionEvent e)
734 GSequenceLink link = new GSequenceLink();
735 boolean valid = false;
738 if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
739 MessageManager.getString("label.new_sequence_url_link"),
740 JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
742 if (link.checkValid())
744 nameLinks.addElement(link.getName());
745 urlLinks.addElement(link.getURL());
758 public void editLink_actionPerformed(ActionEvent e)
760 GSequenceLink link = new GSequenceLink();
762 int index = linkNameList.getSelectedIndex();
765 JOptionPane.showInternalMessageDialog(Desktop.desktop,
766 MessageManager.getString("label.no_link_selected"),
767 MessageManager.getString("label.no_link_selected"),
768 JOptionPane.WARNING_MESSAGE);
772 link.setName(nameLinks.elementAt(index).toString());
773 link.setURL(urlLinks.elementAt(index).toString());
775 boolean valid = false;
779 if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
780 MessageManager.getString("label.new_sequence_url_link"),
781 JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
783 if (link.checkValid())
785 nameLinks.setElementAt(link.getName(), index);
786 urlLinks.setElementAt(link.getURL(), index);
800 public void deleteLink_actionPerformed(ActionEvent e)
802 int index = linkNameList.getSelectedIndex();
805 JOptionPane.showInternalMessageDialog(Desktop.desktop,
806 MessageManager.getString("label.no_link_selected"),
807 MessageManager.getString("label.no_link_selected"),
808 JOptionPane.WARNING_MESSAGE);
811 nameLinks.removeElementAt(index);
812 urlLinks.removeElementAt(index);
816 void updateLinkData()
818 linkNameList.setListData(nameLinks);
819 linkURLList.setListData(urlLinks);
823 public void defaultBrowser_mouseClicked(MouseEvent e)
825 JFileChooser chooser = new JFileChooser(".");
826 chooser.setDialogTitle(MessageManager
827 .getString("label.select_default_browser"));
829 int value = chooser.showOpenDialog(this);
831 if (value == JFileChooser.APPROVE_OPTION)
833 defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath());
842 * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event
846 protected void showunconserved_actionPerformed(ActionEvent e)
848 // TODO Auto-generated method stub
849 super.showunconserved_actionPerformed(e);
852 public static Collection getGroupURLLinks()
854 return groupURLLinks;
858 public void minColour_actionPerformed(JPanel panel)
860 Color col = JColorChooser.showDialog(this,
861 MessageManager.getString("label.select_colour_minimum_value"),
862 minColour.getBackground());
865 panel.setBackground(col);
871 public void maxColour_actionPerformed(JPanel panel)
873 Color col = JColorChooser.showDialog(this,
874 MessageManager.getString("label.select_colour_maximum_value"),
875 maxColour.getBackground());
878 panel.setBackground(col);
884 protected void userIdWidth_actionPerformed()
888 String val = userIdWidth.getText().trim();
889 if (val.length() > 0)
891 Integer iw = Integer.parseInt(val);
892 if (iw.intValue() < 12)
894 throw new NumberFormatException();
896 userIdWidth.setText(iw.toString());
898 } catch (NumberFormatException x)
900 JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
901 .getString("warn.user_defined_width_requirements"),
902 MessageManager.getString("label.invalid_id_column_width"),
903 JOptionPane.WARNING_MESSAGE);
904 userIdWidth.setText("");
909 protected void autoIdWidth_actionPerformed()
911 userIdWidth.setEnabled(!autoIdWidth.isSelected());
912 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
916 * Returns true if chimera path is to a valid executable, else show an error
919 private boolean validateChimeraPath()
921 if (chimeraPath.getText().trim().length() > 0)
923 File f = new File(chimeraPath.getText());
926 JOptionPane.showInternalMessageDialog(Desktop.desktop,
927 MessageManager.getString("label.invalid_chimera_path"),
928 MessageManager.getString("label.invalid_name"),
929 JOptionPane.ERROR_MESSAGE);
937 * If Chimera is selected, check it can be found on default or user-specified
938 * path, if not show a warning/help dialog.
941 protected void structureViewer_actionPerformed(String selectedItem)
943 if (!selectedItem.equals(ViewerType.CHIMERA.name()))
947 boolean found = false;
950 * Try user-specified and standard paths for Chimera executable.
952 List<String> paths = StructureManager.getChimeraPaths();
953 paths.add(0, chimeraPath.getText());
954 for (String path : paths)
956 if (new File(path.trim()).canExecute())
964 String[] options = { "OK", "Help" };
965 int showHelp = JOptionPane.showInternalOptionDialog(
967 JvSwingUtils.wrapTooltip(true,
968 MessageManager.getString("label.chimera_missing")),
969 "", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE,
970 null, options, options[0]);
971 if (showHelp == JOptionPane.NO_OPTION)
975 Help.showHelpWindow(HelpId.StructureViewer);
976 } catch (HelpSetException e)