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.urls.UrlProvider;
33 import jalview.urls.UrlProviderI;
34 import jalview.util.MessageManager;
35 import jalview.util.Platform;
36 import jalview.ws.sifts.SiftsSettings;
38 import java.awt.BorderLayout;
39 import java.awt.Color;
40 import java.awt.Dimension;
42 import java.awt.event.ActionEvent;
43 import java.awt.event.ActionListener;
44 import java.awt.event.MouseEvent;
46 import java.util.ArrayList;
47 import java.util.List;
48 import java.util.Vector;
50 import javax.help.HelpSetException;
51 import javax.swing.JColorChooser;
52 import javax.swing.JFileChooser;
53 import javax.swing.JInternalFrame;
54 import javax.swing.JOptionPane;
55 import javax.swing.JPanel;
57 import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
65 public class Preferences extends GPreferences
67 public static final String ENABLE_SPLIT_FRAME = "ENABLE_SPLIT_FRAME";
69 public static final String SCALE_PROTEIN_TO_CDNA = "SCALE_PROTEIN_TO_CDNA";
71 public static final String DEFAULT_COLOUR = "DEFAULT_COLOUR";
73 public static final String DEFAULT_COLOUR_PROT = "DEFAULT_COLOUR_PROT";
75 public static final String DEFAULT_COLOUR_NUC = "DEFAULT_COLOUR_NUC";
77 public static final String ADD_TEMPFACT_ANN = "ADD_TEMPFACT_ANN";
79 public static final String ADD_SS_ANN = "ADD_SS_ANN";
81 public static final String USE_RNAVIEW = "USE_RNAVIEW";
83 public static final String STRUCT_FROM_PDB = "STRUCT_FROM_PDB";
85 public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY";
87 public static final String CHIMERA_PATH = "CHIMERA_PATH";
89 public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS";
91 public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE";
93 private static final int MIN_FONT_SIZE = 1;
95 private static final int MAX_FONT_SIZE = 30;
98 * Holds name and link separated with | character. Sequence ID must be
99 * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$
101 public static UrlProviderI sequenceUrlLinks;
104 * Holds name and link separated with | character. Sequence IDS and Sequences
105 * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and
106 * $SEQUENCES$ or $SEQUENCES=/.possible | chars ./=$ and separation character
107 * for first and second token specified after a pipe character at end |,|.
108 * (TODO: proper escape for using | to separate ids or sequences
111 public static List<String> groupURLLinks;
114 String string = Cache.getDefault("SEQUENCE_LINKS",
115 UrlProviderI.DEFAULT_STRING);
116 sequenceUrlLinks = new UrlProvider(UrlProviderI.DEFAULT_LABEL, string);
119 * TODO: reformulate groupURL encoding so two or more can be stored in the
120 * .properties file as '|' separated strings
123 groupURLLinks = new ArrayList<String>();
126 Vector<String> nameLinks, urlLinks;
128 JInternalFrame frame;
130 DasSourceBrowser dasSource;
132 private WsPreferences wsPrefs;
134 private OptionsParam promptEachTimeOpt = new OptionsParam(
135 MessageManager.getString("label.prompt_each_time"),
138 private OptionsParam lineArtOpt = new OptionsParam(
139 MessageManager.getString("label.lineart"), "Lineart");
141 private OptionsParam textOpt = new OptionsParam(
142 MessageManager.getString("action.text"), "Text");
145 * Creates a new Preferences object.
150 frame = new JInternalFrame();
151 frame.setContentPane(this);
152 dasSource = new DasSourceBrowser();
153 dasTab.add(dasSource, BorderLayout.CENTER);
154 wsPrefs = new WsPreferences();
155 wsTab.add(wsPrefs, BorderLayout.CENTER);
156 int width = 500, height = 450;
157 new jalview.util.Platform();
158 if (Platform.isAMac())
164 Desktop.addInternalFrame(frame,
165 MessageManager.getString("label.preferences"), width, height);
166 frame.setMinimumSize(new Dimension(width, height));
169 * Set Visual tab defaults
171 seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true));
172 rightAlign.setSelected(Cache.getDefault("RIGHT_ALIGN_IDS", false));
173 fullScreen.setSelected(Cache.getDefault("SHOW_FULLSCREEN", false));
174 annotations.setSelected(Cache.getDefault("SHOW_ANNOTATIONS", true));
176 conservation.setSelected(Cache.getDefault("SHOW_CONSERVATION", true));
177 quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));
178 identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
179 openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false));
181 .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
182 showGroupConsensus.setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS",
184 showGroupConservation.setSelected(Cache.getDefault(
185 "SHOW_GROUP_CONSERVATION", false));
186 showConsensHistogram.setSelected(Cache.getDefault(
187 "SHOW_CONSENSUS_HISTOGRAM", true));
188 showConsensLogo.setSelected(Cache.getDefault("SHOW_CONSENSUS_LOGO",
190 showNpTooltip.setSelected(Cache
191 .getDefault("SHOW_NPFEATS_TOOLTIP", true));
192 showDbRefTooltip.setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP",
195 String[] fonts = java.awt.GraphicsEnvironment
196 .getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
197 for (int i = 0; i < fonts.length; i++)
199 fontNameCB.addItem(fonts[i]);
202 for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++)
204 fontSizeCB.addItem(i + "");
207 fontStyleCB.addItem("plain");
208 fontStyleCB.addItem("bold");
209 fontStyleCB.addItem("italic");
211 fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif"));
212 fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10"));
213 fontStyleCB.setSelectedItem(Cache.getDefault("FONT_STYLE", Font.PLAIN
216 smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", false));
217 scaleProteinToCdna.setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA,
220 idItalics.setSelected(Cache.getDefault("ID_ITALICS", true));
222 wrap.setSelected(Cache.getDefault("WRAP_ALIGNMENT", false));
224 gapSymbolCB.addItem("-");
225 gapSymbolCB.addItem(".");
227 gapSymbolCB.setSelectedItem(Cache.getDefault("GAP_SYMBOL", "-"));
229 sortby.addItem("No sort");
230 sortby.addItem("Id");
231 sortby.addItem("Pairwise Identity");
232 sortby.setSelectedItem(Cache.getDefault("SORT_ALIGNMENT", "No sort"));
234 sortAnnBy.addItem(SequenceAnnotationOrder.NONE.toString());
236 .addItem(SequenceAnnotationOrder.SEQUENCE_AND_LABEL.toString());
238 .addItem(SequenceAnnotationOrder.LABEL_AND_SEQUENCE.toString());
239 SequenceAnnotationOrder savedSort = SequenceAnnotationOrder
240 .valueOf(Cache.getDefault(SORT_ANNOTATIONS,
241 SequenceAnnotationOrder.NONE.name()));
242 sortAnnBy.setSelectedItem(savedSort.toString());
244 sortAutocalc.addItem("Autocalculated first");
245 sortAutocalc.addItem("Autocalculated last");
246 final boolean showAbove = Cache.getDefault(SHOW_AUTOCALC_ABOVE, true);
247 sortAutocalc.setSelectedItem(showAbove ? sortAutocalc.getItemAt(0)
248 : sortAutocalc.getItemAt(1));
250 .setSelected(Cache.getDefault("SHOW_STARTUP_FILE", true));
251 startupFileTextfield.setText(Cache.getDefault("STARTUP_FILE",
252 Cache.getDefault("www.jalview.org", "http://www.jalview.org")
253 + "/examples/exampleFile_2_3.jar"));
256 * Set Colours tab defaults
258 for (int i = ColourSchemeProperty.FIRST_COLOUR; i <= ColourSchemeProperty.LAST_COLOUR; i++)
260 protColour.addItem(ColourSchemeProperty.getColourName(i));
261 nucColour.addItem(ColourSchemeProperty.getColourName(i));
263 String oldProp = Cache.getDefault(DEFAULT_COLOUR, "None");
264 String newProp = Cache.getDefault(DEFAULT_COLOUR_PROT, null);
265 protColour.setSelectedItem(newProp != null ? newProp : oldProp);
266 newProp = Cache.getDefault(DEFAULT_COLOUR_NUC, null);
267 nucColour.setSelectedItem(newProp != null ? newProp : oldProp);
268 minColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN",
270 maxColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX",
274 * Set Structure tab defaults.
276 final boolean structSelected = Cache.getDefault(STRUCT_FROM_PDB, false);
277 structFromPdb.setSelected(structSelected);
278 useRnaView.setSelected(Cache.getDefault(USE_RNAVIEW, false));
279 useRnaView.setEnabled(structSelected);
280 addSecondaryStructure.setSelected(Cache.getDefault(ADD_SS_ANN, false));
281 addSecondaryStructure.setEnabled(structSelected);
282 addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, false));
283 addTempFactor.setEnabled(structSelected);
284 structViewer.setSelectedItem(Cache.getDefault(STRUCTURE_DISPLAY,
285 ViewerType.JMOL.name()));
286 chimeraPath.setText(Cache.getDefault(CHIMERA_PATH, ""));
287 chimeraPath.addActionListener(new ActionListener()
290 public void actionPerformed(ActionEvent e)
292 validateChimeraPath();
296 if (Cache.getDefault("MAP_WITH_SIFTS", false))
298 siftsMapping.setSelected(true);
302 nwMapping.setSelected(true);
306 .setMapWithSifts(Cache.getDefault("MAP_WITH_SIFTS", false));
309 * Set Connections tab defaults
311 nameLinks = new Vector<String>();
312 urlLinks = new Vector<String>();
317 useProxy.setSelected(Cache.getDefault("USE_PROXY", false));
318 proxyServerTB.setEnabled(useProxy.isSelected());
319 proxyPortTB.setEnabled(useProxy.isSelected());
320 proxyServerTB.setText(Cache.getDefault("PROXY_SERVER", ""));
321 proxyPortTB.setText(Cache.getDefault("PROXY_PORT", ""));
323 defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
325 usagestats.setSelected(Cache.getDefault("USAGESTATS", false));
326 // note antisense here: default is true
328 .setSelected(Cache.getProperty("NOQUESTIONNAIRES") == null);
329 versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true));
332 * Set Output tab defaults
334 epsRendering.addItem(promptEachTimeOpt);
335 epsRendering.addItem(lineArtOpt);
336 epsRendering.addItem(textOpt);
337 String defaultEPS = Cache.getDefault("EPS_RENDERING",
339 if (defaultEPS.equalsIgnoreCase("Text"))
341 epsRendering.setSelectedItem(textOpt);
343 else if (defaultEPS.equalsIgnoreCase("Lineart"))
345 epsRendering.setSelectedItem(lineArtOpt);
349 epsRendering.setSelectedItem(promptEachTimeOpt);
351 autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
352 userIdWidth.setEnabled(!autoIdWidth.isSelected());
353 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
354 Integer wi = Cache.getIntegerProperty("FIGURE_USERIDWIDTH");
355 userIdWidth.setText(wi == null ? "" : wi.toString());
356 blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
357 clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
358 fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
359 msfjv.setSelected(Cache.getDefault("MSF_JVSUFFIX", true));
360 pfamjv.setSelected(Cache.getDefault("PFAM_JVSUFFIX", true));
361 pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true));
362 pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true));
363 modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false));
364 embbedBioJSON.setSelected(Cache.getDefault("EXPORT_EMBBED_BIOJSON",
368 * Set Editing tab defaults
370 autoCalculateConsCheck.setSelected(Cache.getDefault(
371 "AUTO_CALC_CONSENSUS", true));
372 padGaps.setSelected(Cache.getDefault("PAD_GAPS", false));
373 sortByTree.setSelected(Cache.getDefault("SORT_BY_TREE", false));
375 annotations_actionPerformed(null); // update the display of the annotation
380 * Save user selections on the Preferences tabs to the Cache and write out to
386 public void ok_actionPerformed(ActionEvent e)
388 if (!validateSettings())
394 * Save Visual settings
396 Cache.applicationProperties.setProperty("SHOW_JVSUFFIX",
397 Boolean.toString(seqLimit.isSelected()));
398 Cache.applicationProperties.setProperty("RIGHT_ALIGN_IDS",
399 Boolean.toString(rightAlign.isSelected()));
400 Cache.applicationProperties.setProperty("SHOW_FULLSCREEN",
401 Boolean.toString(fullScreen.isSelected()));
402 Cache.applicationProperties.setProperty("SHOW_OVERVIEW",
403 Boolean.toString(openoverv.isSelected()));
404 Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
405 Boolean.toString(annotations.isSelected()));
406 Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
407 Boolean.toString(conservation.isSelected()));
408 Cache.applicationProperties.setProperty("SHOW_QUALITY",
409 Boolean.toString(quality.isSelected()));
410 Cache.applicationProperties.setProperty("SHOW_IDENTITY",
411 Boolean.toString(identity.isSelected()));
413 Cache.applicationProperties.setProperty("GAP_SYMBOL", gapSymbolCB
414 .getSelectedItem().toString());
416 Cache.applicationProperties.setProperty("FONT_NAME", fontNameCB
417 .getSelectedItem().toString());
418 Cache.applicationProperties.setProperty("FONT_STYLE", fontStyleCB
419 .getSelectedItem().toString());
420 Cache.applicationProperties.setProperty("FONT_SIZE", fontSizeCB
421 .getSelectedItem().toString());
423 Cache.applicationProperties.setProperty("ID_ITALICS",
424 Boolean.toString(idItalics.isSelected()));
425 Cache.applicationProperties.setProperty("SHOW_UNCONSERVED",
426 Boolean.toString(showUnconserved.isSelected()));
427 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSENSUS",
428 Boolean.toString(showGroupConsensus.isSelected()));
429 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSERVATION",
430 Boolean.toString(showGroupConservation.isSelected()));
431 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_HISTOGRAM",
432 Boolean.toString(showConsensHistogram.isSelected()));
433 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_LOGO",
434 Boolean.toString(showConsensLogo.isSelected()));
435 Cache.applicationProperties.setProperty("ANTI_ALIAS",
436 Boolean.toString(smoothFont.isSelected()));
437 Cache.applicationProperties.setProperty(SCALE_PROTEIN_TO_CDNA,
438 Boolean.toString(scaleProteinToCdna.isSelected()));
439 Cache.applicationProperties.setProperty("SHOW_NPFEATS_TOOLTIP",
440 Boolean.toString(showNpTooltip.isSelected()));
441 Cache.applicationProperties.setProperty("SHOW_DBREFS_TOOLTIP",
442 Boolean.toString(showDbRefTooltip.isSelected()));
444 Cache.applicationProperties.setProperty("WRAP_ALIGNMENT",
445 Boolean.toString(wrap.isSelected()));
447 Cache.applicationProperties.setProperty("STARTUP_FILE",
448 startupFileTextfield.getText());
449 Cache.applicationProperties.setProperty("SHOW_STARTUP_FILE",
450 Boolean.toString(startupCheckbox.isSelected()));
452 Cache.applicationProperties.setProperty("SORT_ALIGNMENT", sortby
453 .getSelectedItem().toString());
455 // convert description of sort order to enum name for save
456 SequenceAnnotationOrder annSortOrder = SequenceAnnotationOrder
457 .forDescription(sortAnnBy.getSelectedItem().toString());
458 if (annSortOrder != null)
460 Cache.applicationProperties.setProperty(SORT_ANNOTATIONS,
461 annSortOrder.name());
464 final boolean showAutocalcFirst = sortAutocalc.getSelectedIndex() == 0;
465 Cache.applicationProperties.setProperty(SHOW_AUTOCALC_ABOVE, Boolean
466 .valueOf(showAutocalcFirst).toString());
469 * Save Colours settings
471 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_PROT, protColour
472 .getSelectedItem().toString());
473 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_NUC, nucColour
474 .getSelectedItem().toString());
475 Cache.setColourProperty("ANNOTATIONCOLOUR_MIN",
476 minColour.getBackground());
477 Cache.setColourProperty("ANNOTATIONCOLOUR_MAX",
478 maxColour.getBackground());
481 * Save Structure settings
483 Cache.applicationProperties.setProperty(ADD_TEMPFACT_ANN,
484 Boolean.toString(addTempFactor.isSelected()));
485 Cache.applicationProperties.setProperty(ADD_SS_ANN,
486 Boolean.toString(addSecondaryStructure.isSelected()));
487 Cache.applicationProperties.setProperty(USE_RNAVIEW,
488 Boolean.toString(useRnaView.isSelected()));
489 Cache.applicationProperties.setProperty(STRUCT_FROM_PDB,
490 Boolean.toString(structFromPdb.isSelected()));
491 Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY, structViewer
492 .getSelectedItem().toString());
493 Cache.setOrRemove(CHIMERA_PATH, chimeraPath.getText());
494 Cache.applicationProperties.setProperty("MAP_WITH_SIFTS",
495 Boolean.toString(siftsMapping.isSelected()));
496 SiftsSettings.setMapWithSifts(siftsMapping.isSelected());
499 * Save Output settings
501 Cache.applicationProperties.setProperty("EPS_RENDERING",
502 ((OptionsParam) epsRendering.getSelectedItem()).getCode());
505 * Save Connections settings
507 Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
509 jalview.util.BrowserLauncher.resetBrowser();
511 // save user-defined and selected links
512 String links = sequenceUrlLinks.writeUrlsAsString();
515 Cache.applicationProperties.remove("SEQUENCE_LINKS");
519 Cache.applicationProperties.setProperty("SEQUENCE_LINKS",
523 Cache.applicationProperties.setProperty("USE_PROXY",
524 Boolean.toString(useProxy.isSelected()));
526 Cache.setOrRemove("PROXY_SERVER", proxyServerTB.getText());
528 Cache.setOrRemove("PROXY_PORT", proxyPortTB.getText());
530 if (useProxy.isSelected())
532 System.setProperty("http.proxyHost", proxyServerTB.getText());
533 System.setProperty("http.proxyPort", proxyPortTB.getText());
537 System.setProperty("http.proxyHost", "");
538 System.setProperty("http.proxyPort", "");
540 Cache.setProperty("VERSION_CHECK",
541 Boolean.toString(versioncheck.isSelected()));
542 if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
544 // default is false - we only set this if the user has actively agreed
545 Cache.setProperty("USAGESTATS",
546 Boolean.toString(usagestats.isSelected()));
548 if (!questionnaire.isSelected())
550 Cache.setProperty("NOQUESTIONNAIRES", "true");
554 // special - made easy to edit a property file to disable questionnaires
555 // by just adding the given line
556 Cache.removeProperty("NOQUESTIONNAIRES");
560 * Save Output settings
562 Cache.applicationProperties.setProperty("BLC_JVSUFFIX",
563 Boolean.toString(blcjv.isSelected()));
564 Cache.applicationProperties.setProperty("CLUSTAL_JVSUFFIX",
565 Boolean.toString(clustaljv.isSelected()));
566 Cache.applicationProperties.setProperty("FASTA_JVSUFFIX",
567 Boolean.toString(fastajv.isSelected()));
568 Cache.applicationProperties.setProperty("MSF_JVSUFFIX",
569 Boolean.toString(msfjv.isSelected()));
570 Cache.applicationProperties.setProperty("PFAM_JVSUFFIX",
571 Boolean.toString(pfamjv.isSelected()));
572 Cache.applicationProperties.setProperty("PILEUP_JVSUFFIX",
573 Boolean.toString(pileupjv.isSelected()));
574 Cache.applicationProperties.setProperty("PIR_JVSUFFIX",
575 Boolean.toString(pirjv.isSelected()));
576 Cache.applicationProperties.setProperty("PIR_MODELLER",
577 Boolean.toString(modellerOutput.isSelected()));
578 Cache.applicationProperties.setProperty("EXPORT_EMBBED_BIOJSON",
579 Boolean.toString(embbedBioJSON.isSelected()));
580 jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
582 Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH",
583 Boolean.toString(autoIdWidth.isSelected()));
584 userIdWidth_actionPerformed();
585 Cache.applicationProperties.setProperty("FIGURE_USERIDWIDTH",
586 userIdWidth.getText());
589 * Save Editing settings
591 Cache.applicationProperties.setProperty("AUTO_CALC_CONSENSUS",
592 Boolean.toString(autoCalculateConsCheck.isSelected()));
593 Cache.applicationProperties.setProperty("SORT_BY_TREE",
594 Boolean.toString(sortByTree.isSelected()));
595 Cache.applicationProperties.setProperty("PAD_GAPS",
596 Boolean.toString(padGaps.isSelected()));
598 dasSource.saveProperties(Cache.applicationProperties);
599 wsPrefs.updateAndRefreshWsMenuConfig(false);
600 Cache.saveProperties();
601 Desktop.instance.doConfigureStructurePrefs();
604 frame.setClosed(true);
605 } catch (Exception ex)
611 * Do any necessary validation before saving settings. Return focus to the
612 * first tab which fails validation.
616 private boolean validateSettings()
618 if (!validateStructure())
620 structureTab.requestFocusInWindow();
627 protected boolean validateStructure()
629 return validateChimeraPath();
637 public void startupFileTextfield_mouseClicked()
639 JalviewFileChooser chooser = new JalviewFileChooser(
640 jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] {
641 "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc",
642 "jar" }, new String[] { "Fasta", "Clustal", "PFAM", "MSF",
643 "PIR", "BLC", "Jalview" },
644 jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT"));
645 chooser.setFileView(new JalviewFileView());
646 chooser.setDialogTitle(MessageManager
647 .getString("label.select_startup_file"));
649 int value = chooser.showOpenDialog(this);
651 if (value == JalviewFileChooser.APPROVE_OPTION)
653 jalview.bin.Cache.applicationProperties.setProperty(
654 "DEFAULT_FILE_FORMAT", chooser.getSelectedFormat());
655 startupFileTextfield.setText(chooser.getSelectedFile()
667 public void cancel_actionPerformed(ActionEvent e)
671 wsPrefs.updateWsMenuConfig(true);
672 wsPrefs.refreshWs_actionPerformed(e);
673 frame.setClosed(true);
674 } catch (Exception ex)
686 public void annotations_actionPerformed(ActionEvent e)
688 conservation.setEnabled(annotations.isSelected());
689 quality.setEnabled(annotations.isSelected());
690 identity.setEnabled(annotations.isSelected());
691 showGroupConsensus.setEnabled(annotations.isSelected());
692 showGroupConservation.setEnabled(annotations.isSelected());
693 showConsensHistogram.setEnabled(annotations.isSelected()
694 && (identity.isSelected() || showGroupConsensus.isSelected()));
695 showConsensLogo.setEnabled(annotations.isSelected()
696 && (identity.isSelected() || showGroupConsensus.isSelected()));
700 public void newLink_actionPerformed(ActionEvent e)
703 GSequenceLink link = new GSequenceLink();
704 boolean valid = false;
707 if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
708 MessageManager.getString("label.new_sequence_url_link"),
709 JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
711 if (link.checkValid())
713 nameLinks.addElement(link.getName());
714 urlLinks.addElement(link.getURL());
715 if (updateLinkData())
733 public void editLink_actionPerformed(ActionEvent e)
735 GSequenceLink link = new GSequenceLink();
737 int index = linkNameList.getSelectedIndex();
740 JOptionPane.showInternalMessageDialog(Desktop.desktop,
741 MessageManager.getString("label.no_link_selected"),
742 MessageManager.getString("label.no_link_selected"),
743 JOptionPane.WARNING_MESSAGE);
747 link.setName(nameLinks.elementAt(index).toString());
748 link.setURL(urlLinks.elementAt(index).toString());
750 boolean valid = false;
754 if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
755 MessageManager.getString("label.new_sequence_url_link"),
756 JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
758 if (link.checkValid())
760 nameLinks.setElementAt(link.getName(), index);
761 urlLinks.setElementAt(link.getURL(), index);
762 if (updateLinkData())
781 public void deleteLink_actionPerformed(ActionEvent e)
783 int index = linkNameList.getSelectedIndex();
786 JOptionPane.showInternalMessageDialog(Desktop.desktop,
787 MessageManager.getString("label.no_link_selected"),
788 MessageManager.getString("label.no_link_selected"),
789 JOptionPane.WARNING_MESSAGE);
792 nameLinks.removeElementAt(index);
793 urlLinks.removeElementAt(index);
797 private boolean updateLinkData()
801 sequenceUrlLinks.setUrlLinks(nameLinks, urlLinks);
802 linkNameList.setListData(nameLinks);
803 linkURLList.setListData(urlLinks);
804 } catch (IllegalArgumentException e)
807 // put back the old links
810 linkNameList.setListData(nameLinks);
811 linkURLList.setListData(urlLinks);
813 JOptionPane.showInternalMessageDialog(Desktop.desktop,
814 e.getMessage(), MessageManager.getString("label.link_name"),
815 JOptionPane.WARNING_MESSAGE);
822 private void resetStoredLinks()
824 Vector<String> nlinks = sequenceUrlLinks.getLinksForDisplay();
828 for (String entry : nlinks)
830 nameLinks.addElement(entry.split("\\|")[0]);
831 urlLinks.addElement(entry.split("\\|")[1]);
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();