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 java.awt.BorderLayout;
24 import java.awt.Color;
25 import java.awt.Dimension;
27 import java.awt.event.ActionEvent;
28 import java.awt.event.ActionListener;
29 import java.awt.event.MouseEvent;
31 import java.util.Collection;
32 import java.util.List;
33 import java.util.StringTokenizer;
34 import java.util.Vector;
36 import javax.help.HelpSetException;
37 import javax.swing.JColorChooser;
38 import javax.swing.JFileChooser;
39 import javax.swing.JInternalFrame;
40 import javax.swing.JOptionPane;
41 import javax.swing.JPanel;
43 import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
45 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
46 import jalview.bin.Cache;
47 import jalview.gui.Help.HelpId;
48 import jalview.gui.StructureViewer.ViewerType;
49 import jalview.io.JalviewFileChooser;
50 import jalview.io.JalviewFileView;
51 import jalview.jbgui.GPreferences;
52 import jalview.jbgui.GSequenceLink;
53 import jalview.schemes.ColourSchemeProperty;
54 import jalview.util.MessageManager;
62 public class Preferences extends GPreferences
65 public static final String SCALE_PROTEIN_TO_CDNA = "SCALE_PROTEIN_TO_CDNA";
67 public static final String DEFAULT_COLOUR = "DEFAULT_COLOUR";
69 public static final String DEFAULT_COLOUR_PROT = "DEFAULT_COLOUR_PROT";
71 public static final String DEFAULT_COLOUR_NUC = "DEFAULT_COLOUR_NUC";
73 public static final String ADD_TEMPFACT_ANN = "ADD_TEMPFACT_ANN";
75 public static final String ADD_SS_ANN = "ADD_SS_ANN";
77 public static final String USE_RNAVIEW = "USE_RNAVIEW";
79 public static final String STRUCT_FROM_PDB = "STRUCT_FROM_PDB";
81 public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY";
83 public static final String CHIMERA_PATH = "CHIMERA_PATH";
85 public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS";
87 public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE";
89 private static final int MIN_FONT_SIZE = 1;
91 private static final int MAX_FONT_SIZE = 30;
94 * Holds name and link separated with | character. Sequence ID must be
95 * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$
97 public static Vector sequenceURLLinks;
100 * Holds name and link separated with | character. Sequence IDS and Sequences
101 * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and
102 * $SEQUENCES$ or $SEQUENCES=/.possible | chars ./=$ and separation character
103 * for first and second token specified after a pipe character at end |,|.
104 * (TODO: proper escape for using | to separate ids or sequences
107 public static Vector groupURLLinks;
110 String string = Cache
113 "EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$");
114 sequenceURLLinks = new Vector();
118 StringTokenizer st = new StringTokenizer(string, "|");
119 while (st.hasMoreElements())
121 String name = st.nextToken();
122 String url = st.nextToken();
123 // check for '|' within a regex
124 int rxstart = url.indexOf("$SEQUENCE_ID$");
125 while (rxstart == -1 && url.indexOf("/=$") == -1)
127 url = url + "|" + st.nextToken();
129 sequenceURLLinks.addElement(name + "|" + url);
131 } catch (Exception ex)
133 System.out.println(ex + "\nError parsing sequence links");
136 // upgrade old SRS link
137 int srsPos = sequenceURLLinks
138 .indexOf("SRS|http://srs.ebi.ac.uk/srsbin/cgi-bin/wgetz?-newId+(([uniprot-all:$SEQUENCE_ID$]))+-view+SwissEntry");
143 "EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$",
149 * TODO: reformulate groupURL encoding so two or more can be stored in the
150 * .properties file as '|' separated strings
153 groupURLLinks = new Vector();
156 Vector nameLinks, urlLinks;
158 JInternalFrame frame;
160 DasSourceBrowser dasSource;
162 private WsPreferences wsPrefs;
165 * Creates a new Preferences object.
170 frame = new JInternalFrame();
171 frame.setContentPane(this);
172 dasSource = new DasSourceBrowser();
173 dasTab.add(dasSource, BorderLayout.CENTER);
174 wsPrefs = new WsPreferences();
175 wsTab.add(wsPrefs, BorderLayout.CENTER);
176 int width = 500, height = 450;
177 if (new jalview.util.Platform().isAMac())
183 Desktop.addInternalFrame(frame,
184 MessageManager.getString("label.preferences"), width, height);
185 frame.setMinimumSize(new Dimension(width, height));
188 * Set Visual tab defaults
190 seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true));
191 rightAlign.setSelected(Cache.getDefault("RIGHT_ALIGN_IDS", false));
192 fullScreen.setSelected(Cache.getDefault("SHOW_FULLSCREEN", false));
193 annotations.setSelected(Cache.getDefault("SHOW_ANNOTATIONS", true));
195 conservation.setSelected(Cache.getDefault("SHOW_CONSERVATION", true));
196 quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));
197 identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
198 openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false));
200 .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
201 showGroupConsensus.setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS",
203 showGroupConservation.setSelected(Cache.getDefault(
204 "SHOW_GROUP_CONSERVATION", false));
205 showConsensHistogram.setSelected(Cache.getDefault(
206 "SHOW_CONSENSUS_HISTOGRAM", true));
207 showConsensLogo.setSelected(Cache.getDefault("SHOW_CONSENSUS_LOGO",
209 showNpTooltip.setSelected(Cache
210 .getDefault("SHOW_NPFEATS_TOOLTIP", true));
211 showDbRefTooltip.setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP",
214 String[] fonts = java.awt.GraphicsEnvironment
215 .getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
216 for (int i = 0; i < fonts.length; i++)
218 fontNameCB.addItem(fonts[i]);
221 for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++)
223 fontSizeCB.addItem(i + "");
226 fontStyleCB.addItem("plain");
227 fontStyleCB.addItem("bold");
228 fontStyleCB.addItem("italic");
230 fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif"));
231 fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10"));
232 fontStyleCB.setSelectedItem(Cache.getDefault("FONT_STYLE", Font.PLAIN
235 smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", false));
236 scaleProteinToCdna.setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA,
239 idItalics.setSelected(Cache.getDefault("ID_ITALICS", true));
241 wrap.setSelected(Cache.getDefault("WRAP_ALIGNMENT", false));
243 gapSymbolCB.addItem("-");
244 gapSymbolCB.addItem(".");
246 gapSymbolCB.setSelectedItem(Cache.getDefault("GAP_SYMBOL", "-"));
248 sortby.addItem("No sort");
249 sortby.addItem("Id");
250 sortby.addItem("Pairwise Identity");
251 sortby.setSelectedItem(Cache.getDefault("SORT_ALIGNMENT", "No sort"));
253 sortAnnBy.addItem(SequenceAnnotationOrder.NONE.toString());
255 .addItem(SequenceAnnotationOrder.SEQUENCE_AND_LABEL.toString());
257 .addItem(SequenceAnnotationOrder.LABEL_AND_SEQUENCE.toString());
258 SequenceAnnotationOrder savedSort = SequenceAnnotationOrder
259 .valueOf(Cache.getDefault(SORT_ANNOTATIONS,
260 SequenceAnnotationOrder.NONE.name()));
261 sortAnnBy.setSelectedItem(savedSort.toString());
263 sortAutocalc.addItem("Autocalculated first");
264 sortAutocalc.addItem("Autocalculated last");
265 final boolean showAbove = Cache.getDefault(SHOW_AUTOCALC_ABOVE,
267 sortAutocalc.setSelectedItem(showAbove ? sortAutocalc.getItemAt(0)
268 : sortAutocalc.getItemAt(1));
270 .setSelected(Cache.getDefault("SHOW_STARTUP_FILE", true));
271 startupFileTextfield.setText(Cache.getDefault("STARTUP_FILE",
272 Cache.getDefault("www.jalview.org", "http://www.jalview.org")
273 + "/examples/exampleFile_2_3.jar"));
276 * Set Colours tab defaults
278 for (int i = ColourSchemeProperty.FIRST_COLOUR; i <= ColourSchemeProperty.LAST_COLOUR; i++)
280 protColour.addItem(ColourSchemeProperty.getColourName(i));
281 nucColour.addItem(ColourSchemeProperty.getColourName(i));
283 String oldProp = Cache.getDefault(DEFAULT_COLOUR, "None");
284 String newProp = Cache.getDefault(DEFAULT_COLOUR_PROT, null);
285 protColour.setSelectedItem(newProp != null ? newProp : oldProp);
286 newProp = Cache.getDefault(DEFAULT_COLOUR_NUC, null);
287 nucColour.setSelectedItem(newProp != null ? newProp : oldProp);
288 minColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN",
290 maxColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX",
294 * Set Structure tab defaults.
296 final boolean structSelected = Cache.getDefault(STRUCT_FROM_PDB, false);
297 structFromPdb.setSelected(structSelected);
298 useRnaView.setSelected(Cache.getDefault(USE_RNAVIEW, false));
299 useRnaView.setEnabled(structSelected);
300 addSecondaryStructure
301 .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();
318 * Set Connections tab defaults
320 nameLinks = new Vector();
321 urlLinks = new Vector();
322 for (int i = 0; i < sequenceURLLinks.size(); i++)
324 String link = sequenceURLLinks.elementAt(i).toString();
325 nameLinks.addElement(link.substring(0, link.indexOf("|")));
326 urlLinks.addElement(link.substring(link.indexOf("|") + 1));
331 useProxy.setSelected(Cache.getDefault("USE_PROXY", false));
332 proxyServerTB.setEnabled(useProxy.isSelected());
333 proxyPortTB.setEnabled(useProxy.isSelected());
334 proxyServerTB.setText(Cache.getDefault("PROXY_SERVER", ""));
335 proxyPortTB.setText(Cache.getDefault("PROXY_PORT", ""));
337 defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
339 usagestats.setSelected(Cache.getDefault("USAGESTATS", false));
340 // note antisense here: default is true
342 .setSelected(Cache.getProperty("NOQUESTIONNAIRES") == null);
343 versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true));
346 * Set Output tab defaults
349 .addItem(MessageManager.getString("label.prompt_each_time"));
350 epsRendering.addItem(MessageManager.getString("label.lineart"));
351 epsRendering.addItem(MessageManager.getString("action.text"));
352 epsRendering.setSelectedItem(Cache.getDefault("EPS_RENDERING",
353 "Prompt each time"));
354 autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
355 userIdWidth.setEnabled(autoIdWidth.isSelected());
356 userIdWidthlabel.setEnabled(autoIdWidth.isSelected());
357 Integer wi = Cache.getIntegerProperty("FIGURE_USERIDWIDTH");
358 userIdWidth.setText(wi == null ? "" : wi.toString());
359 blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
360 clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
361 fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
362 msfjv.setSelected(Cache.getDefault("MSF_JVSUFFIX", true));
363 pfamjv.setSelected(Cache.getDefault("PFAM_JVSUFFIX", true));
364 pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true));
365 pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true));
366 modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false));
369 * Set Editing tab defaults
371 autoCalculateConsCheck.setSelected(Cache.getDefault(
372 "AUTO_CALC_CONSENSUS", true));
373 padGaps.setSelected(Cache.getDefault("PAD_GAPS", false));
374 sortByTree.setSelected(Cache.getDefault("SORT_BY_TREE", false));
376 annotations_actionPerformed(null); // update the display of the annotation
381 * 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,
466 Boolean.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());
496 * Save Output settings
498 if (epsRendering.getSelectedItem().equals("Prompt each time"))
500 Cache.applicationProperties.remove("EPS_RENDERING");
504 Cache.applicationProperties.setProperty("EPS_RENDERING", epsRendering
505 .getSelectedItem().toString());
509 * Save Connections settings
511 Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
513 jalview.util.BrowserLauncher.resetBrowser();
515 if (nameLinks.size() > 0)
517 StringBuffer links = new StringBuffer();
518 sequenceURLLinks = new Vector();
519 for (int i = 0; i < nameLinks.size(); i++)
521 sequenceURLLinks.addElement(nameLinks.elementAt(i) + "|"
522 + urlLinks.elementAt(i));
523 links.append(sequenceURLLinks.elementAt(i).toString());
527 links.setLength(links.length() - 1);
528 Cache.applicationProperties.setProperty("SEQUENCE_LINKS",
533 Cache.applicationProperties.remove("SEQUENCE_LINKS");
536 Cache.applicationProperties.setProperty("USE_PROXY",
537 Boolean.toString(useProxy.isSelected()));
539 Cache.setOrRemove("PROXY_SERVER", proxyServerTB.getText());
541 Cache.setOrRemove("PROXY_PORT", proxyPortTB.getText());
543 if (useProxy.isSelected())
545 System.setProperty("http.proxyHost", proxyServerTB.getText());
546 System.setProperty("http.proxyPort", proxyPortTB.getText());
550 System.setProperty("http.proxyHost", "");
551 System.setProperty("http.proxyPort", "");
553 Cache.setProperty("VERSION_CHECK",
554 Boolean.toString(versioncheck.isSelected()));
555 if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
557 // default is false - we only set this if the user has actively agreed
558 Cache.setProperty("USAGESTATS",
559 Boolean.toString(usagestats.isSelected()));
561 if (!questionnaire.isSelected())
563 Cache.setProperty("NOQUESTIONNAIRES", "true");
567 // special - made easy to edit a property file to disable questionnaires
568 // by just adding the given line
569 Cache.removeProperty("NOQUESTIONNAIRES");
573 * Save Output settings
575 Cache.applicationProperties.setProperty("BLC_JVSUFFIX",
576 Boolean.toString(blcjv.isSelected()));
577 Cache.applicationProperties.setProperty("CLUSTAL_JVSUFFIX",
578 Boolean.toString(clustaljv.isSelected()));
579 Cache.applicationProperties.setProperty("FASTA_JVSUFFIX",
580 Boolean.toString(fastajv.isSelected()));
581 Cache.applicationProperties.setProperty("MSF_JVSUFFIX",
582 Boolean.toString(msfjv.isSelected()));
583 Cache.applicationProperties.setProperty("PFAM_JVSUFFIX",
584 Boolean.toString(pfamjv.isSelected()));
585 Cache.applicationProperties.setProperty("PILEUP_JVSUFFIX",
586 Boolean.toString(pileupjv.isSelected()));
587 Cache.applicationProperties.setProperty("PIR_JVSUFFIX",
588 Boolean.toString(pirjv.isSelected()));
589 Cache.applicationProperties.setProperty("PIR_MODELLER",
590 Boolean.toString(modellerOutput.isSelected()));
591 jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
593 Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH",
594 Boolean.toString(autoIdWidth.isSelected()));
595 userIdWidth_actionPerformed();
596 Cache.applicationProperties.setProperty("FIGURE_USERIDWIDTH",
597 userIdWidth.getText());
600 * Save Editing settings
602 Cache.applicationProperties.setProperty("AUTO_CALC_CONSENSUS",
603 Boolean.toString(autoCalculateConsCheck.isSelected()));
604 Cache.applicationProperties.setProperty("SORT_BY_TREE",
605 Boolean.toString(sortByTree.isSelected()));
606 Cache.applicationProperties.setProperty("PAD_GAPS",
607 Boolean.toString(padGaps.isSelected()));
609 dasSource.saveProperties(Cache.applicationProperties);
610 wsPrefs.updateAndRefreshWsMenuConfig(false);
611 Cache.saveProperties();
612 Desktop.instance.doConfigureStructurePrefs();
615 frame.setClosed(true);
616 } catch (Exception ex)
622 * Do any necessary validation before saving settings. Return focus to the
623 * first tab which fails validation.
627 private boolean validateSettings()
629 if (!validateStructure())
631 structureTab.requestFocusInWindow();
638 protected boolean validateStructure()
640 return validateChimeraPath();
646 public void startupFileTextfield_mouseClicked()
648 JalviewFileChooser chooser = new JalviewFileChooser(
649 jalview.bin.Cache.getProperty("LAST_DIRECTORY"),
651 { "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc", "jar" },
653 { "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview" },
654 jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT"));
655 chooser.setFileView(new JalviewFileView());
656 chooser.setDialogTitle(MessageManager.getString("label.select_startup_file"));
658 int value = chooser.showOpenDialog(this);
660 if (value == JalviewFileChooser.APPROVE_OPTION)
662 jalview.bin.Cache.applicationProperties.setProperty(
663 "DEFAULT_FILE_FORMAT", chooser.getSelectedFormat());
664 startupFileTextfield.setText(chooser.getSelectedFile()
675 public void cancel_actionPerformed(ActionEvent e)
679 wsPrefs.updateWsMenuConfig(true);
680 wsPrefs.refreshWs_actionPerformed(e);
681 frame.setClosed(true);
682 } catch (Exception ex)
693 public void annotations_actionPerformed(ActionEvent e)
695 conservation.setEnabled(annotations.isSelected());
696 quality.setEnabled(annotations.isSelected());
697 identity.setEnabled(annotations.isSelected());
698 showGroupConsensus.setEnabled(annotations.isSelected());
699 showGroupConservation.setEnabled(annotations.isSelected());
700 showConsensHistogram.setEnabled(annotations.isSelected()
701 && (identity.isSelected() || showGroupConsensus.isSelected()));
702 showConsensLogo.setEnabled(annotations.isSelected()
703 && (identity.isSelected() || showGroupConsensus.isSelected()));
706 public void newLink_actionPerformed(ActionEvent e)
709 GSequenceLink link = new GSequenceLink();
710 boolean valid = false;
713 if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
714 MessageManager.getString("label.new_sequence_url_link"),
715 JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
717 if (link.checkValid())
719 nameLinks.addElement(link.getName());
720 urlLinks.addElement(link.getURL());
732 public void editLink_actionPerformed(ActionEvent e)
734 GSequenceLink link = new GSequenceLink();
736 int index = linkNameList.getSelectedIndex();
739 JOptionPane.showInternalMessageDialog(Desktop.desktop,
740 MessageManager.getString("label.no_link_selected"),
741 MessageManager.getString("label.no_link_selected"),
742 JOptionPane.WARNING_MESSAGE);
746 link.setName(nameLinks.elementAt(index).toString());
747 link.setURL(urlLinks.elementAt(index).toString());
749 boolean valid = false;
753 if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
754 MessageManager.getString("label.new_sequence_url_link"),
755 JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
757 if (link.checkValid())
759 nameLinks.setElementAt(link.getName(), index);
760 urlLinks.setElementAt(link.getURL(), index);
773 public void deleteLink_actionPerformed(ActionEvent e)
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);
784 nameLinks.removeElementAt(index);
785 urlLinks.removeElementAt(index);
789 void updateLinkData()
791 linkNameList.setListData(nameLinks);
792 linkURLList.setListData(urlLinks);
795 public void defaultBrowser_mouseClicked(MouseEvent e)
797 JFileChooser chooser = new JFileChooser(".");
798 chooser.setDialogTitle(MessageManager.getString("label.select_default_browser"));
800 int value = chooser.showOpenDialog(this);
802 if (value == JFileChooser.APPROVE_OPTION)
804 defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath());
813 * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event
816 protected void showunconserved_actionPerformed(ActionEvent e)
818 // TODO Auto-generated method stub
819 super.showunconserved_actionPerformed(e);
822 public static Collection getGroupURLLinks()
824 return groupURLLinks;
828 public void minColour_actionPerformed(JPanel panel)
830 Color col = JColorChooser.showDialog(this,
831 MessageManager.getString("label.select_colour_minimum_value"), minColour.getBackground());
834 panel.setBackground(col);
840 public void maxColour_actionPerformed(JPanel panel)
842 Color col = JColorChooser.showDialog(this,
843 MessageManager.getString("label.select_colour_maximum_value"), maxColour.getBackground());
846 panel.setBackground(col);
852 protected void userIdWidth_actionPerformed()
856 String val = userIdWidth.getText().trim();
857 if (val.length() > 0)
859 Integer iw = Integer.parseInt(val);
860 if (iw.intValue() < 12)
862 throw new NumberFormatException();
864 userIdWidth.setText(iw.toString());
866 } catch (NumberFormatException x)
869 .showInternalMessageDialog(
871 MessageManager.getString("warn.user_defined_width_requirements"),
872 MessageManager.getString("label.invalid_id_column_width"),
873 JOptionPane.WARNING_MESSAGE);
874 userIdWidth.setText("");
879 protected void autoIdWidth_actionPerformed()
881 userIdWidth.setEnabled(!autoIdWidth.isSelected());
882 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
886 * Returns true if chimera path is to a valid executable, else show an error
889 private boolean validateChimeraPath()
891 if (chimeraPath.getText().trim().length() > 0)
893 File f = new File(chimeraPath.getText());
896 JOptionPane.showInternalMessageDialog(Desktop.desktop,
897 MessageManager.getString("label.invalid_chimera_path"),
898 MessageManager.getString("label.invalid_name"),
899 JOptionPane.ERROR_MESSAGE);
907 * If Chimera is selected, check it can be found on default or user-specified
908 * path, if not show a warning/help dialog.
911 protected void structureViewer_actionPerformed(String selectedItem)
913 if (!selectedItem.equals(ViewerType.CHIMERA.name()))
917 boolean found = false;
920 * Try user-specified and standard paths for Chimera executable.
922 List<String> paths = StructureManager.getChimeraPaths();
923 paths.add(0, chimeraPath.getText());
924 for (String path : paths)
926 if (new File(path.trim()).canExecute())
936 int showHelp = JOptionPane.showInternalOptionDialog(
938 JvSwingUtils.wrapTooltip(true,
939 MessageManager.getString("label.chimera_missing")),
940 "", JOptionPane.YES_NO_OPTION,
941 JOptionPane.WARNING_MESSAGE, null, options, options[0]);
942 if (showHelp == JOptionPane.NO_OPTION)
946 Help.showHelpWindow(HelpId.StructureViewer);
947 } catch (HelpSetException e)