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;
34 import java.awt.BorderLayout;
35 import java.awt.Color;
36 import java.awt.Dimension;
38 import java.awt.event.ActionEvent;
39 import java.awt.event.ActionListener;
40 import java.awt.event.MouseEvent;
42 import java.util.Collection;
43 import java.util.List;
44 import java.util.StringTokenizer;
45 import java.util.Vector;
47 import javax.help.HelpSetException;
48 import javax.swing.JColorChooser;
49 import javax.swing.JFileChooser;
50 import javax.swing.JInternalFrame;
51 import javax.swing.JOptionPane;
52 import javax.swing.JPanel;
54 import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
62 public class Preferences extends GPreferences
65 public static final String DEFAULT_COLOUR = "DEFAULT_COLOUR";
67 public static final String DEFAULT_COLOUR_PROT = "DEFAULT_COLOUR_PROT";
69 public static final String DEFAULT_COLOUR_NUC = "DEFAULT_COLOUR_NUC";
71 public static final String ADD_TEMPFACT_ANN = "ADD_TEMPFACT_ANN";
73 public static final String ADD_SS_ANN = "ADD_SS_ANN";
75 public static final String USE_RNAVIEW = "USE_RNAVIEW";
77 public static final String STRUCT_FROM_PDB = "STRUCT_FROM_PDB";
79 public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY";
81 public static final String CHIMERA_PATH = "CHIMERA_PATH";
83 public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS";
85 public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE";
87 private static final int MIN_FONT_SIZE = 1;
89 private static final int MAX_FONT_SIZE = 30;
92 * Holds name and link separated with | character. Sequence ID must be
93 * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$
95 public static Vector sequenceURLLinks;
98 * Holds name and link separated with | character. Sequence IDS and Sequences
99 * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and
100 * $SEQUENCES$ or $SEQUENCES=/.possible | chars ./=$ and separation character
101 * for first and second token specified after a pipe character at end |,|.
102 * (TODO: proper escape for using | to separate ids or sequences
105 public static Vector groupURLLinks;
108 String string = Cache
111 "EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$");
112 sequenceURLLinks = new Vector();
116 StringTokenizer st = new StringTokenizer(string, "|");
117 while (st.hasMoreElements())
119 String name = st.nextToken();
120 String url = st.nextToken();
121 // check for '|' within a regex
122 int rxstart = url.indexOf("$SEQUENCE_ID$");
123 while (rxstart == -1 && url.indexOf("/=$") == -1)
125 url = url + "|" + st.nextToken();
127 sequenceURLLinks.addElement(name + "|" + url);
129 } catch (Exception ex)
131 System.out.println(ex + "\nError parsing sequence links");
134 // upgrade old SRS link
135 int srsPos = sequenceURLLinks
136 .indexOf("SRS|http://srs.ebi.ac.uk/srsbin/cgi-bin/wgetz?-newId+(([uniprot-all:$SEQUENCE_ID$]))+-view+SwissEntry");
141 "EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$",
147 * TODO: reformulate groupURL encoding so two or more can be stored in the
148 * .properties file as '|' separated strings
151 groupURLLinks = new Vector();
154 Vector nameLinks, urlLinks;
156 JInternalFrame frame;
158 DasSourceBrowser dasSource;
160 private WsPreferences wsPrefs;
163 * Creates a new Preferences object.
168 frame = new JInternalFrame();
169 frame.setContentPane(this);
170 dasSource = new DasSourceBrowser();
171 dasTab.add(dasSource, BorderLayout.CENTER);
172 wsPrefs = new WsPreferences();
173 wsTab.add(wsPrefs, BorderLayout.CENTER);
174 int width = 500, height = 420;
175 if (new jalview.util.Platform().isAMac())
181 Desktop.addInternalFrame(frame,
182 MessageManager.getString("label.preferences"), width, height);
183 frame.setMinimumSize(new Dimension(width, height));
186 * Set Visual tab defaults
188 seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true));
189 rightAlign.setSelected(Cache.getDefault("RIGHT_ALIGN_IDS", false));
190 fullScreen.setSelected(Cache.getDefault("SHOW_FULLSCREEN", false));
191 annotations.setSelected(Cache.getDefault("SHOW_ANNOTATIONS", true));
193 conservation.setSelected(Cache.getDefault("SHOW_CONSERVATION", true));
194 quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));
195 identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
196 openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false));
198 .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
199 showGroupConsensus.setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS",
201 showGroupConservation.setSelected(Cache.getDefault(
202 "SHOW_GROUP_CONSERVATION", false));
203 showConsensHistogram.setSelected(Cache.getDefault(
204 "SHOW_CONSENSUS_HISTOGRAM", true));
205 showConsensLogo.setSelected(Cache.getDefault("SHOW_CONSENSUS_LOGO",
207 showNpTooltip.setSelected(Cache
208 .getDefault("SHOW_NPFEATS_TOOLTIP", true));
209 showDbRefTooltip.setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP",
212 String[] fonts = java.awt.GraphicsEnvironment
213 .getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
214 for (int i = 0; i < fonts.length; i++)
216 fontNameCB.addItem(fonts[i]);
219 for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++)
221 fontSizeCB.addItem(i + "");
224 fontStyleCB.addItem("plain");
225 fontStyleCB.addItem("bold");
226 fontStyleCB.addItem("italic");
228 fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif"));
229 fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10"));
230 fontStyleCB.setSelectedItem(Cache.getDefault("FONT_STYLE", Font.PLAIN
233 smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", false));
235 idItalics.setSelected(Cache.getDefault("ID_ITALICS", true));
237 wrap.setSelected(Cache.getDefault("WRAP_ALIGNMENT", false));
239 gapSymbolCB.addItem("-");
240 gapSymbolCB.addItem(".");
242 gapSymbolCB.setSelectedItem(Cache.getDefault("GAP_SYMBOL", "-"));
244 sortby.addItem("No sort");
245 sortby.addItem("Id");
246 sortby.addItem("Pairwise Identity");
247 sortby.setSelectedItem(Cache.getDefault("SORT_ALIGNMENT", "No sort"));
249 sortAnnBy.addItem(SequenceAnnotationOrder.NONE.toString());
251 .addItem(SequenceAnnotationOrder.SEQUENCE_AND_LABEL.toString());
253 .addItem(SequenceAnnotationOrder.LABEL_AND_SEQUENCE.toString());
254 SequenceAnnotationOrder savedSort = SequenceAnnotationOrder
255 .valueOf(Cache.getDefault(SORT_ANNOTATIONS,
256 SequenceAnnotationOrder.NONE.name()));
257 sortAnnBy.setSelectedItem(savedSort.toString());
259 sortAutocalc.addItem("Autocalculated first");
260 sortAutocalc.addItem("Autocalculated last");
261 final boolean showAbove = Cache.getDefault(SHOW_AUTOCALC_ABOVE,
263 sortAutocalc.setSelectedItem(showAbove ? sortAutocalc.getItemAt(0)
264 : sortAutocalc.getItemAt(1));
266 .setSelected(Cache.getDefault("SHOW_STARTUP_FILE", true));
267 startupFileTextfield.setText(Cache.getDefault("STARTUP_FILE",
268 Cache.getDefault("www.jalview.org", "http://www.jalview.org")
269 + "/examples/exampleFile_2_3.jar"));
272 * Set Colours tab defaults
274 for (int i = ColourSchemeProperty.FIRST_COLOUR; i <= ColourSchemeProperty.LAST_COLOUR; i++)
276 protColour.addItem(ColourSchemeProperty.getColourName(i));
277 nucColour.addItem(ColourSchemeProperty.getColourName(i));
279 String oldProp = Cache.getDefault(DEFAULT_COLOUR, "None");
280 String newProp = Cache.getDefault(DEFAULT_COLOUR_PROT, null);
281 protColour.setSelectedItem(newProp != null ? newProp : oldProp);
282 newProp = Cache.getDefault(DEFAULT_COLOUR_NUC, null);
283 nucColour.setSelectedItem(newProp != null ? newProp : oldProp);
284 minColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN",
286 maxColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX",
290 * Set Structure tab defaults.
292 final boolean structSelected = Cache.getDefault(STRUCT_FROM_PDB, false);
293 structFromPdb.setSelected(structSelected);
294 useRnaView.setSelected(Cache.getDefault(USE_RNAVIEW, false));
295 useRnaView.setEnabled(structSelected);
296 addSecondaryStructure
297 .setSelected(Cache.getDefault(ADD_SS_ANN, false));
298 addSecondaryStructure.setEnabled(structSelected);
299 addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, false));
300 addTempFactor.setEnabled(structSelected);
301 structViewer.setSelectedItem(Cache.getDefault(STRUCTURE_DISPLAY,
302 ViewerType.JMOL.name()));
303 chimeraPath.setText(Cache.getDefault(CHIMERA_PATH, ""));
304 chimeraPath.addActionListener(new ActionListener()
307 public void actionPerformed(ActionEvent e)
309 validateChimeraPath();
314 * Set Connections tab defaults
316 nameLinks = new Vector();
317 urlLinks = new Vector();
318 for (int i = 0; i < sequenceURLLinks.size(); i++)
320 String link = sequenceURLLinks.elementAt(i).toString();
321 nameLinks.addElement(link.substring(0, link.indexOf("|")));
322 urlLinks.addElement(link.substring(link.indexOf("|") + 1));
327 useProxy.setSelected(Cache.getDefault("USE_PROXY", false));
328 proxyServerTB.setEnabled(useProxy.isSelected());
329 proxyPortTB.setEnabled(useProxy.isSelected());
330 proxyServerTB.setText(Cache.getDefault("PROXY_SERVER", ""));
331 proxyPortTB.setText(Cache.getDefault("PROXY_PORT", ""));
333 defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
335 usagestats.setSelected(Cache.getDefault("USAGESTATS", false));
336 // note antisense here: default is true
338 .setSelected(Cache.getProperty("NOQUESTIONNAIRES") == null);
339 versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true));
342 * Set Output tab defaults
345 .addItem(MessageManager.getString("label.prompt_each_time"));
346 epsRendering.addItem(MessageManager.getString("label.lineart"));
347 epsRendering.addItem(MessageManager.getString("action.text"));
348 epsRendering.setSelectedItem(Cache.getDefault("EPS_RENDERING",
349 "Prompt each time"));
350 autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
351 userIdWidth.setEnabled(autoIdWidth.isSelected());
352 userIdWidthlabel.setEnabled(autoIdWidth.isSelected());
353 Integer wi = Cache.getIntegerProperty("FIGURE_USERIDWIDTH");
354 userIdWidth.setText(wi == null ? "" : wi.toString());
355 blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
356 clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
357 fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
358 msfjv.setSelected(Cache.getDefault("MSF_JVSUFFIX", true));
359 pfamjv.setSelected(Cache.getDefault("PFAM_JVSUFFIX", true));
360 pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true));
361 pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true));
362 modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false));
365 * Set Editing tab defaults
367 autoCalculateConsCheck.setSelected(Cache.getDefault(
368 "AUTO_CALC_CONSENSUS", true));
369 padGaps.setSelected(Cache.getDefault("PAD_GAPS", false));
370 sortByTree.setSelected(Cache.getDefault("SORT_BY_TREE", false));
372 annotations_actionPerformed(null); // update the display of the annotation
377 * Save user selections on the Preferences tabs to the Cache and write out to
382 public void ok_actionPerformed(ActionEvent e)
384 if (!validateSettings())
390 * Save Visual settings
392 Cache.applicationProperties.setProperty("SHOW_JVSUFFIX",
393 Boolean.toString(seqLimit.isSelected()));
394 Cache.applicationProperties.setProperty("RIGHT_ALIGN_IDS",
395 Boolean.toString(rightAlign.isSelected()));
396 Cache.applicationProperties.setProperty("SHOW_FULLSCREEN",
397 Boolean.toString(fullScreen.isSelected()));
398 Cache.applicationProperties.setProperty("SHOW_OVERVIEW",
399 Boolean.toString(openoverv.isSelected()));
400 Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
401 Boolean.toString(annotations.isSelected()));
402 Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
403 Boolean.toString(conservation.isSelected()));
404 Cache.applicationProperties.setProperty("SHOW_QUALITY",
405 Boolean.toString(quality.isSelected()));
406 Cache.applicationProperties.setProperty("SHOW_IDENTITY",
407 Boolean.toString(identity.isSelected()));
409 Cache.applicationProperties.setProperty("GAP_SYMBOL", gapSymbolCB
410 .getSelectedItem().toString());
412 Cache.applicationProperties.setProperty("FONT_NAME", fontNameCB
413 .getSelectedItem().toString());
414 Cache.applicationProperties.setProperty("FONT_STYLE", fontStyleCB
415 .getSelectedItem().toString());
416 Cache.applicationProperties.setProperty("FONT_SIZE", fontSizeCB
417 .getSelectedItem().toString());
419 Cache.applicationProperties.setProperty("ID_ITALICS",
420 Boolean.toString(idItalics.isSelected()));
421 Cache.applicationProperties.setProperty("SHOW_UNCONSERVED",
422 Boolean.toString(showUnconserved.isSelected()));
423 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSENSUS",
424 Boolean.toString(showGroupConsensus.isSelected()));
425 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSERVATION",
426 Boolean.toString(showGroupConservation.isSelected()));
427 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_HISTOGRAM",
428 Boolean.toString(showConsensHistogram.isSelected()));
429 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_LOGO",
430 Boolean.toString(showConsensLogo.isSelected()));
431 Cache.applicationProperties.setProperty("ANTI_ALIAS",
432 Boolean.toString(smoothFont.isSelected()));
433 Cache.applicationProperties.setProperty("SHOW_NPFEATS_TOOLTIP",
434 Boolean.toString(showNpTooltip.isSelected()));
435 Cache.applicationProperties.setProperty("SHOW_DBREFS_TOOLTIP",
436 Boolean.toString(showDbRefTooltip.isSelected()));
438 Cache.applicationProperties.setProperty("WRAP_ALIGNMENT",
439 Boolean.toString(wrap.isSelected()));
441 Cache.applicationProperties.setProperty("STARTUP_FILE",
442 startupFileTextfield.getText());
443 Cache.applicationProperties.setProperty("SHOW_STARTUP_FILE",
444 Boolean.toString(startupCheckbox.isSelected()));
446 Cache.applicationProperties.setProperty("SORT_ALIGNMENT", sortby
447 .getSelectedItem().toString());
449 // convert description of sort order to enum name for save
450 SequenceAnnotationOrder annSortOrder = SequenceAnnotationOrder
451 .forDescription(sortAnnBy.getSelectedItem().toString());
452 if (annSortOrder != null)
454 Cache.applicationProperties.setProperty(SORT_ANNOTATIONS,
455 annSortOrder.name());
458 final boolean showAutocalcFirst = sortAutocalc.getSelectedIndex() == 0;
459 Cache.applicationProperties.setProperty(SHOW_AUTOCALC_ABOVE,
460 Boolean.valueOf(showAutocalcFirst).toString());
463 * Save Colours settings
465 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_PROT, protColour
466 .getSelectedItem().toString());
467 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_NUC, nucColour
468 .getSelectedItem().toString());
469 Cache.setColourProperty("ANNOTATIONCOLOUR_MIN",
470 minColour.getBackground());
471 Cache.setColourProperty("ANNOTATIONCOLOUR_MAX",
472 maxColour.getBackground());
475 * Save Structure settings
477 Cache.applicationProperties.setProperty(ADD_TEMPFACT_ANN,
478 Boolean.toString(addTempFactor.isSelected()));
479 Cache.applicationProperties.setProperty(ADD_SS_ANN,
480 Boolean.toString(addSecondaryStructure.isSelected()));
481 Cache.applicationProperties.setProperty(USE_RNAVIEW,
482 Boolean.toString(useRnaView.isSelected()));
483 Cache.applicationProperties.setProperty(STRUCT_FROM_PDB,
484 Boolean.toString(structFromPdb.isSelected()));
485 Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY, structViewer
486 .getSelectedItem().toString());
487 Cache.setOrRemove(CHIMERA_PATH, chimeraPath.getText());
490 * Save Output settings
492 if (epsRendering.getSelectedItem().equals("Prompt each time"))
494 Cache.applicationProperties.remove("EPS_RENDERING");
498 Cache.applicationProperties.setProperty("EPS_RENDERING", epsRendering
499 .getSelectedItem().toString());
503 * Save Connections settings
505 Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
507 jalview.util.BrowserLauncher.resetBrowser();
509 if (nameLinks.size() > 0)
511 StringBuffer links = new StringBuffer();
512 sequenceURLLinks = new Vector();
513 for (int i = 0; i < nameLinks.size(); i++)
515 sequenceURLLinks.addElement(nameLinks.elementAt(i) + "|"
516 + urlLinks.elementAt(i));
517 links.append(sequenceURLLinks.elementAt(i).toString());
521 links.setLength(links.length() - 1);
522 Cache.applicationProperties.setProperty("SEQUENCE_LINKS",
527 Cache.applicationProperties.remove("SEQUENCE_LINKS");
530 Cache.applicationProperties.setProperty("USE_PROXY",
531 Boolean.toString(useProxy.isSelected()));
533 Cache.setOrRemove("PROXY_SERVER", proxyServerTB.getText());
535 Cache.setOrRemove("PROXY_PORT", proxyPortTB.getText());
537 if (useProxy.isSelected())
539 System.setProperty("http.proxyHost", proxyServerTB.getText());
540 System.setProperty("http.proxyPort", proxyPortTB.getText());
544 System.setProperty("http.proxyHost", "");
545 System.setProperty("http.proxyPort", "");
547 Cache.setProperty("VERSION_CHECK",
548 Boolean.toString(versioncheck.isSelected()));
549 if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
551 // default is false - we only set this if the user has actively agreed
552 Cache.setProperty("USAGESTATS",
553 Boolean.toString(usagestats.isSelected()));
555 if (!questionnaire.isSelected())
557 Cache.setProperty("NOQUESTIONNAIRES", "true");
561 // special - made easy to edit a property file to disable questionnaires
562 // by just adding the given line
563 Cache.removeProperty("NOQUESTIONNAIRES");
567 * Save Output settings
569 Cache.applicationProperties.setProperty("BLC_JVSUFFIX",
570 Boolean.toString(blcjv.isSelected()));
571 Cache.applicationProperties.setProperty("CLUSTAL_JVSUFFIX",
572 Boolean.toString(clustaljv.isSelected()));
573 Cache.applicationProperties.setProperty("FASTA_JVSUFFIX",
574 Boolean.toString(fastajv.isSelected()));
575 Cache.applicationProperties.setProperty("MSF_JVSUFFIX",
576 Boolean.toString(msfjv.isSelected()));
577 Cache.applicationProperties.setProperty("PFAM_JVSUFFIX",
578 Boolean.toString(pfamjv.isSelected()));
579 Cache.applicationProperties.setProperty("PILEUP_JVSUFFIX",
580 Boolean.toString(pileupjv.isSelected()));
581 Cache.applicationProperties.setProperty("PIR_JVSUFFIX",
582 Boolean.toString(pirjv.isSelected()));
583 Cache.applicationProperties.setProperty("PIR_MODELLER",
584 Boolean.toString(modellerOutput.isSelected()));
585 jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
587 Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH",
588 Boolean.toString(autoIdWidth.isSelected()));
589 userIdWidth_actionPerformed();
590 Cache.applicationProperties.setProperty("FIGURE_USERIDWIDTH",
591 userIdWidth.getText());
594 * Save Editing settings
596 Cache.applicationProperties.setProperty("AUTO_CALC_CONSENSUS",
597 Boolean.toString(autoCalculateConsCheck.isSelected()));
598 Cache.applicationProperties.setProperty("SORT_BY_TREE",
599 Boolean.toString(sortByTree.isSelected()));
600 Cache.applicationProperties.setProperty("PAD_GAPS",
601 Boolean.toString(padGaps.isSelected()));
603 dasSource.saveProperties(Cache.applicationProperties);
604 wsPrefs.updateAndRefreshWsMenuConfig(false);
605 Cache.saveProperties();
606 Desktop.instance.doConfigureStructurePrefs();
609 frame.setClosed(true);
610 } catch (Exception ex)
616 * Do any necessary validation before saving settings. Return focus to the
617 * first tab which fails validation.
621 private boolean validateSettings()
623 if (!validateStructure())
625 structureTab.requestFocusInWindow();
632 protected boolean validateStructure()
634 return validateChimeraPath();
640 public void startupFileTextfield_mouseClicked()
642 JalviewFileChooser chooser = new JalviewFileChooser(
643 jalview.bin.Cache.getProperty("LAST_DIRECTORY"),
645 { "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc", "jar" },
647 { "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview" },
648 jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT"));
649 chooser.setFileView(new JalviewFileView());
650 chooser.setDialogTitle(MessageManager.getString("label.select_startup_file"));
652 int value = chooser.showOpenDialog(this);
654 if (value == JalviewFileChooser.APPROVE_OPTION)
656 jalview.bin.Cache.applicationProperties.setProperty(
657 "DEFAULT_FILE_FORMAT", chooser.getSelectedFormat());
658 startupFileTextfield.setText(chooser.getSelectedFile()
669 public void cancel_actionPerformed(ActionEvent e)
673 wsPrefs.updateWsMenuConfig(true);
674 wsPrefs.refreshWs_actionPerformed(e);
675 frame.setClosed(true);
676 } catch (Exception ex)
687 public void annotations_actionPerformed(ActionEvent e)
689 conservation.setEnabled(annotations.isSelected());
690 quality.setEnabled(annotations.isSelected());
691 identity.setEnabled(annotations.isSelected());
692 showGroupConsensus.setEnabled(annotations.isSelected());
693 showGroupConservation.setEnabled(annotations.isSelected());
694 showConsensHistogram.setEnabled(annotations.isSelected()
695 && (identity.isSelected() || showGroupConsensus.isSelected()));
696 showConsensLogo.setEnabled(annotations.isSelected()
697 && (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());
726 public void editLink_actionPerformed(ActionEvent e)
728 GSequenceLink link = new GSequenceLink();
730 int index = linkNameList.getSelectedIndex();
733 JOptionPane.showInternalMessageDialog(Desktop.desktop,
734 MessageManager.getString("label.no_link_selected"),
735 MessageManager.getString("label.no_link_selected"),
736 JOptionPane.WARNING_MESSAGE);
740 link.setName(nameLinks.elementAt(index).toString());
741 link.setURL(urlLinks.elementAt(index).toString());
743 boolean valid = false;
747 if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
748 MessageManager.getString("label.new_sequence_url_link"),
749 JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
751 if (link.checkValid())
753 nameLinks.setElementAt(link.getName(), index);
754 urlLinks.setElementAt(link.getURL(), index);
767 public void deleteLink_actionPerformed(ActionEvent e)
769 int index = linkNameList.getSelectedIndex();
772 JOptionPane.showInternalMessageDialog(Desktop.desktop,
773 MessageManager.getString("label.no_link_selected"),
774 MessageManager.getString("label.no_link_selected"),
775 JOptionPane.WARNING_MESSAGE);
778 nameLinks.removeElementAt(index);
779 urlLinks.removeElementAt(index);
783 void updateLinkData()
785 linkNameList.setListData(nameLinks);
786 linkURLList.setListData(urlLinks);
789 public void defaultBrowser_mouseClicked(MouseEvent e)
791 JFileChooser chooser = new JFileChooser(".");
792 chooser.setDialogTitle(MessageManager.getString("label.select_default_browser"));
794 int value = chooser.showOpenDialog(this);
796 if (value == JFileChooser.APPROVE_OPTION)
798 defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath());
807 * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event
810 protected void showunconserved_actionPerformed(ActionEvent e)
812 // TODO Auto-generated method stub
813 super.showunconserved_actionPerformed(e);
816 public static Collection getGroupURLLinks()
818 return groupURLLinks;
822 public void minColour_actionPerformed(JPanel panel)
824 Color col = JColorChooser.showDialog(this,
825 MessageManager.getString("label.select_colour_minimum_value"), minColour.getBackground());
828 panel.setBackground(col);
834 public void maxColour_actionPerformed(JPanel panel)
836 Color col = JColorChooser.showDialog(this,
837 MessageManager.getString("label.select_colour_maximum_value"), maxColour.getBackground());
840 panel.setBackground(col);
846 protected void userIdWidth_actionPerformed()
850 String val = userIdWidth.getText().trim();
851 if (val.length() > 0)
853 Integer iw = Integer.parseInt(val);
854 if (iw.intValue() < 12)
856 throw new NumberFormatException();
858 userIdWidth.setText(iw.toString());
860 } catch (NumberFormatException x)
863 .showInternalMessageDialog(
865 MessageManager.getString("warn.user_defined_width_requirements"),
866 MessageManager.getString("label.invalid_id_column_width"),
867 JOptionPane.WARNING_MESSAGE);
868 userIdWidth.setText("");
873 protected void autoIdWidth_actionPerformed()
875 userIdWidth.setEnabled(!autoIdWidth.isSelected());
876 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
880 * Returns true if chimera path is to a valid executable, else show an error
883 private boolean validateChimeraPath()
885 if (chimeraPath.getText().trim().length() > 0)
887 File f = new File(chimeraPath.getText());
890 JOptionPane.showInternalMessageDialog(Desktop.desktop,
891 MessageManager.getString("label.invalid_chimera_path"),
892 MessageManager.getString("label.invalid_name"),
893 JOptionPane.ERROR_MESSAGE);
901 * If Chimera is selected, check it can be found on default or user-specified
902 * path, if not show a warning/help dialog.
905 protected void structureViewer_actionPerformed(String selectedItem)
907 if (!selectedItem.equals(ViewerType.CHIMERA.name()))
911 boolean found = false;
914 * Try user-specified and standard paths for Chimera executable.
916 List<String> paths = StructureManager.getChimeraPaths();
917 paths.add(0, chimeraPath.getText());
918 for (String path : paths)
920 if (new File(path.trim()).canExecute())
930 int showHelp = JOptionPane.showInternalOptionDialog(
932 JvSwingUtils.wrapTooltip(true,
933 MessageManager.getString("label.chimera_missing")),
934 "", JOptionPane.YES_NO_OPTION,
935 JOptionPane.WARNING_MESSAGE, null, options, options[0]);
936 if (showHelp == JOptionPane.NO_OPTION)
940 Help.showHelpWindow(HelpId.StructureViewer);
941 } catch (HelpSetException e)