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.EMBLEBI_STRING;
24 import static jalview.util.UrlConstants.SEQUENCE_ID;
25 import static jalview.util.UrlConstants.SRS_STRING;
27 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
28 import jalview.bin.Cache;
29 import jalview.gui.Help.HelpId;
30 import jalview.gui.StructureViewer.ViewerType;
31 import jalview.io.JalviewFileChooser;
32 import jalview.io.JalviewFileView;
33 import jalview.jbgui.GPreferences;
34 import jalview.jbgui.GSequenceLink;
35 import jalview.schemes.ColourSchemeProperty;
36 import jalview.util.MessageManager;
37 import jalview.util.Platform;
38 import jalview.ws.sifts.SiftsSettings;
40 import java.awt.BorderLayout;
41 import java.awt.Color;
42 import java.awt.Dimension;
44 import java.awt.event.ActionEvent;
45 import java.awt.event.ActionListener;
46 import java.awt.event.MouseEvent;
48 import java.util.ArrayList;
49 import java.util.List;
50 import java.util.StringTokenizer;
51 import java.util.Vector;
53 import javax.help.HelpSetException;
54 import javax.swing.JColorChooser;
55 import javax.swing.JFileChooser;
56 import javax.swing.JInternalFrame;
57 import javax.swing.JOptionPane;
58 import javax.swing.JPanel;
60 import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
68 public class Preferences extends GPreferences
70 public static final String ENABLE_SPLIT_FRAME = "ENABLE_SPLIT_FRAME";
72 public static final String SCALE_PROTEIN_TO_CDNA = "SCALE_PROTEIN_TO_CDNA";
74 public static final String DEFAULT_COLOUR = "DEFAULT_COLOUR";
76 public static final String DEFAULT_COLOUR_PROT = "DEFAULT_COLOUR_PROT";
78 public static final String DEFAULT_COLOUR_NUC = "DEFAULT_COLOUR_NUC";
80 public static final String ADD_TEMPFACT_ANN = "ADD_TEMPFACT_ANN";
82 public static final String ADD_SS_ANN = "ADD_SS_ANN";
84 public static final String USE_RNAVIEW = "USE_RNAVIEW";
86 public static final String STRUCT_FROM_PDB = "STRUCT_FROM_PDB";
88 public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY";
90 public static final String CHIMERA_PATH = "CHIMERA_PATH";
92 public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS";
94 public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE";
96 private static final int MIN_FONT_SIZE = 1;
98 private static final int MAX_FONT_SIZE = 30;
101 * Holds name and link separated with | character. Sequence ID must be
102 * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$
104 public static Vector<String> sequenceURLLinks;
107 * Holds name and link separated with | character. Sequence IDS and Sequences
108 * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and
109 * $SEQUENCES$ or $SEQUENCES=/.possible | chars ./=$ and separation character
110 * for first and second token specified after a pipe character at end |,|.
111 * (TODO: proper escape for using | to separate ids or sequences
114 public static List<String> groupURLLinks;
117 String string = Cache.getDefault("SEQUENCE_LINKS", EMBLEBI_STRING);
118 sequenceURLLinks = new Vector<String>();
122 StringTokenizer st = new StringTokenizer(string, "|");
123 while (st.hasMoreElements())
125 String name = st.nextToken();
126 String url = st.nextToken();
127 // check for '|' within a regex
128 int rxstart = url.indexOf("$" + SEQUENCE_ID + "$");
129 while (rxstart == -1 && url.indexOf("/=$") == -1)
131 url = url + "|" + st.nextToken();
133 sequenceURLLinks.addElement(name + "|" + url);
135 } catch (Exception ex)
137 System.out.println(ex + "\nError parsing sequence links");
140 // upgrade old SRS link
141 int srsPos = sequenceURLLinks.indexOf(SRS_STRING);
144 sequenceURLLinks.setElementAt(EMBLEBI_STRING, srsPos);
149 * TODO: reformulate groupURL encoding so two or more can be stored in the
150 * .properties file as '|' separated strings
153 groupURLLinks = new ArrayList<String>();
156 Vector<String> nameLinks, urlLinks;
158 JInternalFrame frame;
160 DasSourceBrowser dasSource;
162 private WsPreferences wsPrefs;
164 private OptionsParam promptEachTimeOpt = new OptionsParam(
165 MessageManager.getString("label.prompt_each_time"),
168 private OptionsParam lineArtOpt = new OptionsParam(
169 MessageManager.getString("label.lineart"), "Lineart");
171 private OptionsParam textOpt = new OptionsParam(
172 MessageManager.getString("action.text"), "Text");
175 * Creates a new Preferences object.
180 frame = new JInternalFrame();
181 frame.setContentPane(this);
182 dasSource = new DasSourceBrowser();
183 dasTab.add(dasSource, BorderLayout.CENTER);
184 wsPrefs = new WsPreferences();
185 wsTab.add(wsPrefs, BorderLayout.CENTER);
186 int width = 500, height = 450;
187 new jalview.util.Platform();
188 if (Platform.isAMac())
194 Desktop.addInternalFrame(frame,
195 MessageManager.getString("label.preferences"), width, height);
196 frame.setMinimumSize(new Dimension(width, height));
199 * Set Visual tab defaults
201 seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true));
202 rightAlign.setSelected(Cache.getDefault("RIGHT_ALIGN_IDS", false));
203 fullScreen.setSelected(Cache.getDefault("SHOW_FULLSCREEN", false));
204 annotations.setSelected(Cache.getDefault("SHOW_ANNOTATIONS", true));
206 conservation.setSelected(Cache.getDefault("SHOW_CONSERVATION", true));
207 quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));
208 identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
209 openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false));
211 .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
212 showGroupConsensus.setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS",
214 showGroupConservation.setSelected(Cache.getDefault(
215 "SHOW_GROUP_CONSERVATION", false));
216 showConsensHistogram.setSelected(Cache.getDefault(
217 "SHOW_CONSENSUS_HISTOGRAM", true));
218 showConsensLogo.setSelected(Cache.getDefault("SHOW_CONSENSUS_LOGO",
220 showNpTooltip.setSelected(Cache
221 .getDefault("SHOW_NPFEATS_TOOLTIP", true));
222 showDbRefTooltip.setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP",
225 String[] fonts = java.awt.GraphicsEnvironment
226 .getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
227 for (int i = 0; i < fonts.length; i++)
229 fontNameCB.addItem(fonts[i]);
232 for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++)
234 fontSizeCB.addItem(i + "");
237 fontStyleCB.addItem("plain");
238 fontStyleCB.addItem("bold");
239 fontStyleCB.addItem("italic");
241 fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif"));
242 fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10"));
243 fontStyleCB.setSelectedItem(Cache.getDefault("FONT_STYLE", Font.PLAIN
246 smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", false));
247 scaleProteinToCdna.setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA,
250 idItalics.setSelected(Cache.getDefault("ID_ITALICS", true));
252 wrap.setSelected(Cache.getDefault("WRAP_ALIGNMENT", false));
254 gapSymbolCB.addItem("-");
255 gapSymbolCB.addItem(".");
257 gapSymbolCB.setSelectedItem(Cache.getDefault("GAP_SYMBOL", "-"));
259 sortby.addItem("No sort");
260 sortby.addItem("Id");
261 sortby.addItem("Pairwise Identity");
262 sortby.setSelectedItem(Cache.getDefault("SORT_ALIGNMENT", "No sort"));
264 sortAnnBy.addItem(SequenceAnnotationOrder.NONE.toString());
266 .addItem(SequenceAnnotationOrder.SEQUENCE_AND_LABEL.toString());
268 .addItem(SequenceAnnotationOrder.LABEL_AND_SEQUENCE.toString());
269 SequenceAnnotationOrder savedSort = SequenceAnnotationOrder
270 .valueOf(Cache.getDefault(SORT_ANNOTATIONS,
271 SequenceAnnotationOrder.NONE.name()));
272 sortAnnBy.setSelectedItem(savedSort.toString());
274 sortAutocalc.addItem("Autocalculated first");
275 sortAutocalc.addItem("Autocalculated last");
276 final boolean showAbove = Cache.getDefault(SHOW_AUTOCALC_ABOVE, true);
277 sortAutocalc.setSelectedItem(showAbove ? sortAutocalc.getItemAt(0)
278 : sortAutocalc.getItemAt(1));
280 .setSelected(Cache.getDefault("SHOW_STARTUP_FILE", true));
281 startupFileTextfield.setText(Cache.getDefault("STARTUP_FILE",
282 Cache.getDefault("www.jalview.org", "http://www.jalview.org")
283 + "/examples/exampleFile_2_3.jar"));
286 * Set Colours tab defaults
288 for (int i = ColourSchemeProperty.FIRST_COLOUR; i <= ColourSchemeProperty.LAST_COLOUR; i++)
290 protColour.addItem(ColourSchemeProperty.getColourName(i));
291 nucColour.addItem(ColourSchemeProperty.getColourName(i));
293 String oldProp = Cache.getDefault(DEFAULT_COLOUR, "None");
294 String newProp = Cache.getDefault(DEFAULT_COLOUR_PROT, null);
295 protColour.setSelectedItem(newProp != null ? newProp : oldProp);
296 newProp = Cache.getDefault(DEFAULT_COLOUR_NUC, null);
297 nucColour.setSelectedItem(newProp != null ? newProp : oldProp);
298 minColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN",
300 maxColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX",
304 * Set Structure tab defaults.
306 final boolean structSelected = Cache.getDefault(STRUCT_FROM_PDB, false);
307 structFromPdb.setSelected(structSelected);
308 useRnaView.setSelected(Cache.getDefault(USE_RNAVIEW, false));
309 useRnaView.setEnabled(structSelected);
310 addSecondaryStructure.setSelected(Cache.getDefault(ADD_SS_ANN, false));
311 addSecondaryStructure.setEnabled(structSelected);
312 addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, false));
313 addTempFactor.setEnabled(structSelected);
314 structViewer.setSelectedItem(Cache.getDefault(STRUCTURE_DISPLAY,
315 ViewerType.JMOL.name()));
316 chimeraPath.setText(Cache.getDefault(CHIMERA_PATH, ""));
317 chimeraPath.addActionListener(new ActionListener()
320 public void actionPerformed(ActionEvent e)
322 validateChimeraPath();
326 if (Cache.getDefault("MAP_WITH_SIFTS", false))
328 siftsMapping.setSelected(true);
332 nwMapping.setSelected(true);
336 .setMapWithSifts(Cache.getDefault("MAP_WITH_SIFTS", false));
339 * Set Connections tab defaults
341 nameLinks = new Vector<String>();
342 urlLinks = new Vector<String>();
343 for (int i = 0; i < sequenceURLLinks.size(); i++)
345 String link = sequenceURLLinks.elementAt(i).toString();
346 nameLinks.addElement(link.substring(0, link.indexOf("|")));
347 urlLinks.addElement(link.substring(link.indexOf("|") + 1));
352 useProxy.setSelected(Cache.getDefault("USE_PROXY", false));
353 proxyServerTB.setEnabled(useProxy.isSelected());
354 proxyPortTB.setEnabled(useProxy.isSelected());
355 proxyServerTB.setText(Cache.getDefault("PROXY_SERVER", ""));
356 proxyPortTB.setText(Cache.getDefault("PROXY_PORT", ""));
358 defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
360 usagestats.setSelected(Cache.getDefault("USAGESTATS", false));
361 // note antisense here: default is true
363 .setSelected(Cache.getProperty("NOQUESTIONNAIRES") == null);
364 versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true));
367 * Set Output tab defaults
369 epsRendering.addItem(promptEachTimeOpt);
370 epsRendering.addItem(lineArtOpt);
371 epsRendering.addItem(textOpt);
372 String defaultEPS = Cache.getDefault("EPS_RENDERING",
374 if (defaultEPS.equalsIgnoreCase("Text"))
376 epsRendering.setSelectedItem(textOpt);
378 else if (defaultEPS.equalsIgnoreCase("Lineart"))
380 epsRendering.setSelectedItem(lineArtOpt);
384 epsRendering.setSelectedItem(promptEachTimeOpt);
386 autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
387 userIdWidth.setEnabled(!autoIdWidth.isSelected());
388 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
389 Integer wi = Cache.getIntegerProperty("FIGURE_USERIDWIDTH");
390 userIdWidth.setText(wi == null ? "" : wi.toString());
391 blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
392 clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
393 fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
394 msfjv.setSelected(Cache.getDefault("MSF_JVSUFFIX", true));
395 pfamjv.setSelected(Cache.getDefault("PFAM_JVSUFFIX", true));
396 pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true));
397 pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true));
398 modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false));
399 embbedBioJSON.setSelected(Cache.getDefault("EXPORT_EMBBED_BIOJSON",
403 * Set Editing tab defaults
405 autoCalculateConsCheck.setSelected(Cache.getDefault(
406 "AUTO_CALC_CONSENSUS", true));
407 padGaps.setSelected(Cache.getDefault("PAD_GAPS", false));
408 sortByTree.setSelected(Cache.getDefault("SORT_BY_TREE", false));
410 annotations_actionPerformed(null); // update the display of the annotation
415 * Save user selections on the Preferences tabs to the Cache and write out to
421 public void ok_actionPerformed(ActionEvent e)
423 if (!validateSettings())
429 * Save Visual settings
431 Cache.applicationProperties.setProperty("SHOW_JVSUFFIX",
432 Boolean.toString(seqLimit.isSelected()));
433 Cache.applicationProperties.setProperty("RIGHT_ALIGN_IDS",
434 Boolean.toString(rightAlign.isSelected()));
435 Cache.applicationProperties.setProperty("SHOW_FULLSCREEN",
436 Boolean.toString(fullScreen.isSelected()));
437 Cache.applicationProperties.setProperty("SHOW_OVERVIEW",
438 Boolean.toString(openoverv.isSelected()));
439 Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
440 Boolean.toString(annotations.isSelected()));
441 Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
442 Boolean.toString(conservation.isSelected()));
443 Cache.applicationProperties.setProperty("SHOW_QUALITY",
444 Boolean.toString(quality.isSelected()));
445 Cache.applicationProperties.setProperty("SHOW_IDENTITY",
446 Boolean.toString(identity.isSelected()));
448 Cache.applicationProperties.setProperty("GAP_SYMBOL", gapSymbolCB
449 .getSelectedItem().toString());
451 Cache.applicationProperties.setProperty("FONT_NAME", fontNameCB
452 .getSelectedItem().toString());
453 Cache.applicationProperties.setProperty("FONT_STYLE", fontStyleCB
454 .getSelectedItem().toString());
455 Cache.applicationProperties.setProperty("FONT_SIZE", fontSizeCB
456 .getSelectedItem().toString());
458 Cache.applicationProperties.setProperty("ID_ITALICS",
459 Boolean.toString(idItalics.isSelected()));
460 Cache.applicationProperties.setProperty("SHOW_UNCONSERVED",
461 Boolean.toString(showUnconserved.isSelected()));
462 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSENSUS",
463 Boolean.toString(showGroupConsensus.isSelected()));
464 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSERVATION",
465 Boolean.toString(showGroupConservation.isSelected()));
466 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_HISTOGRAM",
467 Boolean.toString(showConsensHistogram.isSelected()));
468 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_LOGO",
469 Boolean.toString(showConsensLogo.isSelected()));
470 Cache.applicationProperties.setProperty("ANTI_ALIAS",
471 Boolean.toString(smoothFont.isSelected()));
472 Cache.applicationProperties.setProperty(SCALE_PROTEIN_TO_CDNA,
473 Boolean.toString(scaleProteinToCdna.isSelected()));
474 Cache.applicationProperties.setProperty("SHOW_NPFEATS_TOOLTIP",
475 Boolean.toString(showNpTooltip.isSelected()));
476 Cache.applicationProperties.setProperty("SHOW_DBREFS_TOOLTIP",
477 Boolean.toString(showDbRefTooltip.isSelected()));
479 Cache.applicationProperties.setProperty("WRAP_ALIGNMENT",
480 Boolean.toString(wrap.isSelected()));
482 Cache.applicationProperties.setProperty("STARTUP_FILE",
483 startupFileTextfield.getText());
484 Cache.applicationProperties.setProperty("SHOW_STARTUP_FILE",
485 Boolean.toString(startupCheckbox.isSelected()));
487 Cache.applicationProperties.setProperty("SORT_ALIGNMENT", sortby
488 .getSelectedItem().toString());
490 // convert description of sort order to enum name for save
491 SequenceAnnotationOrder annSortOrder = SequenceAnnotationOrder
492 .forDescription(sortAnnBy.getSelectedItem().toString());
493 if (annSortOrder != null)
495 Cache.applicationProperties.setProperty(SORT_ANNOTATIONS,
496 annSortOrder.name());
499 final boolean showAutocalcFirst = sortAutocalc.getSelectedIndex() == 0;
500 Cache.applicationProperties.setProperty(SHOW_AUTOCALC_ABOVE, Boolean
501 .valueOf(showAutocalcFirst).toString());
504 * Save Colours settings
506 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_PROT, protColour
507 .getSelectedItem().toString());
508 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_NUC, nucColour
509 .getSelectedItem().toString());
510 Cache.setColourProperty("ANNOTATIONCOLOUR_MIN",
511 minColour.getBackground());
512 Cache.setColourProperty("ANNOTATIONCOLOUR_MAX",
513 maxColour.getBackground());
516 * Save Structure settings
518 Cache.applicationProperties.setProperty(ADD_TEMPFACT_ANN,
519 Boolean.toString(addTempFactor.isSelected()));
520 Cache.applicationProperties.setProperty(ADD_SS_ANN,
521 Boolean.toString(addSecondaryStructure.isSelected()));
522 Cache.applicationProperties.setProperty(USE_RNAVIEW,
523 Boolean.toString(useRnaView.isSelected()));
524 Cache.applicationProperties.setProperty(STRUCT_FROM_PDB,
525 Boolean.toString(structFromPdb.isSelected()));
526 Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY, structViewer
527 .getSelectedItem().toString());
528 Cache.setOrRemove(CHIMERA_PATH, chimeraPath.getText());
529 Cache.applicationProperties.setProperty("MAP_WITH_SIFTS",
530 Boolean.toString(siftsMapping.isSelected()));
531 SiftsSettings.setMapWithSifts(siftsMapping.isSelected());
534 * Save Output settings
536 Cache.applicationProperties.setProperty("EPS_RENDERING",
537 ((OptionsParam) epsRendering.getSelectedItem()).getCode());
540 * Save Connections settings
542 Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
544 jalview.util.BrowserLauncher.resetBrowser();
546 if (nameLinks.size() > 0)
548 StringBuffer links = new StringBuffer();
549 sequenceURLLinks = new Vector<String>();
550 for (int i = 0; i < nameLinks.size(); i++)
552 sequenceURLLinks.addElement(nameLinks.elementAt(i) + "|"
553 + urlLinks.elementAt(i));
554 links.append(sequenceURLLinks.elementAt(i).toString());
558 links.setLength(links.length() - 1);
559 Cache.applicationProperties.setProperty("SEQUENCE_LINKS",
564 Cache.applicationProperties.remove("SEQUENCE_LINKS");
567 Cache.applicationProperties.setProperty("USE_PROXY",
568 Boolean.toString(useProxy.isSelected()));
570 Cache.setOrRemove("PROXY_SERVER", proxyServerTB.getText());
572 Cache.setOrRemove("PROXY_PORT", proxyPortTB.getText());
574 if (useProxy.isSelected())
576 System.setProperty("http.proxyHost", proxyServerTB.getText());
577 System.setProperty("http.proxyPort", proxyPortTB.getText());
581 System.setProperty("http.proxyHost", "");
582 System.setProperty("http.proxyPort", "");
584 Cache.setProperty("VERSION_CHECK",
585 Boolean.toString(versioncheck.isSelected()));
586 if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
588 // default is false - we only set this if the user has actively agreed
589 Cache.setProperty("USAGESTATS",
590 Boolean.toString(usagestats.isSelected()));
592 if (!questionnaire.isSelected())
594 Cache.setProperty("NOQUESTIONNAIRES", "true");
598 // special - made easy to edit a property file to disable questionnaires
599 // by just adding the given line
600 Cache.removeProperty("NOQUESTIONNAIRES");
604 * Save Output settings
606 Cache.applicationProperties.setProperty("BLC_JVSUFFIX",
607 Boolean.toString(blcjv.isSelected()));
608 Cache.applicationProperties.setProperty("CLUSTAL_JVSUFFIX",
609 Boolean.toString(clustaljv.isSelected()));
610 Cache.applicationProperties.setProperty("FASTA_JVSUFFIX",
611 Boolean.toString(fastajv.isSelected()));
612 Cache.applicationProperties.setProperty("MSF_JVSUFFIX",
613 Boolean.toString(msfjv.isSelected()));
614 Cache.applicationProperties.setProperty("PFAM_JVSUFFIX",
615 Boolean.toString(pfamjv.isSelected()));
616 Cache.applicationProperties.setProperty("PILEUP_JVSUFFIX",
617 Boolean.toString(pileupjv.isSelected()));
618 Cache.applicationProperties.setProperty("PIR_JVSUFFIX",
619 Boolean.toString(pirjv.isSelected()));
620 Cache.applicationProperties.setProperty("PIR_MODELLER",
621 Boolean.toString(modellerOutput.isSelected()));
622 Cache.applicationProperties.setProperty("EXPORT_EMBBED_BIOJSON",
623 Boolean.toString(embbedBioJSON.isSelected()));
624 jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
626 Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH",
627 Boolean.toString(autoIdWidth.isSelected()));
628 userIdWidth_actionPerformed();
629 Cache.applicationProperties.setProperty("FIGURE_USERIDWIDTH",
630 userIdWidth.getText());
633 * Save Editing settings
635 Cache.applicationProperties.setProperty("AUTO_CALC_CONSENSUS",
636 Boolean.toString(autoCalculateConsCheck.isSelected()));
637 Cache.applicationProperties.setProperty("SORT_BY_TREE",
638 Boolean.toString(sortByTree.isSelected()));
639 Cache.applicationProperties.setProperty("PAD_GAPS",
640 Boolean.toString(padGaps.isSelected()));
642 dasSource.saveProperties(Cache.applicationProperties);
643 wsPrefs.updateAndRefreshWsMenuConfig(false);
644 Cache.saveProperties();
645 Desktop.instance.doConfigureStructurePrefs();
648 frame.setClosed(true);
649 } catch (Exception ex)
655 * Do any necessary validation before saving settings. Return focus to the
656 * first tab which fails validation.
660 private boolean validateSettings()
662 if (!validateStructure())
664 structureTab.requestFocusInWindow();
671 protected boolean validateStructure()
673 return validateChimeraPath();
681 public void startupFileTextfield_mouseClicked()
683 JalviewFileChooser chooser = new JalviewFileChooser(
684 jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] {
685 "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc",
686 "jar" }, new String[] { "Fasta", "Clustal", "PFAM", "MSF",
687 "PIR", "BLC", "Jalview" },
688 jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT"));
689 chooser.setFileView(new JalviewFileView());
690 chooser.setDialogTitle(MessageManager
691 .getString("label.select_startup_file"));
693 int value = chooser.showOpenDialog(this);
695 if (value == JalviewFileChooser.APPROVE_OPTION)
697 jalview.bin.Cache.applicationProperties.setProperty(
698 "DEFAULT_FILE_FORMAT", chooser.getSelectedFormat());
699 startupFileTextfield.setText(chooser.getSelectedFile()
711 public void cancel_actionPerformed(ActionEvent e)
715 wsPrefs.updateWsMenuConfig(true);
716 wsPrefs.refreshWs_actionPerformed(e);
717 frame.setClosed(true);
718 } catch (Exception ex)
730 public void annotations_actionPerformed(ActionEvent e)
732 conservation.setEnabled(annotations.isSelected());
733 quality.setEnabled(annotations.isSelected());
734 identity.setEnabled(annotations.isSelected());
735 showGroupConsensus.setEnabled(annotations.isSelected());
736 showGroupConservation.setEnabled(annotations.isSelected());
737 showConsensHistogram.setEnabled(annotations.isSelected()
738 && (identity.isSelected() || showGroupConsensus.isSelected()));
739 showConsensLogo.setEnabled(annotations.isSelected()
740 && (identity.isSelected() || showGroupConsensus.isSelected()));
744 public void newLink_actionPerformed(ActionEvent e)
747 GSequenceLink link = new GSequenceLink();
748 boolean valid = false;
751 if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
752 MessageManager.getString("label.new_sequence_url_link"),
753 JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
755 if (link.checkValid())
757 nameLinks.addElement(link.getName());
758 urlLinks.addElement(link.getURL());
771 public void editLink_actionPerformed(ActionEvent e)
773 GSequenceLink link = new GSequenceLink();
775 int index = linkNameList.getSelectedIndex();
778 JOptionPane.showInternalMessageDialog(Desktop.desktop,
779 MessageManager.getString("label.no_link_selected"),
780 MessageManager.getString("label.no_link_selected"),
781 JOptionPane.WARNING_MESSAGE);
785 link.setName(nameLinks.elementAt(index).toString());
786 link.setURL(urlLinks.elementAt(index).toString());
788 boolean valid = false;
792 if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
793 MessageManager.getString("label.new_sequence_url_link"),
794 JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
796 if (link.checkValid())
798 nameLinks.setElementAt(link.getName(), index);
799 urlLinks.setElementAt(link.getURL(), index);
813 public void deleteLink_actionPerformed(ActionEvent e)
815 int index = linkNameList.getSelectedIndex();
818 JOptionPane.showInternalMessageDialog(Desktop.desktop,
819 MessageManager.getString("label.no_link_selected"),
820 MessageManager.getString("label.no_link_selected"),
821 JOptionPane.WARNING_MESSAGE);
824 nameLinks.removeElementAt(index);
825 urlLinks.removeElementAt(index);
829 void updateLinkData()
831 linkNameList.setListData(nameLinks);
832 linkURLList.setListData(urlLinks);
836 public void defaultBrowser_mouseClicked(MouseEvent e)
838 JFileChooser chooser = new JFileChooser(".");
839 chooser.setDialogTitle(MessageManager
840 .getString("label.select_default_browser"));
842 int value = chooser.showOpenDialog(this);
844 if (value == JFileChooser.APPROVE_OPTION)
846 defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath());
855 * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event
859 protected void showunconserved_actionPerformed(ActionEvent e)
861 // TODO Auto-generated method stub
862 super.showunconserved_actionPerformed(e);
865 public static List<String> getGroupURLLinks()
867 return groupURLLinks;
871 public void minColour_actionPerformed(JPanel panel)
873 Color col = JColorChooser.showDialog(this,
874 MessageManager.getString("label.select_colour_minimum_value"),
875 minColour.getBackground());
878 panel.setBackground(col);
884 public void maxColour_actionPerformed(JPanel panel)
886 Color col = JColorChooser.showDialog(this,
887 MessageManager.getString("label.select_colour_maximum_value"),
888 maxColour.getBackground());
891 panel.setBackground(col);
897 protected void userIdWidth_actionPerformed()
901 String val = userIdWidth.getText().trim();
902 if (val.length() > 0)
904 Integer iw = Integer.parseInt(val);
905 if (iw.intValue() < 12)
907 throw new NumberFormatException();
909 userIdWidth.setText(iw.toString());
911 } catch (NumberFormatException x)
913 JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
914 .getString("warn.user_defined_width_requirements"),
915 MessageManager.getString("label.invalid_id_column_width"),
916 JOptionPane.WARNING_MESSAGE);
917 userIdWidth.setText("");
922 protected void autoIdWidth_actionPerformed()
924 userIdWidth.setEnabled(!autoIdWidth.isSelected());
925 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
929 * Returns true if chimera path is to a valid executable, else show an error
932 private boolean validateChimeraPath()
934 if (chimeraPath.getText().trim().length() > 0)
936 File f = new File(chimeraPath.getText());
939 JOptionPane.showInternalMessageDialog(Desktop.desktop,
940 MessageManager.getString("label.invalid_chimera_path"),
941 MessageManager.getString("label.invalid_name"),
942 JOptionPane.ERROR_MESSAGE);
950 * If Chimera is selected, check it can be found on default or user-specified
951 * path, if not show a warning/help dialog.
954 protected void structureViewer_actionPerformed(String selectedItem)
956 if (!selectedItem.equals(ViewerType.CHIMERA.name()))
960 boolean found = false;
963 * Try user-specified and standard paths for Chimera executable.
965 List<String> paths = StructureManager.getChimeraPaths();
966 paths.add(0, chimeraPath.getText());
967 for (String path : paths)
969 if (new File(path.trim()).canExecute())
977 String[] options = { "OK", "Help" };
978 int showHelp = JOptionPane.showInternalOptionDialog(
980 JvSwingUtils.wrapTooltip(true,
981 MessageManager.getString("label.chimera_missing")),
982 "", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE,
983 null, options, options[0]);
984 if (showHelp == JOptionPane.NO_OPTION)
988 Help.showHelpWindow(HelpId.StructureViewer);
989 } catch (HelpSetException e)
997 public class OptionsParam
1001 private String code;
1003 public OptionsParam(String name, String code)
1009 public String getName()
1014 public void setName(String name)
1019 public String getCode()
1024 public void setCode(String code)
1030 public String toString()
1036 public boolean equals(Object that)
1038 if (!(that instanceof OptionsParam))
1042 return this.code.equalsIgnoreCase(((OptionsParam) that).code);
1046 public int hashCode()
1048 return name.hashCode() + code.hashCode();