2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 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.Viewer;
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 ADD_TEMPFACT_ANN = "ADD_TEMPFACT_ANN";
67 public static final String ADD_SS_ANN = "ADD_SS_ANN";
69 public static final String USE_RNAVIEW = "USE_RNAVIEW";
71 public static final String STRUCT_FROM_PDB = "STRUCT_FROM_PDB";
73 public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY";
75 public static final String CHIMERA_PATH = "CHIMERA_PATH";
77 public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS";
79 public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE";
81 private static final int MIN_FONT_SIZE = 1;
83 private static final int MAX_FONT_SIZE = 30;
86 * Holds name and link separated with | character. Sequence ID must be
87 * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$
89 public static Vector sequenceURLLinks;
92 * Holds name and link separated with | character. Sequence IDS and Sequences
93 * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and
94 * $SEQUENCES$ or $SEQUENCES=/.possible | chars ./=$ and separation character
95 * for first and second token specified after a pipe character at end |,|.
96 * (TODO: proper escape for using | to separate ids or sequences
99 public static Vector groupURLLinks;
102 String string = Cache
105 "EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$");
106 sequenceURLLinks = new Vector();
110 StringTokenizer st = new StringTokenizer(string, "|");
111 while (st.hasMoreElements())
113 String name = st.nextToken();
114 String url = st.nextToken();
115 // check for '|' within a regex
116 int rxstart = url.indexOf("$SEQUENCE_ID$");
117 while (rxstart == -1 && url.indexOf("/=$") == -1)
119 url = url + "|" + st.nextToken();
121 sequenceURLLinks.addElement(name + "|" + url);
123 } catch (Exception ex)
125 System.out.println(ex + "\nError parsing sequence links");
128 // upgrade old SRS link
129 int srsPos = sequenceURLLinks
130 .indexOf("SRS|http://srs.ebi.ac.uk/srsbin/cgi-bin/wgetz?-newId+(([uniprot-all:$SEQUENCE_ID$]))+-view+SwissEntry");
135 "EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$",
141 * TODO: reformulate groupURL encoding so two or more can be stored in the
142 * .properties file as '|' separated strings
145 groupURLLinks = new Vector();
148 Vector nameLinks, urlLinks;
150 JInternalFrame frame;
152 DasSourceBrowser dasSource;
154 private WsPreferences wsPrefs;
157 * Creates a new Preferences object.
162 frame = new JInternalFrame();
163 frame.setContentPane(this);
164 dasSource = new DasSourceBrowser();
165 dasTab.add(dasSource, BorderLayout.CENTER);
166 wsPrefs = new WsPreferences();
167 wsTab.add(wsPrefs, BorderLayout.CENTER);
168 int width = 500, height = 420;
169 if (new jalview.util.Platform().isAMac())
175 Desktop.addInternalFrame(frame,
176 MessageManager.getString("label.preferences"), width, height);
177 frame.setMinimumSize(new Dimension(width, height));
180 * Set Visual tab defaults
182 seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true));
183 rightAlign.setSelected(Cache.getDefault("RIGHT_ALIGN_IDS", false));
184 fullScreen.setSelected(Cache.getDefault("SHOW_FULLSCREEN", false));
185 annotations.setSelected(Cache.getDefault("SHOW_ANNOTATIONS", true));
187 conservation.setSelected(Cache.getDefault("SHOW_CONSERVATION", true));
188 quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));
189 identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
190 openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false));
192 .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
193 showGroupConsensus.setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS",
195 showGroupConservation.setSelected(Cache.getDefault(
196 "SHOW_GROUP_CONSERVATION", false));
197 showConsensHistogram.setSelected(Cache.getDefault(
198 "SHOW_CONSENSUS_HISTOGRAM", true));
199 showConsensLogo.setSelected(Cache.getDefault("SHOW_CONSENSUS_LOGO",
201 showNpTooltip.setSelected(Cache
202 .getDefault("SHOW_NPFEATS_TOOLTIP", true));
203 showDbRefTooltip.setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP",
206 String[] fonts = java.awt.GraphicsEnvironment
207 .getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
208 for (int i = 0; i < fonts.length; i++)
210 fontNameCB.addItem(fonts[i]);
213 for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++)
215 fontSizeCB.addItem(i + "");
218 fontStyleCB.addItem("plain");
219 fontStyleCB.addItem("bold");
220 fontStyleCB.addItem("italic");
222 fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif"));
223 fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10"));
224 fontStyleCB.setSelectedItem(Cache.getDefault("FONT_STYLE", Font.PLAIN
227 smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", false));
229 idItalics.setSelected(Cache.getDefault("ID_ITALICS", true));
231 wrap.setSelected(Cache.getDefault("WRAP_ALIGNMENT", false));
233 gapSymbolCB.addItem("-");
234 gapSymbolCB.addItem(".");
236 gapSymbolCB.setSelectedItem(Cache.getDefault("GAP_SYMBOL", "-"));
238 sortby.addItem("No sort");
239 sortby.addItem("Id");
240 sortby.addItem("Pairwise Identity");
241 sortby.setSelectedItem(Cache.getDefault("SORT_ALIGNMENT", "No sort"));
243 sortAnnBy.addItem(SequenceAnnotationOrder.NONE.toString());
245 .addItem(SequenceAnnotationOrder.SEQUENCE_AND_LABEL.toString());
247 .addItem(SequenceAnnotationOrder.LABEL_AND_SEQUENCE.toString());
248 SequenceAnnotationOrder savedSort = SequenceAnnotationOrder
249 .valueOf(Cache.getDefault(SORT_ANNOTATIONS,
250 SequenceAnnotationOrder.NONE.name()));
251 sortAnnBy.setSelectedItem(savedSort.toString());
253 sortAutocalc.addItem("Autocalculated first");
254 sortAutocalc.addItem("Autocalculated last");
255 final boolean showAbove = Cache.getDefault(SHOW_AUTOCALC_ABOVE,
257 sortAutocalc.setSelectedItem(showAbove ? sortAutocalc.getItemAt(0)
258 : sortAutocalc.getItemAt(1));
260 .setSelected(Cache.getDefault("SHOW_STARTUP_FILE", true));
261 startupFileTextfield.setText(Cache.getDefault("STARTUP_FILE",
262 Cache.getDefault("www.jalview.org", "http://www.jalview.org")
263 + "/examples/exampleFile_2_3.jar"));
266 * Set Colours tab defaults
268 for (int i = ColourSchemeProperty.FIRST_COLOUR; i <= ColourSchemeProperty.LAST_COLOUR; i++)
270 colour.addItem(ColourSchemeProperty.getColourName(i));
272 String string = Cache.getDefault("DEFAULT_COLOUR", "None");
273 colour.setSelectedItem(string);
274 minColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN",
276 maxColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX",
280 * Set Structure tab defaults.
282 final boolean structSelected = Cache.getDefault(STRUCT_FROM_PDB, false);
283 structFromPdb.setSelected(structSelected);
284 useRnaView.setSelected(Cache.getDefault(USE_RNAVIEW, false));
285 useRnaView.setEnabled(structSelected);
286 addSecondaryStructure
287 .setSelected(Cache.getDefault(ADD_SS_ANN, false));
288 addSecondaryStructure.setEnabled(structSelected);
289 addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, false));
290 addTempFactor.setEnabled(structSelected);
291 structViewer.setSelectedItem(Cache.getDefault(STRUCTURE_DISPLAY,
292 Viewer.JMOL.name()));
293 chimeraPath.setText(Cache.getDefault(CHIMERA_PATH, ""));
294 chimeraPath.addActionListener(new ActionListener()
297 public void actionPerformed(ActionEvent e)
299 validateChimeraPath();
304 * Set Connections tab defaults
306 nameLinks = new Vector();
307 urlLinks = new Vector();
308 for (int i = 0; i < sequenceURLLinks.size(); i++)
310 String link = sequenceURLLinks.elementAt(i).toString();
311 nameLinks.addElement(link.substring(0, link.indexOf("|")));
312 urlLinks.addElement(link.substring(link.indexOf("|") + 1));
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
335 .addItem(MessageManager.getString("label.prompt_each_time"));
336 epsRendering.addItem(MessageManager.getString("label.lineart"));
337 epsRendering.addItem(MessageManager.getString("action.text"));
338 epsRendering.setSelectedItem(Cache.getDefault("EPS_RENDERING",
339 "Prompt each time"));
340 autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
341 userIdWidth.setEnabled(autoIdWidth.isSelected());
342 userIdWidthlabel.setEnabled(autoIdWidth.isSelected());
343 Integer wi = Cache.getIntegerProperty("FIGURE_USERIDWIDTH");
344 userIdWidth.setText(wi == null ? "" : wi.toString());
345 blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
346 clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
347 fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
348 msfjv.setSelected(Cache.getDefault("MSF_JVSUFFIX", true));
349 pfamjv.setSelected(Cache.getDefault("PFAM_JVSUFFIX", true));
350 pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true));
351 pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true));
352 modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false));
355 * Set Editing tab defaults
357 autoCalculateConsCheck.setSelected(Cache.getDefault(
358 "AUTO_CALC_CONSENSUS", true));
359 padGaps.setSelected(Cache.getDefault("PAD_GAPS", false));
360 sortByTree.setSelected(Cache.getDefault("SORT_BY_TREE", false));
362 annotations_actionPerformed(null); // update the display of the annotation
367 * Save user selections on the Preferences tabs to the Cache and write out to
372 public void ok_actionPerformed(ActionEvent e)
374 if (!validateSettings())
380 * Save Visual settings
382 Cache.applicationProperties.setProperty("SHOW_JVSUFFIX",
383 Boolean.toString(seqLimit.isSelected()));
384 Cache.applicationProperties.setProperty("RIGHT_ALIGN_IDS",
385 Boolean.toString(rightAlign.isSelected()));
386 Cache.applicationProperties.setProperty("SHOW_FULLSCREEN",
387 Boolean.toString(fullScreen.isSelected()));
388 Cache.applicationProperties.setProperty("SHOW_OVERVIEW",
389 Boolean.toString(openoverv.isSelected()));
390 Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
391 Boolean.toString(annotations.isSelected()));
392 Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
393 Boolean.toString(conservation.isSelected()));
394 Cache.applicationProperties.setProperty("SHOW_QUALITY",
395 Boolean.toString(quality.isSelected()));
396 Cache.applicationProperties.setProperty("SHOW_IDENTITY",
397 Boolean.toString(identity.isSelected()));
399 Cache.applicationProperties.setProperty("GAP_SYMBOL", gapSymbolCB
400 .getSelectedItem().toString());
402 Cache.applicationProperties.setProperty("FONT_NAME", fontNameCB
403 .getSelectedItem().toString());
404 Cache.applicationProperties.setProperty("FONT_STYLE", fontStyleCB
405 .getSelectedItem().toString());
406 Cache.applicationProperties.setProperty("FONT_SIZE", fontSizeCB
407 .getSelectedItem().toString());
409 Cache.applicationProperties.setProperty("ID_ITALICS",
410 Boolean.toString(idItalics.isSelected()));
411 Cache.applicationProperties.setProperty("SHOW_UNCONSERVED",
412 Boolean.toString(showUnconserved.isSelected()));
413 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSENSUS",
414 Boolean.toString(showGroupConsensus.isSelected()));
415 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSERVATION",
416 Boolean.toString(showGroupConservation.isSelected()));
417 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_HISTOGRAM",
418 Boolean.toString(showConsensHistogram.isSelected()));
419 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_LOGO",
420 Boolean.toString(showConsensLogo.isSelected()));
421 Cache.applicationProperties.setProperty("ANTI_ALIAS",
422 Boolean.toString(smoothFont.isSelected()));
423 Cache.applicationProperties.setProperty("SHOW_NPFEATS_TOOLTIP",
424 Boolean.toString(showNpTooltip.isSelected()));
425 Cache.applicationProperties.setProperty("SHOW_DBREFS_TOOLTIP",
426 Boolean.toString(showDbRefTooltip.isSelected()));
428 Cache.applicationProperties.setProperty("WRAP_ALIGNMENT",
429 Boolean.toString(wrap.isSelected()));
431 Cache.applicationProperties.setProperty("STARTUP_FILE",
432 startupFileTextfield.getText());
433 Cache.applicationProperties.setProperty("SHOW_STARTUP_FILE",
434 Boolean.toString(startupCheckbox.isSelected()));
436 Cache.applicationProperties.setProperty("SORT_ALIGNMENT", sortby
437 .getSelectedItem().toString());
439 // convert description of sort order to enum name for save
440 SequenceAnnotationOrder annSortOrder = SequenceAnnotationOrder
441 .forDescription(sortAnnBy.getSelectedItem().toString());
442 if (annSortOrder != null)
444 Cache.applicationProperties.setProperty(SORT_ANNOTATIONS,
445 annSortOrder.name());
448 final boolean showAutocalcFirst = sortAutocalc.getSelectedIndex() == 0;
449 Cache.applicationProperties.setProperty(SHOW_AUTOCALC_ABOVE,
450 Boolean.valueOf(showAutocalcFirst).toString());
453 * Save Colours settings
455 Cache.applicationProperties.setProperty("DEFAULT_COLOUR", colour
456 .getSelectedItem().toString());
457 Cache.setColourProperty("ANNOTATIONCOLOUR_MIN",
458 minColour.getBackground());
459 Cache.setColourProperty("ANNOTATIONCOLOUR_MAX",
460 maxColour.getBackground());
463 * Save Structure settings
465 Cache.applicationProperties.setProperty(ADD_TEMPFACT_ANN,
466 Boolean.toString(addTempFactor.isSelected()));
467 Cache.applicationProperties.setProperty(ADD_SS_ANN,
468 Boolean.toString(addSecondaryStructure.isSelected()));
469 Cache.applicationProperties.setProperty(USE_RNAVIEW,
470 Boolean.toString(useRnaView.isSelected()));
471 Cache.applicationProperties.setProperty(STRUCT_FROM_PDB,
472 Boolean.toString(structFromPdb.isSelected()));
473 Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY, structViewer
474 .getSelectedItem().toString());
475 Cache.setOrRemove(CHIMERA_PATH, chimeraPath.getText());
478 * Save Output settings
480 if (epsRendering.getSelectedItem().equals("Prompt each time"))
482 Cache.applicationProperties.remove("EPS_RENDERING");
486 Cache.applicationProperties.setProperty("EPS_RENDERING", epsRendering
487 .getSelectedItem().toString());
491 * Save Connections settings
493 Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
495 jalview.util.BrowserLauncher.resetBrowser();
497 if (nameLinks.size() > 0)
499 StringBuffer links = new StringBuffer();
500 sequenceURLLinks = new Vector();
501 for (int i = 0; i < nameLinks.size(); i++)
503 sequenceURLLinks.addElement(nameLinks.elementAt(i) + "|"
504 + urlLinks.elementAt(i));
505 links.append(sequenceURLLinks.elementAt(i).toString());
509 links.setLength(links.length() - 1);
510 Cache.applicationProperties.setProperty("SEQUENCE_LINKS",
515 Cache.applicationProperties.remove("SEQUENCE_LINKS");
518 Cache.applicationProperties.setProperty("USE_PROXY",
519 Boolean.toString(useProxy.isSelected()));
521 Cache.setOrRemove("PROXY_SERVER", proxyServerTB.getText());
523 Cache.setOrRemove("PROXY_PORT", proxyPortTB.getText());
525 if (useProxy.isSelected())
527 System.setProperty("http.proxyHost", proxyServerTB.getText());
528 System.setProperty("http.proxyPort", proxyPortTB.getText());
532 System.setProperty("http.proxyHost", "");
533 System.setProperty("http.proxyPort", "");
535 Cache.setProperty("VERSION_CHECK",
536 Boolean.toString(versioncheck.isSelected()));
537 if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
539 // default is false - we only set this if the user has actively agreed
540 Cache.setProperty("USAGESTATS",
541 Boolean.toString(usagestats.isSelected()));
543 if (!questionnaire.isSelected())
545 Cache.setProperty("NOQUESTIONNAIRES", "true");
549 // special - made easy to edit a property file to disable questionnaires
550 // by just adding the given line
551 Cache.removeProperty("NOQUESTIONNAIRES");
555 * Save Output settings
557 Cache.applicationProperties.setProperty("BLC_JVSUFFIX",
558 Boolean.toString(blcjv.isSelected()));
559 Cache.applicationProperties.setProperty("CLUSTAL_JVSUFFIX",
560 Boolean.toString(clustaljv.isSelected()));
561 Cache.applicationProperties.setProperty("FASTA_JVSUFFIX",
562 Boolean.toString(fastajv.isSelected()));
563 Cache.applicationProperties.setProperty("MSF_JVSUFFIX",
564 Boolean.toString(msfjv.isSelected()));
565 Cache.applicationProperties.setProperty("PFAM_JVSUFFIX",
566 Boolean.toString(pfamjv.isSelected()));
567 Cache.applicationProperties.setProperty("PILEUP_JVSUFFIX",
568 Boolean.toString(pileupjv.isSelected()));
569 Cache.applicationProperties.setProperty("PIR_JVSUFFIX",
570 Boolean.toString(pirjv.isSelected()));
571 Cache.applicationProperties.setProperty("PIR_MODELLER",
572 Boolean.toString(modellerOutput.isSelected()));
573 jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
575 Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH",
576 Boolean.toString(autoIdWidth.isSelected()));
577 userIdWidth_actionPerformed();
578 Cache.applicationProperties.setProperty("FIGURE_USERIDWIDTH",
579 userIdWidth.getText());
582 * Save Editing settings
584 Cache.applicationProperties.setProperty("AUTO_CALC_CONSENSUS",
585 Boolean.toString(autoCalculateConsCheck.isSelected()));
586 Cache.applicationProperties.setProperty("SORT_BY_TREE",
587 Boolean.toString(sortByTree.isSelected()));
588 Cache.applicationProperties.setProperty("PAD_GAPS",
589 Boolean.toString(padGaps.isSelected()));
591 dasSource.saveProperties(Cache.applicationProperties);
592 wsPrefs.updateAndRefreshWsMenuConfig(false);
593 Cache.saveProperties();
594 Desktop.instance.doConfigureStructurePrefs();
597 frame.setClosed(true);
598 } catch (Exception ex)
604 * Do any necessary validation before saving settings. Return focus to the
605 * first tab which fails validation.
609 private boolean validateSettings()
611 if (!validateStructure())
613 structureTab.requestFocusInWindow();
620 protected boolean validateStructure()
622 return validateChimeraPath();
628 public void startupFileTextfield_mouseClicked()
630 JalviewFileChooser chooser = new JalviewFileChooser(
631 jalview.bin.Cache.getProperty("LAST_DIRECTORY"),
633 { "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc", "jar" },
635 { "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview" },
636 jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT"));
637 chooser.setFileView(new JalviewFileView());
638 chooser.setDialogTitle(MessageManager.getString("label.select_startup_file"));
640 int value = chooser.showOpenDialog(this);
642 if (value == JalviewFileChooser.APPROVE_OPTION)
644 jalview.bin.Cache.applicationProperties.setProperty(
645 "DEFAULT_FILE_FORMAT", chooser.getSelectedFormat());
646 startupFileTextfield.setText(chooser.getSelectedFile()
657 public void cancel_actionPerformed(ActionEvent e)
661 wsPrefs.updateWsMenuConfig(true);
662 wsPrefs.refreshWs_actionPerformed(e);
663 frame.setClosed(true);
664 } catch (Exception ex)
675 public void annotations_actionPerformed(ActionEvent e)
677 conservation.setEnabled(annotations.isSelected());
678 quality.setEnabled(annotations.isSelected());
679 identity.setEnabled(annotations.isSelected());
680 showGroupConsensus.setEnabled(annotations.isSelected());
681 showGroupConservation.setEnabled(annotations.isSelected());
682 showConsensHistogram.setEnabled(annotations.isSelected()
683 && (identity.isSelected() || showGroupConsensus.isSelected()));
684 showConsensLogo.setEnabled(annotations.isSelected()
685 && (identity.isSelected() || showGroupConsensus.isSelected()));
688 public void newLink_actionPerformed(ActionEvent e)
691 GSequenceLink link = new GSequenceLink();
692 boolean valid = false;
695 if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
696 MessageManager.getString("label.new_sequence_url_link"),
697 JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
699 if (link.checkValid())
701 nameLinks.addElement(link.getName());
702 urlLinks.addElement(link.getURL());
714 public void editLink_actionPerformed(ActionEvent e)
716 GSequenceLink link = new GSequenceLink();
718 int index = linkNameList.getSelectedIndex();
721 JOptionPane.showInternalMessageDialog(Desktop.desktop,
722 MessageManager.getString("label.no_link_selected"),
723 MessageManager.getString("label.no_link_selected"),
724 JOptionPane.WARNING_MESSAGE);
728 link.setName(nameLinks.elementAt(index).toString());
729 link.setURL(urlLinks.elementAt(index).toString());
731 boolean valid = false;
735 if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
736 MessageManager.getString("label.new_sequence_url_link"),
737 JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
739 if (link.checkValid())
741 nameLinks.setElementAt(link.getName(), index);
742 urlLinks.setElementAt(link.getURL(), index);
755 public void deleteLink_actionPerformed(ActionEvent e)
757 int index = linkNameList.getSelectedIndex();
760 JOptionPane.showInternalMessageDialog(Desktop.desktop,
761 MessageManager.getString("label.no_link_selected"),
762 MessageManager.getString("label.no_link_selected"),
763 JOptionPane.WARNING_MESSAGE);
766 nameLinks.removeElementAt(index);
767 urlLinks.removeElementAt(index);
771 void updateLinkData()
773 linkNameList.setListData(nameLinks);
774 linkURLList.setListData(urlLinks);
777 public void defaultBrowser_mouseClicked(MouseEvent e)
779 JFileChooser chooser = new JFileChooser(".");
780 chooser.setDialogTitle(MessageManager.getString("label.select_default_browser"));
782 int value = chooser.showOpenDialog(this);
784 if (value == JFileChooser.APPROVE_OPTION)
786 defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath());
795 * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event
798 protected void showunconserved_actionPerformed(ActionEvent e)
800 // TODO Auto-generated method stub
801 super.showunconserved_actionPerformed(e);
804 public static Collection getGroupURLLinks()
806 return groupURLLinks;
810 public void minColour_actionPerformed(JPanel panel)
812 Color col = JColorChooser.showDialog(this,
813 MessageManager.getString("label.select_colour_minimum_value"), minColour.getBackground());
816 panel.setBackground(col);
822 public void maxColour_actionPerformed(JPanel panel)
824 Color col = JColorChooser.showDialog(this,
825 MessageManager.getString("label.select_colour_maximum_value"), maxColour.getBackground());
828 panel.setBackground(col);
834 protected void userIdWidth_actionPerformed()
838 String val = userIdWidth.getText().trim();
839 if (val.length() > 0)
841 Integer iw = Integer.parseInt(val);
842 if (iw.intValue() < 12)
844 throw new NumberFormatException();
846 userIdWidth.setText(iw.toString());
848 } catch (NumberFormatException x)
851 .showInternalMessageDialog(
853 MessageManager.getString("warn.user_defined_width_requirements"),
854 MessageManager.getString("label.invalid_id_column_width"),
855 JOptionPane.WARNING_MESSAGE);
856 userIdWidth.setText("");
861 protected void autoIdWidth_actionPerformed()
863 userIdWidth.setEnabled(!autoIdWidth.isSelected());
864 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
868 * Returns true if chimera path is to a valid executable, else show an error
871 private boolean validateChimeraPath()
873 if (chimeraPath.getText().trim().length() > 0)
875 File f = new File(chimeraPath.getText());
878 JOptionPane.showInternalMessageDialog(Desktop.desktop,
879 MessageManager.getString("label.invalid_chimera_path"),
880 MessageManager.getString("label.invalid_name"),
881 JOptionPane.ERROR_MESSAGE);
889 * If Chimera is selected, check it can be found on default or user-specified
890 * path, if not show a warning/help dialog.
893 protected void structureViewer_actionPerformed(String selectedItem)
895 if (!selectedItem.equals(Viewer.CHIMERA.name()))
899 boolean found = false;
902 * Try user-specified and standard paths for Chimera executable.
904 List<String> paths = StructureManager.getChimeraPaths();
905 paths.add(0, chimeraPath.getText());
906 for (String path : paths)
908 if (new File(path.trim()).canExecute())
918 int showHelp = JOptionPane.showInternalOptionDialog(
920 JvSwingUtils.wrapTooltip(true,
921 MessageManager.getString("label.chimera_missing")),
922 "", JOptionPane.YES_NO_OPTION,
923 JOptionPane.WARNING_MESSAGE, null, options, options[0]);
924 if (showHelp == JOptionPane.NO_OPTION)
928 Help.showHelpWindow(HelpId.StructureViewer);
929 } catch (HelpSetException e)