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.StructureViewer.Viewer;
26 import jalview.io.JalviewFileChooser;
27 import jalview.io.JalviewFileView;
28 import jalview.jbgui.GPreferences;
29 import jalview.jbgui.GSequenceLink;
30 import jalview.schemes.ColourSchemeProperty;
31 import jalview.util.MessageManager;
33 import java.awt.BorderLayout;
34 import java.awt.Color;
35 import java.awt.Dimension;
37 import java.awt.event.ActionEvent;
38 import java.awt.event.ActionListener;
39 import java.awt.event.MouseEvent;
41 import java.util.Collection;
42 import java.util.StringTokenizer;
43 import java.util.Vector;
45 import javax.swing.JColorChooser;
46 import javax.swing.JFileChooser;
47 import javax.swing.JInternalFrame;
48 import javax.swing.JOptionPane;
49 import javax.swing.JPanel;
57 public class Preferences extends GPreferences
60 public static final String ADD_TEMPFACT_ANN = "ADD_TEMPFACT_ANN";
62 public static final String ADD_SS_ANN = "ADD_SS_ANN";
64 public static final String USE_RNAVIEW = "USE_RNAVIEW";
66 public static final String STRUCT_FROM_PDB = "STRUCT_FROM_PDB";
68 public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY";
70 public static final String CHIMERA_PATH = "CHIMERA_PATH";
72 public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS";
74 public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE";
76 private static final int MIN_FONT_SIZE = 1;
78 private static final int MAX_FONT_SIZE = 30;
81 * Holds name and link separated with | character. Sequence ID must be
82 * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$
84 public static Vector sequenceURLLinks;
87 * Holds name and link separated with | character. Sequence IDS and Sequences
88 * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and
89 * $SEQUENCES$ or $SEQUENCES=/.possible | chars ./=$ and separation character
90 * for first and second token specified after a pipe character at end |,|.
91 * (TODO: proper escape for using | to separate ids or sequences
94 public static Vector groupURLLinks;
100 "EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$");
101 sequenceURLLinks = new Vector();
105 StringTokenizer st = new StringTokenizer(string, "|");
106 while (st.hasMoreElements())
108 String name = st.nextToken();
109 String url = st.nextToken();
110 // check for '|' within a regex
111 int rxstart = url.indexOf("$SEQUENCE_ID$");
112 while (rxstart == -1 && url.indexOf("/=$") == -1)
114 url = url + "|" + st.nextToken();
116 sequenceURLLinks.addElement(name + "|" + url);
118 } catch (Exception ex)
120 System.out.println(ex + "\nError parsing sequence links");
123 // upgrade old SRS link
124 int srsPos = sequenceURLLinks
125 .indexOf("SRS|http://srs.ebi.ac.uk/srsbin/cgi-bin/wgetz?-newId+(([uniprot-all:$SEQUENCE_ID$]))+-view+SwissEntry");
130 "EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$",
136 * TODO: reformulate groupURL encoding so two or more can be stored in the
137 * .properties file as '|' separated strings
140 groupURLLinks = new Vector();
143 Vector nameLinks, urlLinks;
145 JInternalFrame frame;
147 DasSourceBrowser dasSource;
149 private WsPreferences wsPrefs;
152 * Creates a new Preferences object.
157 frame = new JInternalFrame();
158 frame.setContentPane(this);
159 dasSource = new DasSourceBrowser();
160 dasTab.add(dasSource, BorderLayout.CENTER);
161 wsPrefs = new WsPreferences();
162 wsTab.add(wsPrefs, BorderLayout.CENTER);
163 int width = 500, height = 420;
164 if (new jalview.util.Platform().isAMac())
170 Desktop.addInternalFrame(frame,
171 MessageManager.getString("label.preferences"), width, height);
172 frame.setMinimumSize(new Dimension(width, height));
175 * Set Visual tab defaults
177 seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true));
178 rightAlign.setSelected(Cache.getDefault("RIGHT_ALIGN_IDS", false));
179 fullScreen.setSelected(Cache.getDefault("SHOW_FULLSCREEN", false));
180 annotations.setSelected(Cache.getDefault("SHOW_ANNOTATIONS", true));
182 conservation.setSelected(Cache.getDefault("SHOW_CONSERVATION", true));
183 quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));
184 identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
185 openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false));
187 .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
188 showGroupConsensus.setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS",
190 showGroupConservation.setSelected(Cache.getDefault(
191 "SHOW_GROUP_CONSERVATION", false));
192 showConsensHistogram.setSelected(Cache.getDefault(
193 "SHOW_CONSENSUS_HISTOGRAM", true));
194 showConsensLogo.setSelected(Cache.getDefault("SHOW_CONSENSUS_LOGO",
196 showNpTooltip.setSelected(Cache
197 .getDefault("SHOW_NPFEATS_TOOLTIP", true));
198 showDbRefTooltip.setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP",
201 String[] fonts = java.awt.GraphicsEnvironment
202 .getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
203 for (int i = 0; i < fonts.length; i++)
205 fontNameCB.addItem(fonts[i]);
208 for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++)
210 fontSizeCB.addItem(i + "");
213 fontStyleCB.addItem("plain");
214 fontStyleCB.addItem("bold");
215 fontStyleCB.addItem("italic");
217 fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif"));
218 fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10"));
219 fontStyleCB.setSelectedItem(Cache.getDefault("FONT_STYLE", Font.PLAIN
222 smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", false));
224 idItalics.setSelected(Cache.getDefault("ID_ITALICS", true));
226 wrap.setSelected(Cache.getDefault("WRAP_ALIGNMENT", false));
228 gapSymbolCB.addItem("-");
229 gapSymbolCB.addItem(".");
231 gapSymbolCB.setSelectedItem(Cache.getDefault("GAP_SYMBOL", "-"));
233 sortby.addItem("No sort");
234 sortby.addItem("Id");
235 sortby.addItem("Pairwise Identity");
236 sortby.setSelectedItem(Cache.getDefault("SORT_ALIGNMENT", "No sort"));
238 sortAnnBy.addItem(SequenceAnnotationOrder.NONE.toString());
240 .addItem(SequenceAnnotationOrder.SEQUENCE_AND_LABEL.toString());
242 .addItem(SequenceAnnotationOrder.LABEL_AND_SEQUENCE.toString());
243 SequenceAnnotationOrder savedSort = SequenceAnnotationOrder
244 .valueOf(Cache.getDefault(SORT_ANNOTATIONS,
245 SequenceAnnotationOrder.NONE.name()));
246 sortAnnBy.setSelectedItem(savedSort.toString());
248 sortAutocalc.addItem("Autocalculated first");
249 sortAutocalc.addItem("Autocalculated last");
250 final boolean showAbove = Cache.getDefault(SHOW_AUTOCALC_ABOVE,
252 sortAutocalc.setSelectedItem(showAbove ? sortAutocalc.getItemAt(0)
253 : sortAutocalc.getItemAt(1));
255 .setSelected(Cache.getDefault("SHOW_STARTUP_FILE", true));
256 startupFileTextfield.setText(Cache.getDefault("STARTUP_FILE",
257 Cache.getDefault("www.jalview.org", "http://www.jalview.org")
258 + "/examples/exampleFile_2_3.jar"));
261 * Set Colours tab defaults
263 for (int i = ColourSchemeProperty.FIRST_COLOUR; i <= ColourSchemeProperty.LAST_COLOUR; i++)
265 colour.addItem(ColourSchemeProperty.getColourName(i));
267 String string = Cache.getDefault("DEFAULT_COLOUR", "None");
268 colour.setSelectedItem(string);
269 minColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN",
271 maxColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX",
275 * Set Structure tab defaults.
277 final boolean structSelected = Cache.getDefault(STRUCT_FROM_PDB, false);
278 structFromPdb.setSelected(structSelected);
279 useRnaView.setSelected(Cache.getDefault(USE_RNAVIEW, false));
280 useRnaView.setEnabled(structSelected);
281 addSecondaryStructure
282 .setSelected(Cache.getDefault(ADD_SS_ANN, false));
283 addSecondaryStructure.setEnabled(structSelected);
284 addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, false));
285 addTempFactor.setEnabled(structSelected);
286 structViewer.setSelectedItem(Cache.getDefault(STRUCTURE_DISPLAY,
287 Viewer.JMOL.name()));
288 chimeraPath.setText(Cache.getDefault(CHIMERA_PATH, ""));
289 chimeraPath.addActionListener(new ActionListener()
292 public void actionPerformed(ActionEvent e)
294 validateChimeraPath();
299 * Set Connections tab defaults
301 nameLinks = new Vector();
302 urlLinks = new Vector();
303 for (int i = 0; i < sequenceURLLinks.size(); i++)
305 String link = sequenceURLLinks.elementAt(i).toString();
306 nameLinks.addElement(link.substring(0, link.indexOf("|")));
307 urlLinks.addElement(link.substring(link.indexOf("|") + 1));
312 useProxy.setSelected(Cache.getDefault("USE_PROXY", false));
313 proxyServerTB.setEnabled(useProxy.isSelected());
314 proxyPortTB.setEnabled(useProxy.isSelected());
315 proxyServerTB.setText(Cache.getDefault("PROXY_SERVER", ""));
316 proxyPortTB.setText(Cache.getDefault("PROXY_PORT", ""));
318 defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
320 usagestats.setSelected(Cache.getDefault("USAGESTATS", false));
321 // note antisense here: default is true
323 .setSelected(Cache.getProperty("NOQUESTIONNAIRES") == null);
324 versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true));
327 * Set Output tab defaults
330 .addItem(MessageManager.getString("label.prompt_each_time"));
331 epsRendering.addItem(MessageManager.getString("label.lineart"));
332 epsRendering.addItem(MessageManager.getString("action.text"));
333 epsRendering.setSelectedItem(Cache.getDefault("EPS_RENDERING",
334 "Prompt each time"));
335 autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
336 userIdWidth.setEnabled(autoIdWidth.isSelected());
337 userIdWidthlabel.setEnabled(autoIdWidth.isSelected());
338 Integer wi = Cache.getIntegerProperty("FIGURE_USERIDWIDTH");
339 userIdWidth.setText(wi == null ? "" : wi.toString());
340 blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
341 clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
342 fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
343 msfjv.setSelected(Cache.getDefault("MSF_JVSUFFIX", true));
344 pfamjv.setSelected(Cache.getDefault("PFAM_JVSUFFIX", true));
345 pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true));
346 pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true));
347 modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false));
350 * Set Editing tab defaults
352 autoCalculateConsCheck.setSelected(Cache.getDefault(
353 "AUTO_CALC_CONSENSUS", true));
354 padGaps.setSelected(Cache.getDefault("PAD_GAPS", false));
355 sortByTree.setSelected(Cache.getDefault("SORT_BY_TREE", false));
357 annotations_actionPerformed(null); // update the display of the annotation
362 * Save user selections on the Preferences tabs to the Cache and write out to
367 public void ok_actionPerformed(ActionEvent e)
369 if (!validateSettings())
375 * Save Visual settings
377 Cache.applicationProperties.setProperty("SHOW_JVSUFFIX",
378 Boolean.toString(seqLimit.isSelected()));
379 Cache.applicationProperties.setProperty("RIGHT_ALIGN_IDS",
380 Boolean.toString(rightAlign.isSelected()));
381 Cache.applicationProperties.setProperty("SHOW_FULLSCREEN",
382 Boolean.toString(fullScreen.isSelected()));
383 Cache.applicationProperties.setProperty("SHOW_OVERVIEW",
384 Boolean.toString(openoverv.isSelected()));
385 Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
386 Boolean.toString(annotations.isSelected()));
387 Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
388 Boolean.toString(conservation.isSelected()));
389 Cache.applicationProperties.setProperty("SHOW_QUALITY",
390 Boolean.toString(quality.isSelected()));
391 Cache.applicationProperties.setProperty("SHOW_IDENTITY",
392 Boolean.toString(identity.isSelected()));
394 Cache.applicationProperties.setProperty("GAP_SYMBOL", gapSymbolCB
395 .getSelectedItem().toString());
397 Cache.applicationProperties.setProperty("FONT_NAME", fontNameCB
398 .getSelectedItem().toString());
399 Cache.applicationProperties.setProperty("FONT_STYLE", fontStyleCB
400 .getSelectedItem().toString());
401 Cache.applicationProperties.setProperty("FONT_SIZE", fontSizeCB
402 .getSelectedItem().toString());
404 Cache.applicationProperties.setProperty("ID_ITALICS",
405 Boolean.toString(idItalics.isSelected()));
406 Cache.applicationProperties.setProperty("SHOW_UNCONSERVED",
407 Boolean.toString(showUnconserved.isSelected()));
408 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSENSUS",
409 Boolean.toString(showGroupConsensus.isSelected()));
410 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSERVATION",
411 Boolean.toString(showGroupConservation.isSelected()));
412 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_HISTOGRAM",
413 Boolean.toString(showConsensHistogram.isSelected()));
414 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_LOGO",
415 Boolean.toString(showConsensLogo.isSelected()));
416 Cache.applicationProperties.setProperty("ANTI_ALIAS",
417 Boolean.toString(smoothFont.isSelected()));
418 Cache.applicationProperties.setProperty("SHOW_NPFEATS_TOOLTIP",
419 Boolean.toString(showNpTooltip.isSelected()));
420 Cache.applicationProperties.setProperty("SHOW_DBREFS_TOOLTIP",
421 Boolean.toString(showDbRefTooltip.isSelected()));
423 Cache.applicationProperties.setProperty("WRAP_ALIGNMENT",
424 Boolean.toString(wrap.isSelected()));
426 Cache.applicationProperties.setProperty("STARTUP_FILE",
427 startupFileTextfield.getText());
428 Cache.applicationProperties.setProperty("SHOW_STARTUP_FILE",
429 Boolean.toString(startupCheckbox.isSelected()));
431 Cache.applicationProperties.setProperty("SORT_ALIGNMENT", sortby
432 .getSelectedItem().toString());
434 // convert description of sort order to enum name for save
435 SequenceAnnotationOrder annSortOrder = SequenceAnnotationOrder
436 .forDescription(sortAnnBy.getSelectedItem().toString());
437 if (annSortOrder != null)
439 Cache.applicationProperties.setProperty(SORT_ANNOTATIONS,
440 annSortOrder.name());
443 final boolean showAutocalcFirst = sortAutocalc.getSelectedIndex() == 0;
444 Cache.applicationProperties.setProperty(SHOW_AUTOCALC_ABOVE,
445 Boolean.valueOf(showAutocalcFirst).toString());
448 * Save Colours settings
450 Cache.applicationProperties.setProperty("DEFAULT_COLOUR", colour
451 .getSelectedItem().toString());
452 Cache.setColourProperty("ANNOTATIONCOLOUR_MIN",
453 minColour.getBackground());
454 Cache.setColourProperty("ANNOTATIONCOLOUR_MAX",
455 maxColour.getBackground());
458 * Save Structure settings
460 Cache.applicationProperties.setProperty(ADD_TEMPFACT_ANN,
461 Boolean.toString(addTempFactor.isSelected()));
462 Cache.applicationProperties.setProperty(ADD_SS_ANN,
463 Boolean.toString(addSecondaryStructure.isSelected()));
464 Cache.applicationProperties.setProperty(USE_RNAVIEW,
465 Boolean.toString(useRnaView.isSelected()));
466 Cache.applicationProperties.setProperty(STRUCT_FROM_PDB,
467 Boolean.toString(structFromPdb.isSelected()));
468 Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY, structViewer
469 .getSelectedItem().toString());
470 Cache.setOrRemove(CHIMERA_PATH, chimeraPath.getText());
473 * Save Output settings
475 if (epsRendering.getSelectedItem().equals("Prompt each time"))
477 Cache.applicationProperties.remove("EPS_RENDERING");
481 Cache.applicationProperties.setProperty("EPS_RENDERING", epsRendering
482 .getSelectedItem().toString());
486 * Save Connections settings
488 Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
490 jalview.util.BrowserLauncher.resetBrowser();
492 if (nameLinks.size() > 0)
494 StringBuffer links = new StringBuffer();
495 sequenceURLLinks = new Vector();
496 for (int i = 0; i < nameLinks.size(); i++)
498 sequenceURLLinks.addElement(nameLinks.elementAt(i) + "|"
499 + urlLinks.elementAt(i));
500 links.append(sequenceURLLinks.elementAt(i).toString());
504 links.setLength(links.length() - 1);
505 Cache.applicationProperties.setProperty("SEQUENCE_LINKS",
510 Cache.applicationProperties.remove("SEQUENCE_LINKS");
513 Cache.applicationProperties.setProperty("USE_PROXY",
514 Boolean.toString(useProxy.isSelected()));
516 Cache.setOrRemove("PROXY_SERVER", proxyServerTB.getText());
518 Cache.setOrRemove("PROXY_PORT", proxyPortTB.getText());
520 if (useProxy.isSelected())
522 System.setProperty("http.proxyHost", proxyServerTB.getText());
523 System.setProperty("http.proxyPort", proxyPortTB.getText());
527 System.setProperty("http.proxyHost", "");
528 System.setProperty("http.proxyPort", "");
530 Cache.setProperty("VERSION_CHECK",
531 Boolean.toString(versioncheck.isSelected()));
532 if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
534 // default is false - we only set this if the user has actively agreed
535 Cache.setProperty("USAGESTATS",
536 Boolean.toString(usagestats.isSelected()));
538 if (!questionnaire.isSelected())
540 Cache.setProperty("NOQUESTIONNAIRES", "true");
544 // special - made easy to edit a property file to disable questionnaires
545 // by just adding the given line
546 Cache.removeProperty("NOQUESTIONNAIRES");
550 * Save Output settings
552 Cache.applicationProperties.setProperty("BLC_JVSUFFIX",
553 Boolean.toString(blcjv.isSelected()));
554 Cache.applicationProperties.setProperty("CLUSTAL_JVSUFFIX",
555 Boolean.toString(clustaljv.isSelected()));
556 Cache.applicationProperties.setProperty("FASTA_JVSUFFIX",
557 Boolean.toString(fastajv.isSelected()));
558 Cache.applicationProperties.setProperty("MSF_JVSUFFIX",
559 Boolean.toString(msfjv.isSelected()));
560 Cache.applicationProperties.setProperty("PFAM_JVSUFFIX",
561 Boolean.toString(pfamjv.isSelected()));
562 Cache.applicationProperties.setProperty("PILEUP_JVSUFFIX",
563 Boolean.toString(pileupjv.isSelected()));
564 Cache.applicationProperties.setProperty("PIR_JVSUFFIX",
565 Boolean.toString(pirjv.isSelected()));
566 Cache.applicationProperties.setProperty("PIR_MODELLER",
567 Boolean.toString(modellerOutput.isSelected()));
568 jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
570 Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH",
571 Boolean.toString(autoIdWidth.isSelected()));
572 userIdWidth_actionPerformed();
573 Cache.applicationProperties.setProperty("FIGURE_USERIDWIDTH",
574 userIdWidth.getText());
577 * Save Editing settings
579 Cache.applicationProperties.setProperty("AUTO_CALC_CONSENSUS",
580 Boolean.toString(autoCalculateConsCheck.isSelected()));
581 Cache.applicationProperties.setProperty("SORT_BY_TREE",
582 Boolean.toString(sortByTree.isSelected()));
583 Cache.applicationProperties.setProperty("PAD_GAPS",
584 Boolean.toString(padGaps.isSelected()));
586 dasSource.saveProperties(Cache.applicationProperties);
587 wsPrefs.updateAndRefreshWsMenuConfig(false);
588 Cache.saveProperties();
589 Desktop.instance.doConfigureStructurePrefs();
592 frame.setClosed(true);
593 } catch (Exception ex)
599 * Do any necessary validation before saving settings.
603 private boolean validateSettings()
605 if (!validateStructure())
607 structureTab.requestFocusInWindow();
614 protected boolean validateStructure()
616 return validateChimeraPath();
622 public void startupFileTextfield_mouseClicked()
624 JalviewFileChooser chooser = new JalviewFileChooser(
625 jalview.bin.Cache.getProperty("LAST_DIRECTORY"),
627 { "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc", "jar" },
629 { "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview" },
630 jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT"));
631 chooser.setFileView(new JalviewFileView());
632 chooser.setDialogTitle(MessageManager.getString("label.select_startup_file"));
634 int value = chooser.showOpenDialog(this);
636 if (value == JalviewFileChooser.APPROVE_OPTION)
638 jalview.bin.Cache.applicationProperties.setProperty(
639 "DEFAULT_FILE_FORMAT", chooser.getSelectedFormat());
640 startupFileTextfield.setText(chooser.getSelectedFile()
651 public void cancel_actionPerformed(ActionEvent e)
655 wsPrefs.updateWsMenuConfig(true);
656 wsPrefs.refreshWs_actionPerformed(e);
657 frame.setClosed(true);
658 } catch (Exception ex)
669 public void annotations_actionPerformed(ActionEvent e)
671 conservation.setEnabled(annotations.isSelected());
672 quality.setEnabled(annotations.isSelected());
673 identity.setEnabled(annotations.isSelected());
674 showGroupConsensus.setEnabled(annotations.isSelected());
675 showGroupConservation.setEnabled(annotations.isSelected());
676 showConsensHistogram.setEnabled(annotations.isSelected()
677 && (identity.isSelected() || showGroupConsensus.isSelected()));
678 showConsensLogo.setEnabled(annotations.isSelected()
679 && (identity.isSelected() || showGroupConsensus.isSelected()));
682 public void newLink_actionPerformed(ActionEvent e)
685 GSequenceLink link = new GSequenceLink();
686 boolean valid = false;
689 if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
690 MessageManager.getString("label.new_sequence_url_link"),
691 JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
693 if (link.checkValid())
695 nameLinks.addElement(link.getName());
696 urlLinks.addElement(link.getURL());
708 public void editLink_actionPerformed(ActionEvent e)
710 GSequenceLink link = new GSequenceLink();
712 int index = linkNameList.getSelectedIndex();
715 JOptionPane.showInternalMessageDialog(Desktop.desktop,
716 MessageManager.getString("label.no_link_selected"),
717 MessageManager.getString("label.no_link_selected"),
718 JOptionPane.WARNING_MESSAGE);
722 link.setName(nameLinks.elementAt(index).toString());
723 link.setURL(urlLinks.elementAt(index).toString());
725 boolean valid = false;
729 if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
730 MessageManager.getString("label.new_sequence_url_link"),
731 JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
733 if (link.checkValid())
735 nameLinks.setElementAt(link.getName(), index);
736 urlLinks.setElementAt(link.getURL(), index);
749 public void deleteLink_actionPerformed(ActionEvent e)
751 int index = linkNameList.getSelectedIndex();
754 JOptionPane.showInternalMessageDialog(Desktop.desktop,
755 MessageManager.getString("label.no_link_selected"),
756 MessageManager.getString("label.no_link_selected"),
757 JOptionPane.WARNING_MESSAGE);
760 nameLinks.removeElementAt(index);
761 urlLinks.removeElementAt(index);
765 void updateLinkData()
767 linkNameList.setListData(nameLinks);
768 linkURLList.setListData(urlLinks);
771 public void defaultBrowser_mouseClicked(MouseEvent e)
773 JFileChooser chooser = new JFileChooser(".");
774 chooser.setDialogTitle(MessageManager.getString("label.select_default_browser"));
776 int value = chooser.showOpenDialog(this);
778 if (value == JFileChooser.APPROVE_OPTION)
780 defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath());
789 * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event
792 protected void showunconserved_actionPerformed(ActionEvent e)
794 // TODO Auto-generated method stub
795 super.showunconserved_actionPerformed(e);
798 public static Collection getGroupURLLinks()
800 return groupURLLinks;
804 public void minColour_actionPerformed(JPanel panel)
806 Color col = JColorChooser.showDialog(this,
807 MessageManager.getString("label.select_colour_minimum_value"), minColour.getBackground());
810 panel.setBackground(col);
816 public void maxColour_actionPerformed(JPanel panel)
818 Color col = JColorChooser.showDialog(this,
819 MessageManager.getString("label.select_colour_maximum_value"), maxColour.getBackground());
822 panel.setBackground(col);
828 protected void userIdWidth_actionPerformed()
832 String val = userIdWidth.getText().trim();
833 if (val.length() > 0)
835 Integer iw = Integer.parseInt(val);
836 if (iw.intValue() < 12)
838 throw new NumberFormatException();
840 userIdWidth.setText(iw.toString());
842 } catch (NumberFormatException x)
845 .showInternalMessageDialog(
847 MessageManager.getString("warn.user_defined_width_requirements"),
848 MessageManager.getString("label.invalid_id_column_width"),
849 JOptionPane.WARNING_MESSAGE);
850 userIdWidth.setText("");
855 protected void autoIdWidth_actionPerformed()
857 userIdWidth.setEnabled(!autoIdWidth.isSelected());
858 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
862 * Returns true if chimera path is to a valid executable, else show an error
865 private boolean validateChimeraPath()
867 if (chimeraPath.getText().trim().length() > 0)
869 File f = new File(chimeraPath.getText());
872 JOptionPane.showInternalMessageDialog(Desktop.desktop,
873 MessageManager.getString("label.invalid_chimera_path"),
874 MessageManager.getString("label.invalid_name"),
875 JOptionPane.ERROR_MESSAGE);