2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import static jalview.util.UrlConstants.DB_ACCESSION;
24 import static jalview.util.UrlConstants.EMBLEBI_STRING;
25 import static jalview.util.UrlConstants.SEQUENCE_ID;
26 import static jalview.util.UrlConstants.SRS_STRING;
28 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
29 import jalview.bin.Cache;
30 import jalview.gui.Help.HelpId;
31 import jalview.gui.StructureViewer.ViewerType;
32 import jalview.io.FileFormatI;
33 import jalview.io.JalviewFileChooser;
34 import jalview.io.JalviewFileView;
35 import jalview.jbgui.GPreferences;
36 import jalview.jbgui.GSequenceLink;
37 import jalview.schemes.ColourSchemeI;
38 import jalview.schemes.ColourSchemes;
39 import jalview.schemes.ResidueColourScheme;
40 import jalview.util.MessageManager;
41 import jalview.util.Platform;
42 import jalview.ws.sifts.SiftsSettings;
44 import java.awt.BorderLayout;
45 import java.awt.Color;
46 import java.awt.Dimension;
48 import java.awt.event.ActionEvent;
49 import java.awt.event.ActionListener;
50 import java.awt.event.MouseEvent;
52 import java.util.ArrayList;
53 import java.util.List;
54 import java.util.StringTokenizer;
55 import java.util.Vector;
57 import javax.help.HelpSetException;
58 import javax.swing.JColorChooser;
59 import javax.swing.JFileChooser;
60 import javax.swing.JInternalFrame;
61 import javax.swing.JPanel;
63 import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
71 public class Preferences extends GPreferences
73 public static final String ENABLE_SPLIT_FRAME = "ENABLE_SPLIT_FRAME";
75 public static final String SCALE_PROTEIN_TO_CDNA = "SCALE_PROTEIN_TO_CDNA";
77 public static final String DEFAULT_COLOUR = "DEFAULT_COLOUR";
79 public static final String DEFAULT_COLOUR_PROT = "DEFAULT_COLOUR_PROT";
81 public static final String DEFAULT_COLOUR_NUC = "DEFAULT_COLOUR_NUC";
83 public static final String ADD_TEMPFACT_ANN = "ADD_TEMPFACT_ANN";
85 public static final String ADD_SS_ANN = "ADD_SS_ANN";
87 public static final String USE_RNAVIEW = "USE_RNAVIEW";
89 public static final String STRUCT_FROM_PDB = "STRUCT_FROM_PDB";
91 public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY";
93 public static final String CHIMERA_PATH = "CHIMERA_PATH";
95 public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS";
97 public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE";
99 private static final int MIN_FONT_SIZE = 1;
101 private static final int MAX_FONT_SIZE = 30;
104 * Holds name and link separated with | character. Sequence ID must be
105 * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$
107 public static Vector<String> sequenceURLLinks;
110 * Holds name and link separated with | character. Sequence IDS and Sequences
111 * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and
112 * $SEQUENCES$ or $SEQUENCES=/.possible | chars ./=$ and separation character
113 * for first and second token specified after a pipe character at end |,|.
114 * (TODO: proper escape for using | to separate ids or sequences
117 public static List<String> groupURLLinks;
120 String string = Cache.getDefault("SEQUENCE_LINKS", EMBLEBI_STRING);
121 sequenceURLLinks = new Vector<String>();
125 StringTokenizer st = new StringTokenizer(string, "|");
126 while (st.hasMoreElements())
128 String name = st.nextToken();
129 String url = st.nextToken();
130 // check for '|' within a regex
131 int rxstart = url.indexOf("$" + DB_ACCESSION + "$");
134 rxstart = url.indexOf("$" + SEQUENCE_ID + "$");
136 while (rxstart == -1 && url.indexOf("/=$") == -1)
138 url = url + "|" + st.nextToken();
140 sequenceURLLinks.addElement(name + "|" + url);
142 } catch (Exception ex)
144 System.out.println(ex + "\nError parsing sequence links");
147 // upgrade old SRS link
148 int srsPos = sequenceURLLinks.indexOf(SRS_STRING);
151 sequenceURLLinks.setElementAt(EMBLEBI_STRING, srsPos);
156 * TODO: reformulate groupURL encoding so two or more can be stored in the
157 * .properties file as '|' separated strings
160 groupURLLinks = new ArrayList<String>();
163 Vector<String> nameLinks, urlLinks;
165 JInternalFrame frame;
167 DasSourceBrowser dasSource;
169 private WsPreferences wsPrefs;
171 private OptionsParam promptEachTimeOpt = new OptionsParam(
172 MessageManager.getString("label.prompt_each_time"),
175 private OptionsParam lineArtOpt = new OptionsParam(
176 MessageManager.getString("label.lineart"), "Lineart");
178 private OptionsParam textOpt = new OptionsParam(
179 MessageManager.getString("action.text"), "Text");
182 * Creates a new Preferences object.
187 frame = new JInternalFrame();
188 frame.setContentPane(this);
189 dasSource = new DasSourceBrowser();
190 dasTab.add(dasSource, BorderLayout.CENTER);
191 wsPrefs = new WsPreferences();
192 wsTab.add(wsPrefs, BorderLayout.CENTER);
193 int width = 500, height = 450;
194 new jalview.util.Platform();
195 if (Platform.isAMac())
201 Desktop.addInternalFrame(frame,
202 MessageManager.getString("label.preferences"), width, height);
203 frame.setMinimumSize(new Dimension(width, height));
206 * Set Visual tab defaults
208 seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true));
209 rightAlign.setSelected(Cache.getDefault("RIGHT_ALIGN_IDS", false));
210 fullScreen.setSelected(Cache.getDefault("SHOW_FULLSCREEN", false));
211 annotations.setSelected(Cache.getDefault("SHOW_ANNOTATIONS", true));
213 conservation.setSelected(Cache.getDefault("SHOW_CONSERVATION", true));
214 quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));
215 identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
216 openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false));
218 .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
219 showGroupConsensus.setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS",
221 showGroupConservation.setSelected(Cache.getDefault(
222 "SHOW_GROUP_CONSERVATION", false));
223 showConsensHistogram.setSelected(Cache.getDefault(
224 "SHOW_CONSENSUS_HISTOGRAM", true));
225 showConsensLogo.setSelected(Cache.getDefault("SHOW_CONSENSUS_LOGO",
227 showNpTooltip.setSelected(Cache
228 .getDefault("SHOW_NPFEATS_TOOLTIP", true));
229 showDbRefTooltip.setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP",
232 String[] fonts = java.awt.GraphicsEnvironment
233 .getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
234 for (int i = 0; i < fonts.length; i++)
236 fontNameCB.addItem(fonts[i]);
239 for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++)
241 fontSizeCB.addItem(i + "");
244 fontStyleCB.addItem("plain");
245 fontStyleCB.addItem("bold");
246 fontStyleCB.addItem("italic");
248 fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif"));
249 fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10"));
250 fontStyleCB.setSelectedItem(Cache.getDefault("FONT_STYLE", Font.PLAIN
253 smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", false));
254 scaleProteinToCdna.setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA,
257 idItalics.setSelected(Cache.getDefault("ID_ITALICS", true));
259 wrap.setSelected(Cache.getDefault("WRAP_ALIGNMENT", false));
261 gapSymbolCB.addItem("-");
262 gapSymbolCB.addItem(".");
264 gapSymbolCB.setSelectedItem(Cache.getDefault("GAP_SYMBOL", "-"));
266 sortby.addItem("No sort");
267 sortby.addItem("Id");
268 sortby.addItem("Pairwise Identity");
269 sortby.setSelectedItem(Cache.getDefault("SORT_ALIGNMENT", "No sort"));
271 sortAnnBy.addItem(SequenceAnnotationOrder.NONE.toString());
273 .addItem(SequenceAnnotationOrder.SEQUENCE_AND_LABEL.toString());
275 .addItem(SequenceAnnotationOrder.LABEL_AND_SEQUENCE.toString());
276 SequenceAnnotationOrder savedSort = SequenceAnnotationOrder
277 .valueOf(Cache.getDefault(SORT_ANNOTATIONS,
278 SequenceAnnotationOrder.NONE.name()));
279 sortAnnBy.setSelectedItem(savedSort.toString());
281 sortAutocalc.addItem("Autocalculated first");
282 sortAutocalc.addItem("Autocalculated last");
283 final boolean showAbove = Cache.getDefault(SHOW_AUTOCALC_ABOVE, true);
284 sortAutocalc.setSelectedItem(showAbove ? sortAutocalc.getItemAt(0)
285 : sortAutocalc.getItemAt(1));
287 .setSelected(Cache.getDefault("SHOW_STARTUP_FILE", true));
288 startupFileTextfield.setText(Cache.getDefault("STARTUP_FILE",
289 Cache.getDefault("www.jalview.org", "http://www.jalview.org")
290 + "/examples/exampleFile_2_3.jar"));
293 * Set Colours tab defaults
295 protColour.addItem(ResidueColourScheme.NONE);
296 nucColour.addItem(ResidueColourScheme.NONE);
297 for (ColourSchemeI cs : ColourSchemes.getInstance().getColourSchemes())
299 String name = cs.getSchemeName();
300 protColour.addItem(name);
301 nucColour.addItem(name);
303 String oldProp = Cache.getDefault(DEFAULT_COLOUR,
304 ResidueColourScheme.NONE);
305 String newProp = Cache.getDefault(DEFAULT_COLOUR_PROT, null);
306 protColour.setSelectedItem(newProp != null ? newProp : oldProp);
307 newProp = Cache.getDefault(DEFAULT_COLOUR_NUC, null);
308 nucColour.setSelectedItem(newProp != null ? newProp : oldProp);
309 minColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN",
311 maxColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX",
315 * Set Structure tab defaults.
317 final boolean structSelected = Cache.getDefault(STRUCT_FROM_PDB, false);
318 structFromPdb.setSelected(structSelected);
319 useRnaView.setSelected(Cache.getDefault(USE_RNAVIEW, false));
320 useRnaView.setEnabled(structSelected);
321 addSecondaryStructure.setSelected(Cache.getDefault(ADD_SS_ANN, false));
322 addSecondaryStructure.setEnabled(structSelected);
323 addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, false));
324 addTempFactor.setEnabled(structSelected);
325 structViewer.setSelectedItem(Cache.getDefault(STRUCTURE_DISPLAY,
326 ViewerType.JMOL.name()));
327 chimeraPath.setText(Cache.getDefault(CHIMERA_PATH, ""));
328 chimeraPath.addActionListener(new ActionListener()
331 public void actionPerformed(ActionEvent e)
333 validateChimeraPath();
337 if (Cache.getDefault("MAP_WITH_SIFTS", false))
339 siftsMapping.setSelected(true);
343 nwMapping.setSelected(true);
347 .setMapWithSifts(Cache.getDefault("MAP_WITH_SIFTS", false));
350 * Set Connections tab defaults
352 nameLinks = new Vector<String>();
353 urlLinks = new Vector<String>();
354 for (int i = 0; i < sequenceURLLinks.size(); i++)
356 String link = sequenceURLLinks.elementAt(i).toString();
357 nameLinks.addElement(link.substring(0, link.indexOf("|")));
358 urlLinks.addElement(link.substring(link.indexOf("|") + 1));
363 useProxy.setSelected(Cache.getDefault("USE_PROXY", false));
364 proxyServerTB.setEnabled(useProxy.isSelected());
365 proxyPortTB.setEnabled(useProxy.isSelected());
366 proxyServerTB.setText(Cache.getDefault("PROXY_SERVER", ""));
367 proxyPortTB.setText(Cache.getDefault("PROXY_PORT", ""));
369 defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
371 usagestats.setSelected(Cache.getDefault("USAGESTATS", false));
372 // note antisense here: default is true
374 .setSelected(Cache.getProperty("NOQUESTIONNAIRES") == null);
375 versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true));
378 * Set Output tab defaults
380 epsRendering.addItem(promptEachTimeOpt);
381 epsRendering.addItem(lineArtOpt);
382 epsRendering.addItem(textOpt);
383 String defaultEPS = Cache.getDefault("EPS_RENDERING",
385 if (defaultEPS.equalsIgnoreCase("Text"))
387 epsRendering.setSelectedItem(textOpt);
389 else if (defaultEPS.equalsIgnoreCase("Lineart"))
391 epsRendering.setSelectedItem(lineArtOpt);
395 epsRendering.setSelectedItem(promptEachTimeOpt);
397 autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
398 userIdWidth.setEnabled(!autoIdWidth.isSelected());
399 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
400 Integer wi = Cache.getIntegerProperty("FIGURE_USERIDWIDTH");
401 userIdWidth.setText(wi == null ? "" : wi.toString());
402 blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
403 clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
404 fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
405 msfjv.setSelected(Cache.getDefault("MSF_JVSUFFIX", true));
406 pfamjv.setSelected(Cache.getDefault("PFAM_JVSUFFIX", true));
407 pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true));
408 pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true));
409 modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false));
410 embbedBioJSON.setSelected(Cache.getDefault("EXPORT_EMBBED_BIOJSON",
414 * Set Editing tab defaults
416 autoCalculateConsCheck.setSelected(Cache.getDefault(
417 "AUTO_CALC_CONSENSUS", true));
418 padGaps.setSelected(Cache.getDefault("PAD_GAPS", false));
419 sortByTree.setSelected(Cache.getDefault("SORT_BY_TREE", false));
421 annotations_actionPerformed(null); // update the display of the annotation
426 * Save user selections on the Preferences tabs to the Cache and write out to
432 public void ok_actionPerformed(ActionEvent e)
434 if (!validateSettings())
440 * Save Visual settings
442 Cache.applicationProperties.setProperty("SHOW_JVSUFFIX",
443 Boolean.toString(seqLimit.isSelected()));
444 Cache.applicationProperties.setProperty("RIGHT_ALIGN_IDS",
445 Boolean.toString(rightAlign.isSelected()));
446 Cache.applicationProperties.setProperty("SHOW_FULLSCREEN",
447 Boolean.toString(fullScreen.isSelected()));
448 Cache.applicationProperties.setProperty("SHOW_OVERVIEW",
449 Boolean.toString(openoverv.isSelected()));
450 Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
451 Boolean.toString(annotations.isSelected()));
452 Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
453 Boolean.toString(conservation.isSelected()));
454 Cache.applicationProperties.setProperty("SHOW_QUALITY",
455 Boolean.toString(quality.isSelected()));
456 Cache.applicationProperties.setProperty("SHOW_IDENTITY",
457 Boolean.toString(identity.isSelected()));
459 Cache.applicationProperties.setProperty("GAP_SYMBOL", gapSymbolCB
460 .getSelectedItem().toString());
462 Cache.applicationProperties.setProperty("FONT_NAME", fontNameCB
463 .getSelectedItem().toString());
464 Cache.applicationProperties.setProperty("FONT_STYLE", fontStyleCB
465 .getSelectedItem().toString());
466 Cache.applicationProperties.setProperty("FONT_SIZE", fontSizeCB
467 .getSelectedItem().toString());
469 Cache.applicationProperties.setProperty("ID_ITALICS",
470 Boolean.toString(idItalics.isSelected()));
471 Cache.applicationProperties.setProperty("SHOW_UNCONSERVED",
472 Boolean.toString(showUnconserved.isSelected()));
473 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSENSUS",
474 Boolean.toString(showGroupConsensus.isSelected()));
475 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSERVATION",
476 Boolean.toString(showGroupConservation.isSelected()));
477 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_HISTOGRAM",
478 Boolean.toString(showConsensHistogram.isSelected()));
479 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_LOGO",
480 Boolean.toString(showConsensLogo.isSelected()));
481 Cache.applicationProperties.setProperty("ANTI_ALIAS",
482 Boolean.toString(smoothFont.isSelected()));
483 Cache.applicationProperties.setProperty(SCALE_PROTEIN_TO_CDNA,
484 Boolean.toString(scaleProteinToCdna.isSelected()));
485 Cache.applicationProperties.setProperty("SHOW_NPFEATS_TOOLTIP",
486 Boolean.toString(showNpTooltip.isSelected()));
487 Cache.applicationProperties.setProperty("SHOW_DBREFS_TOOLTIP",
488 Boolean.toString(showDbRefTooltip.isSelected()));
490 Cache.applicationProperties.setProperty("WRAP_ALIGNMENT",
491 Boolean.toString(wrap.isSelected()));
493 Cache.applicationProperties.setProperty("STARTUP_FILE",
494 startupFileTextfield.getText());
495 Cache.applicationProperties.setProperty("SHOW_STARTUP_FILE",
496 Boolean.toString(startupCheckbox.isSelected()));
498 Cache.applicationProperties.setProperty("SORT_ALIGNMENT", sortby
499 .getSelectedItem().toString());
501 // convert description of sort order to enum name for save
502 SequenceAnnotationOrder annSortOrder = SequenceAnnotationOrder
503 .forDescription(sortAnnBy.getSelectedItem().toString());
504 if (annSortOrder != null)
506 Cache.applicationProperties.setProperty(SORT_ANNOTATIONS,
507 annSortOrder.name());
510 final boolean showAutocalcFirst = sortAutocalc.getSelectedIndex() == 0;
511 Cache.applicationProperties.setProperty(SHOW_AUTOCALC_ABOVE, Boolean
512 .valueOf(showAutocalcFirst).toString());
515 * Save Colours settings
517 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_PROT, protColour
518 .getSelectedItem().toString());
519 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_NUC, nucColour
520 .getSelectedItem().toString());
521 Cache.setColourProperty("ANNOTATIONCOLOUR_MIN",
522 minColour.getBackground());
523 Cache.setColourProperty("ANNOTATIONCOLOUR_MAX",
524 maxColour.getBackground());
527 * Save Structure settings
529 Cache.applicationProperties.setProperty(ADD_TEMPFACT_ANN,
530 Boolean.toString(addTempFactor.isSelected()));
531 Cache.applicationProperties.setProperty(ADD_SS_ANN,
532 Boolean.toString(addSecondaryStructure.isSelected()));
533 Cache.applicationProperties.setProperty(USE_RNAVIEW,
534 Boolean.toString(useRnaView.isSelected()));
535 Cache.applicationProperties.setProperty(STRUCT_FROM_PDB,
536 Boolean.toString(structFromPdb.isSelected()));
537 Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY, structViewer
538 .getSelectedItem().toString());
539 Cache.setOrRemove(CHIMERA_PATH, chimeraPath.getText());
540 Cache.applicationProperties.setProperty("MAP_WITH_SIFTS",
541 Boolean.toString(siftsMapping.isSelected()));
542 SiftsSettings.setMapWithSifts(siftsMapping.isSelected());
545 * Save Output settings
547 Cache.applicationProperties.setProperty("EPS_RENDERING",
548 ((OptionsParam) epsRendering.getSelectedItem()).getCode());
551 * Save Connections settings
553 Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
555 jalview.util.BrowserLauncher.resetBrowser();
557 if (nameLinks.size() > 0)
559 StringBuffer links = new StringBuffer();
560 sequenceURLLinks = new Vector<String>();
561 for (int i = 0; i < nameLinks.size(); i++)
563 sequenceURLLinks.addElement(nameLinks.elementAt(i) + "|"
564 + urlLinks.elementAt(i));
565 links.append(sequenceURLLinks.elementAt(i).toString());
569 links.setLength(links.length() - 1);
570 Cache.applicationProperties.setProperty("SEQUENCE_LINKS",
575 Cache.applicationProperties.remove("SEQUENCE_LINKS");
576 sequenceURLLinks.clear();
579 Cache.applicationProperties.setProperty("USE_PROXY",
580 Boolean.toString(useProxy.isSelected()));
582 Cache.setOrRemove("PROXY_SERVER", proxyServerTB.getText());
584 Cache.setOrRemove("PROXY_PORT", proxyPortTB.getText());
586 if (useProxy.isSelected())
588 System.setProperty("http.proxyHost", proxyServerTB.getText());
589 System.setProperty("http.proxyPort", proxyPortTB.getText());
593 System.setProperty("http.proxyHost", "");
594 System.setProperty("http.proxyPort", "");
596 Cache.setProperty("VERSION_CHECK",
597 Boolean.toString(versioncheck.isSelected()));
598 if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
600 // default is false - we only set this if the user has actively agreed
601 Cache.setProperty("USAGESTATS",
602 Boolean.toString(usagestats.isSelected()));
604 if (!questionnaire.isSelected())
606 Cache.setProperty("NOQUESTIONNAIRES", "true");
610 // special - made easy to edit a property file to disable questionnaires
611 // by just adding the given line
612 Cache.removeProperty("NOQUESTIONNAIRES");
616 * Save Output settings
618 Cache.applicationProperties.setProperty("BLC_JVSUFFIX",
619 Boolean.toString(blcjv.isSelected()));
620 Cache.applicationProperties.setProperty("CLUSTAL_JVSUFFIX",
621 Boolean.toString(clustaljv.isSelected()));
622 Cache.applicationProperties.setProperty("FASTA_JVSUFFIX",
623 Boolean.toString(fastajv.isSelected()));
624 Cache.applicationProperties.setProperty("MSF_JVSUFFIX",
625 Boolean.toString(msfjv.isSelected()));
626 Cache.applicationProperties.setProperty("PFAM_JVSUFFIX",
627 Boolean.toString(pfamjv.isSelected()));
628 Cache.applicationProperties.setProperty("PILEUP_JVSUFFIX",
629 Boolean.toString(pileupjv.isSelected()));
630 Cache.applicationProperties.setProperty("PIR_JVSUFFIX",
631 Boolean.toString(pirjv.isSelected()));
632 Cache.applicationProperties.setProperty("PIR_MODELLER",
633 Boolean.toString(modellerOutput.isSelected()));
634 Cache.applicationProperties.setProperty("EXPORT_EMBBED_BIOJSON",
635 Boolean.toString(embbedBioJSON.isSelected()));
636 jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
638 Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH",
639 Boolean.toString(autoIdWidth.isSelected()));
640 userIdWidth_actionPerformed();
641 Cache.applicationProperties.setProperty("FIGURE_USERIDWIDTH",
642 userIdWidth.getText());
645 * Save Editing settings
647 Cache.applicationProperties.setProperty("AUTO_CALC_CONSENSUS",
648 Boolean.toString(autoCalculateConsCheck.isSelected()));
649 Cache.applicationProperties.setProperty("SORT_BY_TREE",
650 Boolean.toString(sortByTree.isSelected()));
651 Cache.applicationProperties.setProperty("PAD_GAPS",
652 Boolean.toString(padGaps.isSelected()));
654 dasSource.saveProperties(Cache.applicationProperties);
655 wsPrefs.updateAndRefreshWsMenuConfig(false);
656 Cache.saveProperties();
657 Desktop.instance.doConfigureStructurePrefs();
660 frame.setClosed(true);
661 } catch (Exception ex)
667 * Do any necessary validation before saving settings. Return focus to the
668 * first tab which fails validation.
672 private boolean validateSettings()
674 if (!validateStructure())
676 structureTab.requestFocusInWindow();
683 protected boolean validateStructure()
685 return validateChimeraPath();
693 public void startupFileTextfield_mouseClicked()
695 String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
696 JalviewFileChooser chooser = JalviewFileChooser.forRead(
697 Cache.getProperty("LAST_DIRECTORY"), fileFormat);
698 chooser.setFileView(new JalviewFileView());
699 chooser.setDialogTitle(MessageManager
700 .getString("label.select_startup_file"));
702 int value = chooser.showOpenDialog(this);
704 if (value == JalviewFileChooser.APPROVE_OPTION)
706 FileFormatI format = chooser.getSelectedFormat();
709 Cache.applicationProperties.setProperty("DEFAULT_FILE_FORMAT",
712 startupFileTextfield.setText(chooser.getSelectedFile()
724 public void cancel_actionPerformed(ActionEvent e)
728 wsPrefs.updateWsMenuConfig(true);
729 wsPrefs.refreshWs_actionPerformed(e);
730 frame.setClosed(true);
731 } catch (Exception ex)
743 public void annotations_actionPerformed(ActionEvent e)
745 conservation.setEnabled(annotations.isSelected());
746 quality.setEnabled(annotations.isSelected());
747 identity.setEnabled(annotations.isSelected());
748 showGroupConsensus.setEnabled(annotations.isSelected());
749 showGroupConservation.setEnabled(annotations.isSelected());
750 showConsensHistogram.setEnabled(annotations.isSelected()
751 && (identity.isSelected() || showGroupConsensus.isSelected()));
752 showConsensLogo.setEnabled(annotations.isSelected()
753 && (identity.isSelected() || showGroupConsensus.isSelected()));
757 public void newLink_actionPerformed(ActionEvent e)
760 GSequenceLink link = new GSequenceLink();
761 boolean valid = false;
764 if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
765 MessageManager.getString("label.new_sequence_url_link"),
766 JvOptionPane.OK_CANCEL_OPTION, -1, null) == JvOptionPane.OK_OPTION)
768 if (link.checkValid())
770 nameLinks.addElement(link.getName());
771 urlLinks.addElement(link.getURL());
784 public void editLink_actionPerformed(ActionEvent e)
786 GSequenceLink link = new GSequenceLink();
788 int index = linkNameList.getSelectedIndex();
791 JvOptionPane.showInternalMessageDialog(Desktop.desktop,
792 MessageManager.getString("label.no_link_selected"),
793 MessageManager.getString("label.no_link_selected"),
794 JvOptionPane.WARNING_MESSAGE);
798 link.setName(nameLinks.elementAt(index).toString());
799 link.setURL(urlLinks.elementAt(index).toString());
801 boolean valid = false;
805 if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
806 MessageManager.getString("label.new_sequence_url_link"),
807 JvOptionPane.OK_CANCEL_OPTION, -1, null) == JvOptionPane.OK_OPTION)
809 if (link.checkValid())
811 nameLinks.setElementAt(link.getName(), index);
812 urlLinks.setElementAt(link.getURL(), index);
826 public void deleteLink_actionPerformed(ActionEvent e)
828 int index = linkNameList.getSelectedIndex();
831 JvOptionPane.showInternalMessageDialog(Desktop.desktop,
832 MessageManager.getString("label.no_link_selected"),
833 MessageManager.getString("label.no_link_selected"),
834 JvOptionPane.WARNING_MESSAGE);
837 nameLinks.removeElementAt(index);
838 urlLinks.removeElementAt(index);
842 void updateLinkData()
844 linkNameList.setListData(nameLinks);
845 linkURLList.setListData(urlLinks);
849 public void defaultBrowser_mouseClicked(MouseEvent e)
851 JFileChooser chooser = new JFileChooser(".");
852 chooser.setDialogTitle(MessageManager
853 .getString("label.select_default_browser"));
855 int value = chooser.showOpenDialog(this);
857 if (value == JFileChooser.APPROVE_OPTION)
859 defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath());
868 * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event
872 protected void showunconserved_actionPerformed(ActionEvent e)
874 // TODO Auto-generated method stub
875 super.showunconserved_actionPerformed(e);
878 public static List<String> getGroupURLLinks()
880 return groupURLLinks;
884 public void minColour_actionPerformed(JPanel panel)
886 Color col = JColorChooser.showDialog(this,
887 MessageManager.getString("label.select_colour_minimum_value"),
888 minColour.getBackground());
891 panel.setBackground(col);
897 public void maxColour_actionPerformed(JPanel panel)
899 Color col = JColorChooser.showDialog(this,
900 MessageManager.getString("label.select_colour_maximum_value"),
901 maxColour.getBackground());
904 panel.setBackground(col);
910 protected void userIdWidth_actionPerformed()
914 String val = userIdWidth.getText().trim();
915 if (val.length() > 0)
917 Integer iw = Integer.parseInt(val);
918 if (iw.intValue() < 12)
920 throw new NumberFormatException();
922 userIdWidth.setText(iw.toString());
924 } catch (NumberFormatException x)
926 JvOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
927 .getString("warn.user_defined_width_requirements"),
928 MessageManager.getString("label.invalid_id_column_width"),
929 JvOptionPane.WARNING_MESSAGE);
930 userIdWidth.setText("");
935 protected void autoIdWidth_actionPerformed()
937 userIdWidth.setEnabled(!autoIdWidth.isSelected());
938 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
942 * Returns true if chimera path is to a valid executable, else show an error
945 private boolean validateChimeraPath()
947 if (chimeraPath.getText().trim().length() > 0)
949 File f = new File(chimeraPath.getText());
952 JvOptionPane.showInternalMessageDialog(Desktop.desktop,
953 MessageManager.getString("label.invalid_chimera_path"),
954 MessageManager.getString("label.invalid_name"),
955 JvOptionPane.ERROR_MESSAGE);
963 * If Chimera is selected, check it can be found on default or user-specified
964 * path, if not show a warning/help dialog.
967 protected void structureViewer_actionPerformed(String selectedItem)
969 if (!selectedItem.equals(ViewerType.CHIMERA.name()))
973 boolean found = false;
976 * Try user-specified and standard paths for Chimera executable.
978 List<String> paths = StructureManager.getChimeraPaths();
979 paths.add(0, chimeraPath.getText());
980 for (String path : paths)
982 if (new File(path.trim()).canExecute())
990 String[] options = { "OK", "Help" };
991 int showHelp = JvOptionPane.showInternalOptionDialog(
993 JvSwingUtils.wrapTooltip(true,
994 MessageManager.getString("label.chimera_missing")),
995 "", JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE,
996 null, options, options[0]);
997 if (showHelp == JvOptionPane.NO_OPTION)
1001 Help.showHelpWindow(HelpId.StructureViewer);
1002 } catch (HelpSetException e)
1004 e.printStackTrace();
1010 public class OptionsParam
1012 private String name;
1014 private String code;
1016 public OptionsParam(String name, String code)
1022 public String getName()
1027 public void setName(String name)
1032 public String getCode()
1037 public void setCode(String code)
1043 public String toString()
1049 public boolean equals(Object that)
1051 if (!(that instanceof OptionsParam))
1055 return this.code.equalsIgnoreCase(((OptionsParam) that).code);
1059 public int hashCode()
1061 return name.hashCode() + code.hashCode();