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;
34 import java.awt.BorderLayout;
35 import java.awt.Color;
36 import java.awt.Dimension;
38 import java.awt.event.ActionEvent;
39 import java.awt.event.ActionListener;
40 import java.awt.event.MouseEvent;
42 import java.util.Collection;
43 import java.util.List;
44 import java.util.StringTokenizer;
45 import java.util.Vector;
47 import javax.help.HelpSetException;
48 import javax.swing.JColorChooser;
49 import javax.swing.JFileChooser;
50 import javax.swing.JInternalFrame;
51 import javax.swing.JOptionPane;
52 import javax.swing.JPanel;
54 import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
62 public class Preferences extends GPreferences
64 public static final String ENABLE_SPLIT_FRAME = "ENABLE_SPLIT_FRAME";
66 public static final String SCALE_PROTEIN_TO_CDNA = "SCALE_PROTEIN_TO_CDNA";
68 public static final String DEFAULT_COLOUR = "DEFAULT_COLOUR";
70 public static final String DEFAULT_COLOUR_PROT = "DEFAULT_COLOUR_PROT";
72 public static final String DEFAULT_COLOUR_NUC = "DEFAULT_COLOUR_NUC";
74 public static final String ADD_TEMPFACT_ANN = "ADD_TEMPFACT_ANN";
76 public static final String ADD_SS_ANN = "ADD_SS_ANN";
78 public static final String USE_RNAVIEW = "USE_RNAVIEW";
80 public static final String STRUCT_FROM_PDB = "STRUCT_FROM_PDB";
82 public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY";
84 public static final String CHIMERA_PATH = "CHIMERA_PATH";
86 public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS";
88 public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE";
90 private static final int MIN_FONT_SIZE = 1;
92 private static final int MAX_FONT_SIZE = 30;
95 * Holds name and link separated with | character. Sequence ID must be
96 * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$
98 public static Vector sequenceURLLinks;
101 * Holds name and link separated with | character. Sequence IDS and Sequences
102 * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and
103 * $SEQUENCES$ or $SEQUENCES=/.possible | chars ./=$ and separation character
104 * for first and second token specified after a pipe character at end |,|.
105 * (TODO: proper escape for using | to separate ids or sequences
108 public static Vector groupURLLinks;
111 String string = Cache
114 "EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$");
115 sequenceURLLinks = new Vector();
119 StringTokenizer st = new StringTokenizer(string, "|");
120 while (st.hasMoreElements())
122 String name = st.nextToken();
123 String url = st.nextToken();
124 // check for '|' within a regex
125 int rxstart = url.indexOf("$SEQUENCE_ID$");
126 while (rxstart == -1 && url.indexOf("/=$") == -1)
128 url = url + "|" + st.nextToken();
130 sequenceURLLinks.addElement(name + "|" + url);
132 } catch (Exception ex)
134 System.out.println(ex + "\nError parsing sequence links");
137 // upgrade old SRS link
138 int srsPos = sequenceURLLinks
139 .indexOf("SRS|http://srs.ebi.ac.uk/srsbin/cgi-bin/wgetz?-newId+(([uniprot-all:$SEQUENCE_ID$]))+-view+SwissEntry");
144 "EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$",
150 * TODO: reformulate groupURL encoding so two or more can be stored in the
151 * .properties file as '|' separated strings
154 groupURLLinks = new Vector();
157 Vector nameLinks, urlLinks;
159 JInternalFrame frame;
161 DasSourceBrowser dasSource;
163 private WsPreferences wsPrefs;
166 * Creates a new Preferences object.
171 frame = new JInternalFrame();
172 frame.setContentPane(this);
173 dasSource = new DasSourceBrowser();
174 dasTab.add(dasSource, BorderLayout.CENTER);
175 wsPrefs = new WsPreferences();
176 wsTab.add(wsPrefs, BorderLayout.CENTER);
177 int width = 500, height = 450;
178 if (new jalview.util.Platform().isAMac())
184 Desktop.addInternalFrame(frame,
185 MessageManager.getString("label.preferences"), width, height);
186 frame.setMinimumSize(new Dimension(width, height));
189 * Set Visual tab defaults
191 seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true));
192 rightAlign.setSelected(Cache.getDefault("RIGHT_ALIGN_IDS", false));
193 fullScreen.setSelected(Cache.getDefault("SHOW_FULLSCREEN", false));
194 annotations.setSelected(Cache.getDefault("SHOW_ANNOTATIONS", true));
196 conservation.setSelected(Cache.getDefault("SHOW_CONSERVATION", true));
197 quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));
198 identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
199 openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false));
201 .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
202 showGroupConsensus.setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS",
204 showGroupConservation.setSelected(Cache.getDefault(
205 "SHOW_GROUP_CONSERVATION", false));
206 showConsensHistogram.setSelected(Cache.getDefault(
207 "SHOW_CONSENSUS_HISTOGRAM", true));
208 showConsensLogo.setSelected(Cache.getDefault("SHOW_CONSENSUS_LOGO",
210 showNpTooltip.setSelected(Cache
211 .getDefault("SHOW_NPFEATS_TOOLTIP", true));
212 showDbRefTooltip.setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP",
215 String[] fonts = java.awt.GraphicsEnvironment
216 .getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
217 for (int i = 0; i < fonts.length; i++)
219 fontNameCB.addItem(fonts[i]);
222 for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++)
224 fontSizeCB.addItem(i + "");
227 fontStyleCB.addItem("plain");
228 fontStyleCB.addItem("bold");
229 fontStyleCB.addItem("italic");
231 fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif"));
232 fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10"));
233 fontStyleCB.setSelectedItem(Cache.getDefault("FONT_STYLE", Font.PLAIN
236 smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", false));
237 scaleProteinToCdna.setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA,
240 idItalics.setSelected(Cache.getDefault("ID_ITALICS", true));
242 wrap.setSelected(Cache.getDefault("WRAP_ALIGNMENT", false));
244 gapSymbolCB.addItem("-");
245 gapSymbolCB.addItem(".");
247 gapSymbolCB.setSelectedItem(Cache.getDefault("GAP_SYMBOL", "-"));
249 sortby.addItem("No sort");
250 sortby.addItem("Id");
251 sortby.addItem("Pairwise Identity");
252 sortby.setSelectedItem(Cache.getDefault("SORT_ALIGNMENT", "No sort"));
254 sortAnnBy.addItem(SequenceAnnotationOrder.NONE.toString());
256 .addItem(SequenceAnnotationOrder.SEQUENCE_AND_LABEL.toString());
258 .addItem(SequenceAnnotationOrder.LABEL_AND_SEQUENCE.toString());
259 SequenceAnnotationOrder savedSort = SequenceAnnotationOrder
260 .valueOf(Cache.getDefault(SORT_ANNOTATIONS,
261 SequenceAnnotationOrder.NONE.name()));
262 sortAnnBy.setSelectedItem(savedSort.toString());
264 sortAutocalc.addItem("Autocalculated first");
265 sortAutocalc.addItem("Autocalculated last");
266 final boolean showAbove = Cache.getDefault(SHOW_AUTOCALC_ABOVE,
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
302 .setSelected(Cache.getDefault(ADD_SS_ANN, false));
303 addSecondaryStructure.setEnabled(structSelected);
304 addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, false));
305 addTempFactor.setEnabled(structSelected);
306 structViewer.setSelectedItem(Cache.getDefault(STRUCTURE_DISPLAY,
307 ViewerType.JMOL.name()));
308 chimeraPath.setText(Cache.getDefault(CHIMERA_PATH, ""));
309 chimeraPath.addActionListener(new ActionListener()
312 public void actionPerformed(ActionEvent e)
314 validateChimeraPath();
319 * Set Connections tab defaults
321 nameLinks = new Vector();
322 urlLinks = new Vector();
323 for (int i = 0; i < sequenceURLLinks.size(); i++)
325 String link = sequenceURLLinks.elementAt(i).toString();
326 nameLinks.addElement(link.substring(0, link.indexOf("|")));
327 urlLinks.addElement(link.substring(link.indexOf("|") + 1));
332 useProxy.setSelected(Cache.getDefault("USE_PROXY", false));
333 proxyServerTB.setEnabled(useProxy.isSelected());
334 proxyPortTB.setEnabled(useProxy.isSelected());
335 proxyServerTB.setText(Cache.getDefault("PROXY_SERVER", ""));
336 proxyPortTB.setText(Cache.getDefault("PROXY_PORT", ""));
338 defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
340 usagestats.setSelected(Cache.getDefault("USAGESTATS", false));
341 // note antisense here: default is true
343 .setSelected(Cache.getProperty("NOQUESTIONNAIRES") == null);
344 versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true));
347 * Set Output tab defaults
350 .addItem(MessageManager.getString("label.prompt_each_time"));
351 epsRendering.addItem(MessageManager.getString("label.lineart"));
352 epsRendering.addItem(MessageManager.getString("action.text"));
353 epsRendering.setSelectedItem(Cache.getDefault("EPS_RENDERING",
354 "Prompt each time"));
355 autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
356 userIdWidth.setEnabled(autoIdWidth.isSelected());
357 userIdWidthlabel.setEnabled(autoIdWidth.isSelected());
358 Integer wi = Cache.getIntegerProperty("FIGURE_USERIDWIDTH");
359 userIdWidth.setText(wi == null ? "" : wi.toString());
360 blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
361 clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
362 fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
363 msfjv.setSelected(Cache.getDefault("MSF_JVSUFFIX", true));
364 pfamjv.setSelected(Cache.getDefault("PFAM_JVSUFFIX", true));
365 pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true));
366 pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true));
367 modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false));
368 embbedBioJSON.setSelected(Cache.getDefault("EXPORT_EMBBED_BIOJSON",
372 * Set Editing tab defaults
374 autoCalculateConsCheck.setSelected(Cache.getDefault(
375 "AUTO_CALC_CONSENSUS", true));
376 padGaps.setSelected(Cache.getDefault("PAD_GAPS", false));
377 sortByTree.setSelected(Cache.getDefault("SORT_BY_TREE", false));
379 annotations_actionPerformed(null); // update the display of the annotation
384 * Save user selections on the Preferences tabs to the Cache and write out to
389 public void ok_actionPerformed(ActionEvent e)
391 if (!validateSettings())
397 * Save Visual settings
399 Cache.applicationProperties.setProperty("SHOW_JVSUFFIX",
400 Boolean.toString(seqLimit.isSelected()));
401 Cache.applicationProperties.setProperty("RIGHT_ALIGN_IDS",
402 Boolean.toString(rightAlign.isSelected()));
403 Cache.applicationProperties.setProperty("SHOW_FULLSCREEN",
404 Boolean.toString(fullScreen.isSelected()));
405 Cache.applicationProperties.setProperty("SHOW_OVERVIEW",
406 Boolean.toString(openoverv.isSelected()));
407 Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
408 Boolean.toString(annotations.isSelected()));
409 Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
410 Boolean.toString(conservation.isSelected()));
411 Cache.applicationProperties.setProperty("SHOW_QUALITY",
412 Boolean.toString(quality.isSelected()));
413 Cache.applicationProperties.setProperty("SHOW_IDENTITY",
414 Boolean.toString(identity.isSelected()));
416 Cache.applicationProperties.setProperty("GAP_SYMBOL", gapSymbolCB
417 .getSelectedItem().toString());
419 Cache.applicationProperties.setProperty("FONT_NAME", fontNameCB
420 .getSelectedItem().toString());
421 Cache.applicationProperties.setProperty("FONT_STYLE", fontStyleCB
422 .getSelectedItem().toString());
423 Cache.applicationProperties.setProperty("FONT_SIZE", fontSizeCB
424 .getSelectedItem().toString());
426 Cache.applicationProperties.setProperty("ID_ITALICS",
427 Boolean.toString(idItalics.isSelected()));
428 Cache.applicationProperties.setProperty("SHOW_UNCONSERVED",
429 Boolean.toString(showUnconserved.isSelected()));
430 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSENSUS",
431 Boolean.toString(showGroupConsensus.isSelected()));
432 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSERVATION",
433 Boolean.toString(showGroupConservation.isSelected()));
434 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_HISTOGRAM",
435 Boolean.toString(showConsensHistogram.isSelected()));
436 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_LOGO",
437 Boolean.toString(showConsensLogo.isSelected()));
438 Cache.applicationProperties.setProperty("ANTI_ALIAS",
439 Boolean.toString(smoothFont.isSelected()));
440 Cache.applicationProperties.setProperty(SCALE_PROTEIN_TO_CDNA,
441 Boolean.toString(scaleProteinToCdna.isSelected()));
442 Cache.applicationProperties.setProperty("SHOW_NPFEATS_TOOLTIP",
443 Boolean.toString(showNpTooltip.isSelected()));
444 Cache.applicationProperties.setProperty("SHOW_DBREFS_TOOLTIP",
445 Boolean.toString(showDbRefTooltip.isSelected()));
447 Cache.applicationProperties.setProperty("WRAP_ALIGNMENT",
448 Boolean.toString(wrap.isSelected()));
450 Cache.applicationProperties.setProperty("STARTUP_FILE",
451 startupFileTextfield.getText());
452 Cache.applicationProperties.setProperty("SHOW_STARTUP_FILE",
453 Boolean.toString(startupCheckbox.isSelected()));
455 Cache.applicationProperties.setProperty("SORT_ALIGNMENT", sortby
456 .getSelectedItem().toString());
458 // convert description of sort order to enum name for save
459 SequenceAnnotationOrder annSortOrder = SequenceAnnotationOrder
460 .forDescription(sortAnnBy.getSelectedItem().toString());
461 if (annSortOrder != null)
463 Cache.applicationProperties.setProperty(SORT_ANNOTATIONS,
464 annSortOrder.name());
467 final boolean showAutocalcFirst = sortAutocalc.getSelectedIndex() == 0;
468 Cache.applicationProperties.setProperty(SHOW_AUTOCALC_ABOVE,
469 Boolean.valueOf(showAutocalcFirst).toString());
472 * Save Colours settings
474 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_PROT, protColour
475 .getSelectedItem().toString());
476 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_NUC, nucColour
477 .getSelectedItem().toString());
478 Cache.setColourProperty("ANNOTATIONCOLOUR_MIN",
479 minColour.getBackground());
480 Cache.setColourProperty("ANNOTATIONCOLOUR_MAX",
481 maxColour.getBackground());
484 * Save Structure settings
486 Cache.applicationProperties.setProperty(ADD_TEMPFACT_ANN,
487 Boolean.toString(addTempFactor.isSelected()));
488 Cache.applicationProperties.setProperty(ADD_SS_ANN,
489 Boolean.toString(addSecondaryStructure.isSelected()));
490 Cache.applicationProperties.setProperty(USE_RNAVIEW,
491 Boolean.toString(useRnaView.isSelected()));
492 Cache.applicationProperties.setProperty(STRUCT_FROM_PDB,
493 Boolean.toString(structFromPdb.isSelected()));
494 Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY, structViewer
495 .getSelectedItem().toString());
496 Cache.setOrRemove(CHIMERA_PATH, chimeraPath.getText());
499 * Save Output settings
501 if (epsRendering.getSelectedItem().equals("Prompt each time"))
503 Cache.applicationProperties.remove("EPS_RENDERING");
507 Cache.applicationProperties.setProperty("EPS_RENDERING", epsRendering
508 .getSelectedItem().toString());
512 * Save Connections settings
514 Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
516 jalview.util.BrowserLauncher.resetBrowser();
518 if (nameLinks.size() > 0)
520 StringBuffer links = new StringBuffer();
521 sequenceURLLinks = new Vector();
522 for (int i = 0; i < nameLinks.size(); i++)
524 sequenceURLLinks.addElement(nameLinks.elementAt(i) + "|"
525 + urlLinks.elementAt(i));
526 links.append(sequenceURLLinks.elementAt(i).toString());
530 links.setLength(links.length() - 1);
531 Cache.applicationProperties.setProperty("SEQUENCE_LINKS",
536 Cache.applicationProperties.remove("SEQUENCE_LINKS");
539 Cache.applicationProperties.setProperty("USE_PROXY",
540 Boolean.toString(useProxy.isSelected()));
542 Cache.setOrRemove("PROXY_SERVER", proxyServerTB.getText());
544 Cache.setOrRemove("PROXY_PORT", proxyPortTB.getText());
546 if (useProxy.isSelected())
548 System.setProperty("http.proxyHost", proxyServerTB.getText());
549 System.setProperty("http.proxyPort", proxyPortTB.getText());
553 System.setProperty("http.proxyHost", "");
554 System.setProperty("http.proxyPort", "");
556 Cache.setProperty("VERSION_CHECK",
557 Boolean.toString(versioncheck.isSelected()));
558 if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
560 // default is false - we only set this if the user has actively agreed
561 Cache.setProperty("USAGESTATS",
562 Boolean.toString(usagestats.isSelected()));
564 if (!questionnaire.isSelected())
566 Cache.setProperty("NOQUESTIONNAIRES", "true");
570 // special - made easy to edit a property file to disable questionnaires
571 // by just adding the given line
572 Cache.removeProperty("NOQUESTIONNAIRES");
576 * Save Output settings
578 Cache.applicationProperties.setProperty("BLC_JVSUFFIX",
579 Boolean.toString(blcjv.isSelected()));
580 Cache.applicationProperties.setProperty("CLUSTAL_JVSUFFIX",
581 Boolean.toString(clustaljv.isSelected()));
582 Cache.applicationProperties.setProperty("FASTA_JVSUFFIX",
583 Boolean.toString(fastajv.isSelected()));
584 Cache.applicationProperties.setProperty("MSF_JVSUFFIX",
585 Boolean.toString(msfjv.isSelected()));
586 Cache.applicationProperties.setProperty("PFAM_JVSUFFIX",
587 Boolean.toString(pfamjv.isSelected()));
588 Cache.applicationProperties.setProperty("PILEUP_JVSUFFIX",
589 Boolean.toString(pileupjv.isSelected()));
590 Cache.applicationProperties.setProperty("PIR_JVSUFFIX",
591 Boolean.toString(pirjv.isSelected()));
592 Cache.applicationProperties.setProperty("PIR_MODELLER",
593 Boolean.toString(modellerOutput.isSelected()));
594 Cache.applicationProperties.setProperty("EXPORT_EMBBED_BIOJSON",
595 Boolean.toString(embbedBioJSON.isSelected()));
596 jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
598 Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH",
599 Boolean.toString(autoIdWidth.isSelected()));
600 userIdWidth_actionPerformed();
601 Cache.applicationProperties.setProperty("FIGURE_USERIDWIDTH",
602 userIdWidth.getText());
605 * Save Editing settings
607 Cache.applicationProperties.setProperty("AUTO_CALC_CONSENSUS",
608 Boolean.toString(autoCalculateConsCheck.isSelected()));
609 Cache.applicationProperties.setProperty("SORT_BY_TREE",
610 Boolean.toString(sortByTree.isSelected()));
611 Cache.applicationProperties.setProperty("PAD_GAPS",
612 Boolean.toString(padGaps.isSelected()));
614 dasSource.saveProperties(Cache.applicationProperties);
615 wsPrefs.updateAndRefreshWsMenuConfig(false);
616 Cache.saveProperties();
617 Desktop.instance.doConfigureStructurePrefs();
620 frame.setClosed(true);
621 } catch (Exception ex)
627 * Do any necessary validation before saving settings. Return focus to the
628 * first tab which fails validation.
632 private boolean validateSettings()
634 if (!validateStructure())
636 structureTab.requestFocusInWindow();
643 protected boolean validateStructure()
645 return validateChimeraPath();
651 public void startupFileTextfield_mouseClicked()
653 JalviewFileChooser chooser = new JalviewFileChooser(
654 jalview.bin.Cache.getProperty("LAST_DIRECTORY"),
656 { "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc", "jar" },
658 { "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview" },
659 jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT"));
660 chooser.setFileView(new JalviewFileView());
661 chooser.setDialogTitle(MessageManager.getString("label.select_startup_file"));
663 int value = chooser.showOpenDialog(this);
665 if (value == JalviewFileChooser.APPROVE_OPTION)
667 jalview.bin.Cache.applicationProperties.setProperty(
668 "DEFAULT_FILE_FORMAT", chooser.getSelectedFormat());
669 startupFileTextfield.setText(chooser.getSelectedFile()
680 public void cancel_actionPerformed(ActionEvent e)
684 wsPrefs.updateWsMenuConfig(true);
685 wsPrefs.refreshWs_actionPerformed(e);
686 frame.setClosed(true);
687 } catch (Exception ex)
698 public void annotations_actionPerformed(ActionEvent e)
700 conservation.setEnabled(annotations.isSelected());
701 quality.setEnabled(annotations.isSelected());
702 identity.setEnabled(annotations.isSelected());
703 showGroupConsensus.setEnabled(annotations.isSelected());
704 showGroupConservation.setEnabled(annotations.isSelected());
705 showConsensHistogram.setEnabled(annotations.isSelected()
706 && (identity.isSelected() || showGroupConsensus.isSelected()));
707 showConsensLogo.setEnabled(annotations.isSelected()
708 && (identity.isSelected() || showGroupConsensus.isSelected()));
711 public void newLink_actionPerformed(ActionEvent e)
714 GSequenceLink link = new GSequenceLink();
715 boolean valid = false;
718 if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
719 MessageManager.getString("label.new_sequence_url_link"),
720 JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
722 if (link.checkValid())
724 nameLinks.addElement(link.getName());
725 urlLinks.addElement(link.getURL());
737 public void editLink_actionPerformed(ActionEvent e)
739 GSequenceLink link = new GSequenceLink();
741 int index = linkNameList.getSelectedIndex();
744 JOptionPane.showInternalMessageDialog(Desktop.desktop,
745 MessageManager.getString("label.no_link_selected"),
746 MessageManager.getString("label.no_link_selected"),
747 JOptionPane.WARNING_MESSAGE);
751 link.setName(nameLinks.elementAt(index).toString());
752 link.setURL(urlLinks.elementAt(index).toString());
754 boolean valid = false;
758 if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
759 MessageManager.getString("label.new_sequence_url_link"),
760 JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
762 if (link.checkValid())
764 nameLinks.setElementAt(link.getName(), index);
765 urlLinks.setElementAt(link.getURL(), index);
778 public void deleteLink_actionPerformed(ActionEvent e)
780 int index = linkNameList.getSelectedIndex();
783 JOptionPane.showInternalMessageDialog(Desktop.desktop,
784 MessageManager.getString("label.no_link_selected"),
785 MessageManager.getString("label.no_link_selected"),
786 JOptionPane.WARNING_MESSAGE);
789 nameLinks.removeElementAt(index);
790 urlLinks.removeElementAt(index);
794 void updateLinkData()
796 linkNameList.setListData(nameLinks);
797 linkURLList.setListData(urlLinks);
800 public void defaultBrowser_mouseClicked(MouseEvent e)
802 JFileChooser chooser = new JFileChooser(".");
803 chooser.setDialogTitle(MessageManager.getString("label.select_default_browser"));
805 int value = chooser.showOpenDialog(this);
807 if (value == JFileChooser.APPROVE_OPTION)
809 defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath());
818 * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event
821 protected void showunconserved_actionPerformed(ActionEvent e)
823 // TODO Auto-generated method stub
824 super.showunconserved_actionPerformed(e);
827 public static Collection getGroupURLLinks()
829 return groupURLLinks;
833 public void minColour_actionPerformed(JPanel panel)
835 Color col = JColorChooser.showDialog(this,
836 MessageManager.getString("label.select_colour_minimum_value"), minColour.getBackground());
839 panel.setBackground(col);
845 public void maxColour_actionPerformed(JPanel panel)
847 Color col = JColorChooser.showDialog(this,
848 MessageManager.getString("label.select_colour_maximum_value"), maxColour.getBackground());
851 panel.setBackground(col);
857 protected void userIdWidth_actionPerformed()
861 String val = userIdWidth.getText().trim();
862 if (val.length() > 0)
864 Integer iw = Integer.parseInt(val);
865 if (iw.intValue() < 12)
867 throw new NumberFormatException();
869 userIdWidth.setText(iw.toString());
871 } catch (NumberFormatException x)
874 .showInternalMessageDialog(
876 MessageManager.getString("warn.user_defined_width_requirements"),
877 MessageManager.getString("label.invalid_id_column_width"),
878 JOptionPane.WARNING_MESSAGE);
879 userIdWidth.setText("");
884 protected void autoIdWidth_actionPerformed()
886 userIdWidth.setEnabled(!autoIdWidth.isSelected());
887 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
891 * Returns true if chimera path is to a valid executable, else show an error
894 private boolean validateChimeraPath()
896 if (chimeraPath.getText().trim().length() > 0)
898 File f = new File(chimeraPath.getText());
901 JOptionPane.showInternalMessageDialog(Desktop.desktop,
902 MessageManager.getString("label.invalid_chimera_path"),
903 MessageManager.getString("label.invalid_name"),
904 JOptionPane.ERROR_MESSAGE);
912 * If Chimera is selected, check it can be found on default or user-specified
913 * path, if not show a warning/help dialog.
916 protected void structureViewer_actionPerformed(String selectedItem)
918 if (!selectedItem.equals(ViewerType.CHIMERA.name()))
922 boolean found = false;
925 * Try user-specified and standard paths for Chimera executable.
927 List<String> paths = StructureManager.getChimeraPaths();
928 paths.add(0, chimeraPath.getText());
929 for (String path : paths)
931 if (new File(path.trim()).canExecute())
941 int showHelp = JOptionPane.showInternalOptionDialog(
943 JvSwingUtils.wrapTooltip(true,
944 MessageManager.getString("label.chimera_missing")),
945 "", JOptionPane.YES_NO_OPTION,
946 JOptionPane.WARNING_MESSAGE, null, options, options[0]);
947 if (showHelp == JOptionPane.NO_OPTION)
951 Help.showHelpWindow(HelpId.StructureViewer);
952 } catch (HelpSetException e)