2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
24 import jalview.bin.Cache;
25 import jalview.gui.Help.HelpId;
26 import jalview.gui.StructureViewer.ViewerType;
27 import jalview.io.JalviewFileChooser;
28 import jalview.io.JalviewFileView;
29 import jalview.jbgui.GPreferences;
30 import jalview.jbgui.GSequenceLink;
31 import jalview.schemes.ColourSchemeProperty;
32 import jalview.util.MessageManager;
33 import jalview.ws.sifts.SiftsSettings;
35 import java.awt.BorderLayout;
36 import java.awt.Color;
37 import java.awt.Dimension;
39 import java.awt.event.ActionEvent;
40 import java.awt.event.ActionListener;
41 import java.awt.event.MouseEvent;
43 import java.util.Collection;
44 import java.util.List;
45 import java.util.StringTokenizer;
46 import java.util.Vector;
48 import javax.help.HelpSetException;
49 import javax.swing.JColorChooser;
50 import javax.swing.JFileChooser;
51 import javax.swing.JInternalFrame;
52 import javax.swing.JOptionPane;
53 import javax.swing.JPanel;
55 import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
63 public class Preferences extends GPreferences
65 public static final String ENABLE_SPLIT_FRAME = "ENABLE_SPLIT_FRAME";
67 public static final String SCALE_PROTEIN_TO_CDNA = "SCALE_PROTEIN_TO_CDNA";
69 public static final String DEFAULT_COLOUR = "DEFAULT_COLOUR";
71 public static final String DEFAULT_COLOUR_PROT = "DEFAULT_COLOUR_PROT";
73 public static final String DEFAULT_COLOUR_NUC = "DEFAULT_COLOUR_NUC";
75 public static final String ADD_TEMPFACT_ANN = "ADD_TEMPFACT_ANN";
77 public static final String ADD_SS_ANN = "ADD_SS_ANN";
79 public static final String USE_RNAVIEW = "USE_RNAVIEW";
81 public static final String STRUCT_FROM_PDB = "STRUCT_FROM_PDB";
83 public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY";
85 public static final String CHIMERA_PATH = "CHIMERA_PATH";
87 public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS";
89 public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE";
91 private static final int MIN_FONT_SIZE = 1;
93 private static final int MAX_FONT_SIZE = 30;
96 * Holds name and link separated with | character. Sequence ID must be
97 * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$
99 public static Vector sequenceURLLinks;
102 * Holds name and link separated with | character. Sequence IDS and Sequences
103 * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and
104 * $SEQUENCES$ or $SEQUENCES=/.possible | chars ./=$ and separation character
105 * for first and second token specified after a pipe character at end |,|.
106 * (TODO: proper escape for using | to separate ids or sequences
109 public static Vector groupURLLinks;
112 String string = Cache
115 "EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$");
116 sequenceURLLinks = new Vector();
120 StringTokenizer st = new StringTokenizer(string, "|");
121 while (st.hasMoreElements())
123 String name = st.nextToken();
124 String url = st.nextToken();
125 // check for '|' within a regex
126 int rxstart = url.indexOf("$SEQUENCE_ID$");
127 while (rxstart == -1 && url.indexOf("/=$") == -1)
129 url = url + "|" + st.nextToken();
131 sequenceURLLinks.addElement(name + "|" + url);
133 } catch (Exception ex)
135 System.out.println(ex + "\nError parsing sequence links");
138 // upgrade old SRS link
139 int srsPos = sequenceURLLinks
140 .indexOf("SRS|http://srs.ebi.ac.uk/srsbin/cgi-bin/wgetz?-newId+(([uniprot-all:$SEQUENCE_ID$]))+-view+SwissEntry");
145 "EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$",
151 * TODO: reformulate groupURL encoding so two or more can be stored in the
152 * .properties file as '|' separated strings
155 groupURLLinks = new Vector();
158 Vector nameLinks, urlLinks;
160 JInternalFrame frame;
162 DasSourceBrowser dasSource;
164 private WsPreferences wsPrefs;
167 * Creates a new Preferences object.
172 frame = new JInternalFrame();
173 frame.setContentPane(this);
174 dasSource = new DasSourceBrowser();
175 dasTab.add(dasSource, BorderLayout.CENTER);
176 wsPrefs = new WsPreferences();
177 wsTab.add(wsPrefs, BorderLayout.CENTER);
178 int width = 500, height = 450;
179 if (new jalview.util.Platform().isAMac())
185 Desktop.addInternalFrame(frame,
186 MessageManager.getString("label.preferences"), width, height);
187 frame.setMinimumSize(new Dimension(width, height));
190 * Set Visual tab defaults
192 seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true));
193 rightAlign.setSelected(Cache.getDefault("RIGHT_ALIGN_IDS", false));
194 fullScreen.setSelected(Cache.getDefault("SHOW_FULLSCREEN", false));
195 annotations.setSelected(Cache.getDefault("SHOW_ANNOTATIONS", true));
197 conservation.setSelected(Cache.getDefault("SHOW_CONSERVATION", true));
198 quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));
199 identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
200 openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false));
202 .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
203 showGroupConsensus.setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS",
205 showGroupConservation.setSelected(Cache.getDefault(
206 "SHOW_GROUP_CONSERVATION", false));
207 showConsensHistogram.setSelected(Cache.getDefault(
208 "SHOW_CONSENSUS_HISTOGRAM", true));
209 showConsensLogo.setSelected(Cache.getDefault("SHOW_CONSENSUS_LOGO",
211 showNpTooltip.setSelected(Cache
212 .getDefault("SHOW_NPFEATS_TOOLTIP", true));
213 showDbRefTooltip.setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP",
216 String[] fonts = java.awt.GraphicsEnvironment
217 .getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
218 for (int i = 0; i < fonts.length; i++)
220 fontNameCB.addItem(fonts[i]);
223 for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++)
225 fontSizeCB.addItem(i + "");
228 fontStyleCB.addItem("plain");
229 fontStyleCB.addItem("bold");
230 fontStyleCB.addItem("italic");
232 fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif"));
233 fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10"));
234 fontStyleCB.setSelectedItem(Cache.getDefault("FONT_STYLE", Font.PLAIN
237 smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", false));
238 scaleProteinToCdna.setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA,
241 idItalics.setSelected(Cache.getDefault("ID_ITALICS", true));
243 wrap.setSelected(Cache.getDefault("WRAP_ALIGNMENT", false));
245 gapSymbolCB.addItem("-");
246 gapSymbolCB.addItem(".");
248 gapSymbolCB.setSelectedItem(Cache.getDefault("GAP_SYMBOL", "-"));
250 sortby.addItem("No sort");
251 sortby.addItem("Id");
252 sortby.addItem("Pairwise Identity");
253 sortby.setSelectedItem(Cache.getDefault("SORT_ALIGNMENT", "No sort"));
255 sortAnnBy.addItem(SequenceAnnotationOrder.NONE.toString());
257 .addItem(SequenceAnnotationOrder.SEQUENCE_AND_LABEL.toString());
259 .addItem(SequenceAnnotationOrder.LABEL_AND_SEQUENCE.toString());
260 SequenceAnnotationOrder savedSort = SequenceAnnotationOrder
261 .valueOf(Cache.getDefault(SORT_ANNOTATIONS,
262 SequenceAnnotationOrder.NONE.name()));
263 sortAnnBy.setSelectedItem(savedSort.toString());
265 sortAutocalc.addItem("Autocalculated first");
266 sortAutocalc.addItem("Autocalculated last");
267 final boolean showAbove = Cache.getDefault(SHOW_AUTOCALC_ABOVE, true);
268 sortAutocalc.setSelectedItem(showAbove ? sortAutocalc.getItemAt(0)
269 : sortAutocalc.getItemAt(1));
271 .setSelected(Cache.getDefault("SHOW_STARTUP_FILE", true));
272 startupFileTextfield.setText(Cache.getDefault("STARTUP_FILE",
273 Cache.getDefault("www.jalview.org", "http://www.jalview.org")
274 + "/examples/exampleFile_2_3.jar"));
277 * Set Colours tab defaults
279 for (int i = ColourSchemeProperty.FIRST_COLOUR; i <= ColourSchemeProperty.LAST_COLOUR; i++)
281 protColour.addItem(ColourSchemeProperty.getColourName(i));
282 nucColour.addItem(ColourSchemeProperty.getColourName(i));
284 String oldProp = Cache.getDefault(DEFAULT_COLOUR, "None");
285 String newProp = Cache.getDefault(DEFAULT_COLOUR_PROT, null);
286 protColour.setSelectedItem(newProp != null ? newProp : oldProp);
287 newProp = Cache.getDefault(DEFAULT_COLOUR_NUC, null);
288 nucColour.setSelectedItem(newProp != null ? newProp : oldProp);
289 minColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN",
291 maxColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX",
295 * Set Structure tab defaults.
297 final boolean structSelected = Cache.getDefault(STRUCT_FROM_PDB, false);
298 structFromPdb.setSelected(structSelected);
299 useRnaView.setSelected(Cache.getDefault(USE_RNAVIEW, false));
300 useRnaView.setEnabled(structSelected);
301 addSecondaryStructure.setSelected(Cache.getDefault(ADD_SS_ANN, false));
302 addSecondaryStructure.setEnabled(structSelected);
303 addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, false));
304 addTempFactor.setEnabled(structSelected);
305 structViewer.setSelectedItem(Cache.getDefault(STRUCTURE_DISPLAY,
306 ViewerType.JMOL.name()));
307 chimeraPath.setText(Cache.getDefault(CHIMERA_PATH, ""));
308 chimeraPath.addActionListener(new ActionListener()
311 public void actionPerformed(ActionEvent e)
313 validateChimeraPath();
317 if (Cache.getDefault("MAP_WITH_SIFTS", false))
319 siftsMapping.setSelected(true);
320 SiftsSettings.setMapWithSifts(true);
324 nwMapping.setSelected(true);
325 SiftsSettings.setMapWithSifts(false);
329 * Set Connections tab defaults
331 nameLinks = new Vector();
332 urlLinks = new Vector();
333 for (int i = 0; i < sequenceURLLinks.size(); i++)
335 String link = sequenceURLLinks.elementAt(i).toString();
336 nameLinks.addElement(link.substring(0, link.indexOf("|")));
337 urlLinks.addElement(link.substring(link.indexOf("|") + 1));
342 useProxy.setSelected(Cache.getDefault("USE_PROXY", false));
343 proxyServerTB.setEnabled(useProxy.isSelected());
344 proxyPortTB.setEnabled(useProxy.isSelected());
345 proxyServerTB.setText(Cache.getDefault("PROXY_SERVER", ""));
346 proxyPortTB.setText(Cache.getDefault("PROXY_PORT", ""));
348 defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
350 usagestats.setSelected(Cache.getDefault("USAGESTATS", false));
351 // note antisense here: default is true
353 .setSelected(Cache.getProperty("NOQUESTIONNAIRES") == null);
354 versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true));
357 * Set Output tab defaults
360 .addItem(MessageManager.getString("label.prompt_each_time"));
361 epsRendering.addItem(MessageManager.getString("label.lineart"));
362 epsRendering.addItem(MessageManager.getString("action.text"));
363 epsRendering.setSelectedItem(Cache.getDefault("EPS_RENDERING",
364 "Prompt each time"));
365 autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
366 userIdWidth.setEnabled(!autoIdWidth.isSelected());
367 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
368 Integer wi = Cache.getIntegerProperty("FIGURE_USERIDWIDTH");
369 userIdWidth.setText(wi == null ? "" : wi.toString());
370 blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
371 clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
372 fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
373 msfjv.setSelected(Cache.getDefault("MSF_JVSUFFIX", true));
374 pfamjv.setSelected(Cache.getDefault("PFAM_JVSUFFIX", true));
375 pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true));
376 pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true));
377 modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false));
378 embbedBioJSON.setSelected(Cache.getDefault("EXPORT_EMBBED_BIOJSON",
382 * Set Editing tab defaults
384 autoCalculateConsCheck.setSelected(Cache.getDefault(
385 "AUTO_CALC_CONSENSUS", true));
386 padGaps.setSelected(Cache.getDefault("PAD_GAPS", false));
387 sortByTree.setSelected(Cache.getDefault("SORT_BY_TREE", false));
389 annotations_actionPerformed(null); // update the display of the annotation
394 * Save user selections on the Preferences tabs to the Cache and write out to
400 public void ok_actionPerformed(ActionEvent e)
402 if (!validateSettings())
408 * Save Visual settings
410 Cache.applicationProperties.setProperty("SHOW_JVSUFFIX",
411 Boolean.toString(seqLimit.isSelected()));
412 Cache.applicationProperties.setProperty("RIGHT_ALIGN_IDS",
413 Boolean.toString(rightAlign.isSelected()));
414 Cache.applicationProperties.setProperty("SHOW_FULLSCREEN",
415 Boolean.toString(fullScreen.isSelected()));
416 Cache.applicationProperties.setProperty("SHOW_OVERVIEW",
417 Boolean.toString(openoverv.isSelected()));
418 Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
419 Boolean.toString(annotations.isSelected()));
420 Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
421 Boolean.toString(conservation.isSelected()));
422 Cache.applicationProperties.setProperty("SHOW_QUALITY",
423 Boolean.toString(quality.isSelected()));
424 Cache.applicationProperties.setProperty("SHOW_IDENTITY",
425 Boolean.toString(identity.isSelected()));
427 Cache.applicationProperties.setProperty("GAP_SYMBOL", gapSymbolCB
428 .getSelectedItem().toString());
430 Cache.applicationProperties.setProperty("FONT_NAME", fontNameCB
431 .getSelectedItem().toString());
432 Cache.applicationProperties.setProperty("FONT_STYLE", fontStyleCB
433 .getSelectedItem().toString());
434 Cache.applicationProperties.setProperty("FONT_SIZE", fontSizeCB
435 .getSelectedItem().toString());
437 Cache.applicationProperties.setProperty("ID_ITALICS",
438 Boolean.toString(idItalics.isSelected()));
439 Cache.applicationProperties.setProperty("SHOW_UNCONSERVED",
440 Boolean.toString(showUnconserved.isSelected()));
441 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSENSUS",
442 Boolean.toString(showGroupConsensus.isSelected()));
443 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSERVATION",
444 Boolean.toString(showGroupConservation.isSelected()));
445 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_HISTOGRAM",
446 Boolean.toString(showConsensHistogram.isSelected()));
447 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_LOGO",
448 Boolean.toString(showConsensLogo.isSelected()));
449 Cache.applicationProperties.setProperty("ANTI_ALIAS",
450 Boolean.toString(smoothFont.isSelected()));
451 Cache.applicationProperties.setProperty(SCALE_PROTEIN_TO_CDNA,
452 Boolean.toString(scaleProteinToCdna.isSelected()));
453 Cache.applicationProperties.setProperty("SHOW_NPFEATS_TOOLTIP",
454 Boolean.toString(showNpTooltip.isSelected()));
455 Cache.applicationProperties.setProperty("SHOW_DBREFS_TOOLTIP",
456 Boolean.toString(showDbRefTooltip.isSelected()));
458 Cache.applicationProperties.setProperty("WRAP_ALIGNMENT",
459 Boolean.toString(wrap.isSelected()));
461 Cache.applicationProperties.setProperty("STARTUP_FILE",
462 startupFileTextfield.getText());
463 Cache.applicationProperties.setProperty("SHOW_STARTUP_FILE",
464 Boolean.toString(startupCheckbox.isSelected()));
466 Cache.applicationProperties.setProperty("SORT_ALIGNMENT", sortby
467 .getSelectedItem().toString());
469 // convert description of sort order to enum name for save
470 SequenceAnnotationOrder annSortOrder = SequenceAnnotationOrder
471 .forDescription(sortAnnBy.getSelectedItem().toString());
472 if (annSortOrder != null)
474 Cache.applicationProperties.setProperty(SORT_ANNOTATIONS,
475 annSortOrder.name());
478 final boolean showAutocalcFirst = sortAutocalc.getSelectedIndex() == 0;
479 Cache.applicationProperties.setProperty(SHOW_AUTOCALC_ABOVE, Boolean
480 .valueOf(showAutocalcFirst).toString());
483 * Save Colours settings
485 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_PROT, protColour
486 .getSelectedItem().toString());
487 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_NUC, nucColour
488 .getSelectedItem().toString());
489 Cache.setColourProperty("ANNOTATIONCOLOUR_MIN",
490 minColour.getBackground());
491 Cache.setColourProperty("ANNOTATIONCOLOUR_MAX",
492 maxColour.getBackground());
495 * Save Structure settings
497 Cache.applicationProperties.setProperty(ADD_TEMPFACT_ANN,
498 Boolean.toString(addTempFactor.isSelected()));
499 Cache.applicationProperties.setProperty(ADD_SS_ANN,
500 Boolean.toString(addSecondaryStructure.isSelected()));
501 Cache.applicationProperties.setProperty(USE_RNAVIEW,
502 Boolean.toString(useRnaView.isSelected()));
503 Cache.applicationProperties.setProperty(STRUCT_FROM_PDB,
504 Boolean.toString(structFromPdb.isSelected()));
505 Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY, structViewer
506 .getSelectedItem().toString());
507 Cache.setOrRemove(CHIMERA_PATH, chimeraPath.getText());
508 Cache.applicationProperties.setProperty("MAP_WITH_SIFTS",
509 Boolean.toString(siftsMapping.isSelected()));
510 SiftsSettings.setMapWithSifts(siftsMapping.isSelected());
513 * Save Output settings
515 if (epsRendering.getSelectedItem().equals("Prompt each time"))
517 Cache.applicationProperties.remove("EPS_RENDERING");
521 Cache.applicationProperties.setProperty("EPS_RENDERING", epsRendering
522 .getSelectedItem().toString());
526 * Save Connections settings
528 Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
530 jalview.util.BrowserLauncher.resetBrowser();
532 if (nameLinks.size() > 0)
534 StringBuffer links = new StringBuffer();
535 sequenceURLLinks = new Vector();
536 for (int i = 0; i < nameLinks.size(); i++)
538 sequenceURLLinks.addElement(nameLinks.elementAt(i) + "|"
539 + urlLinks.elementAt(i));
540 links.append(sequenceURLLinks.elementAt(i).toString());
544 links.setLength(links.length() - 1);
545 Cache.applicationProperties.setProperty("SEQUENCE_LINKS",
550 Cache.applicationProperties.remove("SEQUENCE_LINKS");
553 Cache.applicationProperties.setProperty("USE_PROXY",
554 Boolean.toString(useProxy.isSelected()));
556 Cache.setOrRemove("PROXY_SERVER", proxyServerTB.getText());
558 Cache.setOrRemove("PROXY_PORT", proxyPortTB.getText());
560 if (useProxy.isSelected())
562 System.setProperty("http.proxyHost", proxyServerTB.getText());
563 System.setProperty("http.proxyPort", proxyPortTB.getText());
567 System.setProperty("http.proxyHost", "");
568 System.setProperty("http.proxyPort", "");
570 Cache.setProperty("VERSION_CHECK",
571 Boolean.toString(versioncheck.isSelected()));
572 if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
574 // default is false - we only set this if the user has actively agreed
575 Cache.setProperty("USAGESTATS",
576 Boolean.toString(usagestats.isSelected()));
578 if (!questionnaire.isSelected())
580 Cache.setProperty("NOQUESTIONNAIRES", "true");
584 // special - made easy to edit a property file to disable questionnaires
585 // by just adding the given line
586 Cache.removeProperty("NOQUESTIONNAIRES");
590 * Save Output settings
592 Cache.applicationProperties.setProperty("BLC_JVSUFFIX",
593 Boolean.toString(blcjv.isSelected()));
594 Cache.applicationProperties.setProperty("CLUSTAL_JVSUFFIX",
595 Boolean.toString(clustaljv.isSelected()));
596 Cache.applicationProperties.setProperty("FASTA_JVSUFFIX",
597 Boolean.toString(fastajv.isSelected()));
598 Cache.applicationProperties.setProperty("MSF_JVSUFFIX",
599 Boolean.toString(msfjv.isSelected()));
600 Cache.applicationProperties.setProperty("PFAM_JVSUFFIX",
601 Boolean.toString(pfamjv.isSelected()));
602 Cache.applicationProperties.setProperty("PILEUP_JVSUFFIX",
603 Boolean.toString(pileupjv.isSelected()));
604 Cache.applicationProperties.setProperty("PIR_JVSUFFIX",
605 Boolean.toString(pirjv.isSelected()));
606 Cache.applicationProperties.setProperty("PIR_MODELLER",
607 Boolean.toString(modellerOutput.isSelected()));
608 Cache.applicationProperties.setProperty("EXPORT_EMBBED_BIOJSON",
609 Boolean.toString(embbedBioJSON.isSelected()));
610 jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
612 Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH",
613 Boolean.toString(autoIdWidth.isSelected()));
614 userIdWidth_actionPerformed();
615 Cache.applicationProperties.setProperty("FIGURE_USERIDWIDTH",
616 userIdWidth.getText());
619 * Save Editing settings
621 Cache.applicationProperties.setProperty("AUTO_CALC_CONSENSUS",
622 Boolean.toString(autoCalculateConsCheck.isSelected()));
623 Cache.applicationProperties.setProperty("SORT_BY_TREE",
624 Boolean.toString(sortByTree.isSelected()));
625 Cache.applicationProperties.setProperty("PAD_GAPS",
626 Boolean.toString(padGaps.isSelected()));
628 dasSource.saveProperties(Cache.applicationProperties);
629 wsPrefs.updateAndRefreshWsMenuConfig(false);
630 Cache.saveProperties();
631 Desktop.instance.doConfigureStructurePrefs();
634 frame.setClosed(true);
635 } catch (Exception ex)
641 * Do any necessary validation before saving settings. Return focus to the
642 * first tab which fails validation.
646 private boolean validateSettings()
648 if (!validateStructure())
650 structureTab.requestFocusInWindow();
657 protected boolean validateStructure()
659 return validateChimeraPath();
667 public void startupFileTextfield_mouseClicked()
669 JalviewFileChooser chooser = new JalviewFileChooser(
670 jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] {
671 "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc",
672 "jar" }, new String[] { "Fasta", "Clustal", "PFAM", "MSF",
673 "PIR", "BLC", "Jalview" },
674 jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT"));
675 chooser.setFileView(new JalviewFileView());
676 chooser.setDialogTitle(MessageManager
677 .getString("label.select_startup_file"));
679 int value = chooser.showOpenDialog(this);
681 if (value == JalviewFileChooser.APPROVE_OPTION)
683 jalview.bin.Cache.applicationProperties.setProperty(
684 "DEFAULT_FILE_FORMAT", chooser.getSelectedFormat());
685 startupFileTextfield.setText(chooser.getSelectedFile()
697 public void cancel_actionPerformed(ActionEvent e)
701 wsPrefs.updateWsMenuConfig(true);
702 wsPrefs.refreshWs_actionPerformed(e);
703 frame.setClosed(true);
704 } catch (Exception ex)
716 public void annotations_actionPerformed(ActionEvent e)
718 conservation.setEnabled(annotations.isSelected());
719 quality.setEnabled(annotations.isSelected());
720 identity.setEnabled(annotations.isSelected());
721 showGroupConsensus.setEnabled(annotations.isSelected());
722 showGroupConservation.setEnabled(annotations.isSelected());
723 showConsensHistogram.setEnabled(annotations.isSelected()
724 && (identity.isSelected() || showGroupConsensus.isSelected()));
725 showConsensLogo.setEnabled(annotations.isSelected()
726 && (identity.isSelected() || showGroupConsensus.isSelected()));
730 public void newLink_actionPerformed(ActionEvent e)
733 GSequenceLink link = new GSequenceLink();
734 boolean valid = false;
737 if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
738 MessageManager.getString("label.new_sequence_url_link"),
739 JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
741 if (link.checkValid())
743 nameLinks.addElement(link.getName());
744 urlLinks.addElement(link.getURL());
757 public void editLink_actionPerformed(ActionEvent e)
759 GSequenceLink link = new GSequenceLink();
761 int index = linkNameList.getSelectedIndex();
764 JOptionPane.showInternalMessageDialog(Desktop.desktop,
765 MessageManager.getString("label.no_link_selected"),
766 MessageManager.getString("label.no_link_selected"),
767 JOptionPane.WARNING_MESSAGE);
771 link.setName(nameLinks.elementAt(index).toString());
772 link.setURL(urlLinks.elementAt(index).toString());
774 boolean valid = false;
778 if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
779 MessageManager.getString("label.new_sequence_url_link"),
780 JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
782 if (link.checkValid())
784 nameLinks.setElementAt(link.getName(), index);
785 urlLinks.setElementAt(link.getURL(), index);
799 public void deleteLink_actionPerformed(ActionEvent e)
801 int index = linkNameList.getSelectedIndex();
804 JOptionPane.showInternalMessageDialog(Desktop.desktop,
805 MessageManager.getString("label.no_link_selected"),
806 MessageManager.getString("label.no_link_selected"),
807 JOptionPane.WARNING_MESSAGE);
810 nameLinks.removeElementAt(index);
811 urlLinks.removeElementAt(index);
815 void updateLinkData()
817 linkNameList.setListData(nameLinks);
818 linkURLList.setListData(urlLinks);
822 public void defaultBrowser_mouseClicked(MouseEvent e)
824 JFileChooser chooser = new JFileChooser(".");
825 chooser.setDialogTitle(MessageManager
826 .getString("label.select_default_browser"));
828 int value = chooser.showOpenDialog(this);
830 if (value == JFileChooser.APPROVE_OPTION)
832 defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath());
841 * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event
845 protected void showunconserved_actionPerformed(ActionEvent e)
847 // TODO Auto-generated method stub
848 super.showunconserved_actionPerformed(e);
851 public static Collection getGroupURLLinks()
853 return groupURLLinks;
857 public void minColour_actionPerformed(JPanel panel)
859 Color col = JColorChooser.showDialog(this,
860 MessageManager.getString("label.select_colour_minimum_value"),
861 minColour.getBackground());
864 panel.setBackground(col);
870 public void maxColour_actionPerformed(JPanel panel)
872 Color col = JColorChooser.showDialog(this,
873 MessageManager.getString("label.select_colour_maximum_value"),
874 maxColour.getBackground());
877 panel.setBackground(col);
883 protected void userIdWidth_actionPerformed()
887 String val = userIdWidth.getText().trim();
888 if (val.length() > 0)
890 Integer iw = Integer.parseInt(val);
891 if (iw.intValue() < 12)
893 throw new NumberFormatException();
895 userIdWidth.setText(iw.toString());
897 } catch (NumberFormatException x)
899 JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
900 .getString("warn.user_defined_width_requirements"),
901 MessageManager.getString("label.invalid_id_column_width"),
902 JOptionPane.WARNING_MESSAGE);
903 userIdWidth.setText("");
908 protected void autoIdWidth_actionPerformed()
910 userIdWidth.setEnabled(!autoIdWidth.isSelected());
911 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
915 * Returns true if chimera path is to a valid executable, else show an error
918 private boolean validateChimeraPath()
920 if (chimeraPath.getText().trim().length() > 0)
922 File f = new File(chimeraPath.getText());
925 JOptionPane.showInternalMessageDialog(Desktop.desktop,
926 MessageManager.getString("label.invalid_chimera_path"),
927 MessageManager.getString("label.invalid_name"),
928 JOptionPane.ERROR_MESSAGE);
936 * If Chimera is selected, check it can be found on default or user-specified
937 * path, if not show a warning/help dialog.
940 protected void structureViewer_actionPerformed(String selectedItem)
942 if (!selectedItem.equals(ViewerType.CHIMERA.name()))
946 boolean found = false;
949 * Try user-specified and standard paths for Chimera executable.
951 List<String> paths = StructureManager.getChimeraPaths();
952 paths.add(0, chimeraPath.getText());
953 for (String path : paths)
955 if (new File(path.trim()).canExecute())
963 String[] options = { "OK", "Help" };
964 int showHelp = JOptionPane.showInternalOptionDialog(
966 JvSwingUtils.wrapTooltip(true,
967 MessageManager.getString("label.chimera_missing")),
968 "", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE,
969 null, options, options[0]);
970 if (showHelp == JOptionPane.NO_OPTION)
974 Help.showHelpWindow(HelpId.StructureViewer);
975 } catch (HelpSetException e)