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.urls.DesktopUrlProviderFactory;
33 import jalview.urls.UrlLinkTableModel;
34 import jalview.urls.UrlProviderFactoryI;
35 import jalview.urls.UrlProviderI;
36 import jalview.util.MessageManager;
37 import jalview.util.Platform;
38 import jalview.util.UrlConstants;
39 import jalview.ws.sifts.SiftsSettings;
41 import java.awt.BorderLayout;
42 import java.awt.Color;
43 import java.awt.Component;
44 import java.awt.Dimension;
46 import java.awt.event.ActionEvent;
47 import java.awt.event.ActionListener;
48 import java.awt.event.MouseEvent;
50 import java.util.ArrayList;
51 import java.util.List;
53 import javax.help.HelpSetException;
54 import javax.swing.JColorChooser;
55 import javax.swing.JFileChooser;
56 import javax.swing.JInternalFrame;
57 import javax.swing.JOptionPane;
58 import javax.swing.JPanel;
59 import javax.swing.ListSelectionModel;
60 import javax.swing.RowFilter;
61 import javax.swing.RowSorter;
62 import javax.swing.SortOrder;
63 import javax.swing.event.DocumentEvent;
64 import javax.swing.event.DocumentListener;
65 import javax.swing.event.ListSelectionEvent;
66 import javax.swing.event.ListSelectionListener;
67 import javax.swing.table.TableCellRenderer;
68 import javax.swing.table.TableColumn;
69 import javax.swing.table.TableModel;
70 import javax.swing.table.TableRowSorter;
72 import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
80 public class Preferences extends GPreferences
82 public static final String ENABLE_SPLIT_FRAME = "ENABLE_SPLIT_FRAME";
84 public static final String SCALE_PROTEIN_TO_CDNA = "SCALE_PROTEIN_TO_CDNA";
86 public static final String DEFAULT_COLOUR = "DEFAULT_COLOUR";
88 public static final String DEFAULT_COLOUR_PROT = "DEFAULT_COLOUR_PROT";
90 public static final String DEFAULT_COLOUR_NUC = "DEFAULT_COLOUR_NUC";
92 public static final String ADD_TEMPFACT_ANN = "ADD_TEMPFACT_ANN";
94 public static final String ADD_SS_ANN = "ADD_SS_ANN";
96 public static final String USE_RNAVIEW = "USE_RNAVIEW";
98 public static final String STRUCT_FROM_PDB = "STRUCT_FROM_PDB";
100 public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY";
102 public static final String CHIMERA_PATH = "CHIMERA_PATH";
104 public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS";
106 public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE";
108 private static final int MIN_FONT_SIZE = 1;
110 private static final int MAX_FONT_SIZE = 30;
113 * Holds name and link separated with | character. Sequence ID must be
114 * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$
116 public static UrlProviderI sequenceUrlLinks;
118 public static UrlLinkTableModel dataModel;
121 * Holds name and link separated with | character. Sequence IDS and Sequences
122 * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and
123 * $SEQUENCES$ or $SEQUENCES=/.possible | chars ./=$ and separation character
124 * for first and second token specified after a pipe character at end |,|.
125 * (TODO: proper escape for using | to separate ids or sequences
128 public static List<String> groupURLLinks;
131 String string = Cache.getDefault("SEQUENCE_LINKS",
132 UrlConstants.DEFAULT_STRING);
133 UrlProviderFactoryI factory = new DesktopUrlProviderFactory(
134 UrlConstants.DEFAULT_LABEL, string);
135 sequenceUrlLinks = factory.createUrlProvider();
136 dataModel = new UrlLinkTableModel(sequenceUrlLinks);
139 * TODO: reformulate groupURL encoding so two or more can be stored in the
140 * .properties file as '|' separated strings
143 groupURLLinks = new ArrayList<String>();
146 JInternalFrame frame;
148 DasSourceBrowser dasSource;
150 private WsPreferences wsPrefs;
152 private OptionsParam promptEachTimeOpt = new OptionsParam(
153 MessageManager.getString("label.prompt_each_time"),
156 private OptionsParam lineArtOpt = new OptionsParam(
157 MessageManager.getString("label.lineart"), "Lineart");
159 private OptionsParam textOpt = new OptionsParam(
160 MessageManager.getString("action.text"), "Text");
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 = 450;
175 new jalview.util.Platform();
176 if (Platform.isAMac())
182 Desktop.addInternalFrame(frame,
183 MessageManager.getString("label.preferences"), width, height);
184 frame.setMinimumSize(new Dimension(width, height));
187 * Set Visual tab defaults
189 seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true));
190 rightAlign.setSelected(Cache.getDefault("RIGHT_ALIGN_IDS", false));
191 fullScreen.setSelected(Cache.getDefault("SHOW_FULLSCREEN", false));
192 annotations.setSelected(Cache.getDefault("SHOW_ANNOTATIONS", true));
194 conservation.setSelected(Cache.getDefault("SHOW_CONSERVATION", true));
195 quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));
196 identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
197 openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false));
199 .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
200 showGroupConsensus.setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS",
202 showGroupConservation.setSelected(Cache.getDefault(
203 "SHOW_GROUP_CONSERVATION", false));
204 showConsensHistogram.setSelected(Cache.getDefault(
205 "SHOW_CONSENSUS_HISTOGRAM", true));
206 showConsensLogo.setSelected(Cache.getDefault("SHOW_CONSENSUS_LOGO",
208 showNpTooltip.setSelected(Cache
209 .getDefault("SHOW_NPFEATS_TOOLTIP", true));
210 showDbRefTooltip.setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP",
213 String[] fonts = java.awt.GraphicsEnvironment
214 .getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
215 for (int i = 0; i < fonts.length; i++)
217 fontNameCB.addItem(fonts[i]);
220 for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++)
222 fontSizeCB.addItem(i + "");
225 fontStyleCB.addItem("plain");
226 fontStyleCB.addItem("bold");
227 fontStyleCB.addItem("italic");
229 fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif"));
230 fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10"));
231 fontStyleCB.setSelectedItem(Cache.getDefault("FONT_STYLE", Font.PLAIN
234 smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", false));
235 scaleProteinToCdna.setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA,
238 idItalics.setSelected(Cache.getDefault("ID_ITALICS", true));
240 wrap.setSelected(Cache.getDefault("WRAP_ALIGNMENT", false));
242 gapSymbolCB.addItem("-");
243 gapSymbolCB.addItem(".");
245 gapSymbolCB.setSelectedItem(Cache.getDefault("GAP_SYMBOL", "-"));
247 sortby.addItem("No sort");
248 sortby.addItem("Id");
249 sortby.addItem("Pairwise Identity");
250 sortby.setSelectedItem(Cache.getDefault("SORT_ALIGNMENT", "No sort"));
252 sortAnnBy.addItem(SequenceAnnotationOrder.NONE.toString());
254 .addItem(SequenceAnnotationOrder.SEQUENCE_AND_LABEL.toString());
256 .addItem(SequenceAnnotationOrder.LABEL_AND_SEQUENCE.toString());
257 SequenceAnnotationOrder savedSort = SequenceAnnotationOrder
258 .valueOf(Cache.getDefault(SORT_ANNOTATIONS,
259 SequenceAnnotationOrder.NONE.name()));
260 sortAnnBy.setSelectedItem(savedSort.toString());
262 sortAutocalc.addItem("Autocalculated first");
263 sortAutocalc.addItem("Autocalculated last");
264 final boolean showAbove = Cache.getDefault(SHOW_AUTOCALC_ABOVE, true);
265 sortAutocalc.setSelectedItem(showAbove ? sortAutocalc.getItemAt(0)
266 : sortAutocalc.getItemAt(1));
268 .setSelected(Cache.getDefault("SHOW_STARTUP_FILE", true));
269 startupFileTextfield.setText(Cache.getDefault("STARTUP_FILE",
270 Cache.getDefault("www.jalview.org", "http://www.jalview.org")
271 + "/examples/exampleFile_2_3.jar"));
274 * Set Colours tab defaults
276 for (int i = ColourSchemeProperty.FIRST_COLOUR; i <= ColourSchemeProperty.LAST_COLOUR; i++)
278 protColour.addItem(ColourSchemeProperty.getColourName(i));
279 nucColour.addItem(ColourSchemeProperty.getColourName(i));
281 String oldProp = Cache.getDefault(DEFAULT_COLOUR, "None");
282 String newProp = Cache.getDefault(DEFAULT_COLOUR_PROT, null);
283 protColour.setSelectedItem(newProp != null ? newProp : oldProp);
284 newProp = Cache.getDefault(DEFAULT_COLOUR_NUC, null);
285 nucColour.setSelectedItem(newProp != null ? newProp : oldProp);
286 minColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN",
288 maxColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX",
292 * Set Structure tab defaults.
294 final boolean structSelected = Cache.getDefault(STRUCT_FROM_PDB, false);
295 structFromPdb.setSelected(structSelected);
296 useRnaView.setSelected(Cache.getDefault(USE_RNAVIEW, false));
297 useRnaView.setEnabled(structSelected);
298 addSecondaryStructure.setSelected(Cache.getDefault(ADD_SS_ANN, false));
299 addSecondaryStructure.setEnabled(structSelected);
300 addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, false));
301 addTempFactor.setEnabled(structSelected);
302 structViewer.setSelectedItem(Cache.getDefault(STRUCTURE_DISPLAY,
303 ViewerType.JMOL.name()));
304 chimeraPath.setText(Cache.getDefault(CHIMERA_PATH, ""));
305 chimeraPath.addActionListener(new ActionListener()
308 public void actionPerformed(ActionEvent e)
310 validateChimeraPath();
314 if (Cache.getDefault("MAP_WITH_SIFTS", false))
316 siftsMapping.setSelected(true);
320 nwMapping.setSelected(true);
324 .setMapWithSifts(Cache.getDefault("MAP_WITH_SIFTS", false));
327 * Set Connections tab defaults
331 linkUrlTable.setModel(dataModel);
332 final TableRowSorter<TableModel> sorter = new TableRowSorter<>(
333 linkUrlTable.getModel());
334 linkUrlTable.setRowSorter(sorter);
335 List<RowSorter.SortKey> sortKeys = new ArrayList<>();
337 sortKeys.add(new RowSorter.SortKey(3,
338 SortOrder.DESCENDING));
339 sortKeys.add(new RowSorter.SortKey(2, SortOrder.DESCENDING));
340 sortKeys.add(new RowSorter.SortKey(0, SortOrder.ASCENDING));
342 sorter.setSortKeys(sortKeys);
346 ActionListener onReset;
347 onReset = new ActionListener()
350 public void actionPerformed(ActionEvent e)
352 filterTB.setText("");
353 sorter.setRowFilter(RowFilter.regexFilter(""));
357 doReset.addActionListener(onReset);
359 // filter to display only custom urls
360 final RowFilter<TableModel, Object> customUrlFilter = new RowFilter<TableModel, Object>()
363 public boolean include(
364 Entry<? extends TableModel, ? extends Object> entry)
366 String id = entry.getStringValue(4);
367 return sequenceUrlLinks.isUserEntry(id);
371 final TableRowSorter<TableModel> customSorter = new TableRowSorter<>(
372 linkUrlTable.getModel());
373 customSorter.setRowFilter(customUrlFilter);
375 ActionListener onCustomOnly;
376 onCustomOnly = new ActionListener()
379 public void actionPerformed(ActionEvent e)
381 filterTB.setText("");
382 sorter.setRowFilter(customUrlFilter);
385 userOnly.addActionListener(onCustomOnly);
387 filterTB.getDocument().addDocumentListener(new DocumentListener()
390 public void changedUpdate(DocumentEvent e)
392 sorter.setRowFilter(RowFilter.regexFilter("(?i)"
393 + filterTB.getText()));
397 public void removeUpdate(DocumentEvent e)
399 sorter.setRowFilter(RowFilter.regexFilter("(?i)"
400 + filterTB.getText()));
404 public void insertUpdate(DocumentEvent e)
406 sorter.setRowFilter(RowFilter.regexFilter("(?i)"
407 + filterTB.getText()));
411 // set up list selection functionality
412 linkUrlTable.getSelectionModel().addListSelectionListener(
413 new UrlListSelectionHandler());
415 // set up radio buttons
416 linkUrlTable.getColumn("Default").setCellRenderer(
417 new RadioButtonRenderer());
418 linkUrlTable.getColumn("Default")
419 .setCellEditor(new RadioButtonEditor());
421 // get boolean columns and resize those to min possible
422 for (int column = 0; column < linkUrlTable.getColumnCount(); column++)
424 if (linkUrlTable.getModel().getColumnClass(column)
425 .equals(Boolean.class))
427 TableColumn tableColumn = linkUrlTable.getColumnModel().getColumn(
429 int preferredWidth = tableColumn.getMinWidth();
431 TableCellRenderer cellRenderer = linkUrlTable.getCellRenderer(0,
433 Component c = linkUrlTable.prepareRenderer(cellRenderer, 0, column);
434 int cwidth = c.getPreferredSize().width
435 + linkUrlTable.getIntercellSpacing().width;
436 preferredWidth = Math.max(preferredWidth, cwidth);
438 tableColumn.setPreferredWidth(preferredWidth);
442 useProxy.setSelected(Cache.getDefault("USE_PROXY", false));
443 useProxy_actionPerformed(); // make sure useProxy is correctly initialised
444 proxyServerTB.setEnabled(useProxy.isSelected());
445 proxyPortTB.setEnabled(useProxy.isSelected());
446 proxyServerTB.setText(Cache.getDefault("PROXY_SERVER", ""));
447 proxyPortTB.setText(Cache.getDefault("PROXY_PORT", ""));
449 defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
451 usagestats.setSelected(Cache.getDefault("USAGESTATS", false));
452 // note antisense here: default is true
454 .setSelected(Cache.getProperty("NOQUESTIONNAIRES") == null);
455 versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true));
458 * Set Output tab defaults
460 epsRendering.addItem(promptEachTimeOpt);
461 epsRendering.addItem(lineArtOpt);
462 epsRendering.addItem(textOpt);
463 String defaultEPS = Cache.getDefault("EPS_RENDERING",
465 if (defaultEPS.equalsIgnoreCase("Text"))
467 epsRendering.setSelectedItem(textOpt);
469 else if (defaultEPS.equalsIgnoreCase("Lineart"))
471 epsRendering.setSelectedItem(lineArtOpt);
475 epsRendering.setSelectedItem(promptEachTimeOpt);
477 autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
478 userIdWidth.setEnabled(!autoIdWidth.isSelected());
479 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
480 Integer wi = Cache.getIntegerProperty("FIGURE_USERIDWIDTH");
481 userIdWidth.setText(wi == null ? "" : wi.toString());
482 blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
483 clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
484 fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
485 msfjv.setSelected(Cache.getDefault("MSF_JVSUFFIX", true));
486 pfamjv.setSelected(Cache.getDefault("PFAM_JVSUFFIX", true));
487 pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true));
488 pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true));
489 modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false));
490 embbedBioJSON.setSelected(Cache.getDefault("EXPORT_EMBBED_BIOJSON",
494 * Set Editing tab defaults
496 autoCalculateConsCheck.setSelected(Cache.getDefault(
497 "AUTO_CALC_CONSENSUS", true));
498 padGaps.setSelected(Cache.getDefault("PAD_GAPS", false));
499 sortByTree.setSelected(Cache.getDefault("SORT_BY_TREE", false));
501 annotations_actionPerformed(null); // update the display of the annotation
506 * Save user selections on the Preferences tabs to the Cache and write out to
512 public void ok_actionPerformed(ActionEvent e)
514 if (!validateSettings())
520 * Save Visual settings
522 Cache.applicationProperties.setProperty("SHOW_JVSUFFIX",
523 Boolean.toString(seqLimit.isSelected()));
524 Cache.applicationProperties.setProperty("RIGHT_ALIGN_IDS",
525 Boolean.toString(rightAlign.isSelected()));
526 Cache.applicationProperties.setProperty("SHOW_FULLSCREEN",
527 Boolean.toString(fullScreen.isSelected()));
528 Cache.applicationProperties.setProperty("SHOW_OVERVIEW",
529 Boolean.toString(openoverv.isSelected()));
530 Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
531 Boolean.toString(annotations.isSelected()));
532 Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
533 Boolean.toString(conservation.isSelected()));
534 Cache.applicationProperties.setProperty("SHOW_QUALITY",
535 Boolean.toString(quality.isSelected()));
536 Cache.applicationProperties.setProperty("SHOW_IDENTITY",
537 Boolean.toString(identity.isSelected()));
539 Cache.applicationProperties.setProperty("GAP_SYMBOL", gapSymbolCB
540 .getSelectedItem().toString());
542 Cache.applicationProperties.setProperty("FONT_NAME", fontNameCB
543 .getSelectedItem().toString());
544 Cache.applicationProperties.setProperty("FONT_STYLE", fontStyleCB
545 .getSelectedItem().toString());
546 Cache.applicationProperties.setProperty("FONT_SIZE", fontSizeCB
547 .getSelectedItem().toString());
549 Cache.applicationProperties.setProperty("ID_ITALICS",
550 Boolean.toString(idItalics.isSelected()));
551 Cache.applicationProperties.setProperty("SHOW_UNCONSERVED",
552 Boolean.toString(showUnconserved.isSelected()));
553 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSENSUS",
554 Boolean.toString(showGroupConsensus.isSelected()));
555 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSERVATION",
556 Boolean.toString(showGroupConservation.isSelected()));
557 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_HISTOGRAM",
558 Boolean.toString(showConsensHistogram.isSelected()));
559 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_LOGO",
560 Boolean.toString(showConsensLogo.isSelected()));
561 Cache.applicationProperties.setProperty("ANTI_ALIAS",
562 Boolean.toString(smoothFont.isSelected()));
563 Cache.applicationProperties.setProperty(SCALE_PROTEIN_TO_CDNA,
564 Boolean.toString(scaleProteinToCdna.isSelected()));
565 Cache.applicationProperties.setProperty("SHOW_NPFEATS_TOOLTIP",
566 Boolean.toString(showNpTooltip.isSelected()));
567 Cache.applicationProperties.setProperty("SHOW_DBREFS_TOOLTIP",
568 Boolean.toString(showDbRefTooltip.isSelected()));
570 Cache.applicationProperties.setProperty("WRAP_ALIGNMENT",
571 Boolean.toString(wrap.isSelected()));
573 Cache.applicationProperties.setProperty("STARTUP_FILE",
574 startupFileTextfield.getText());
575 Cache.applicationProperties.setProperty("SHOW_STARTUP_FILE",
576 Boolean.toString(startupCheckbox.isSelected()));
578 Cache.applicationProperties.setProperty("SORT_ALIGNMENT", sortby
579 .getSelectedItem().toString());
581 // convert description of sort order to enum name for save
582 SequenceAnnotationOrder annSortOrder = SequenceAnnotationOrder
583 .forDescription(sortAnnBy.getSelectedItem().toString());
584 if (annSortOrder != null)
586 Cache.applicationProperties.setProperty(SORT_ANNOTATIONS,
587 annSortOrder.name());
590 final boolean showAutocalcFirst = sortAutocalc.getSelectedIndex() == 0;
591 Cache.applicationProperties.setProperty(SHOW_AUTOCALC_ABOVE, Boolean
592 .valueOf(showAutocalcFirst).toString());
595 * Save Colours settings
597 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_PROT, protColour
598 .getSelectedItem().toString());
599 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_NUC, nucColour
600 .getSelectedItem().toString());
601 Cache.setColourProperty("ANNOTATIONCOLOUR_MIN",
602 minColour.getBackground());
603 Cache.setColourProperty("ANNOTATIONCOLOUR_MAX",
604 maxColour.getBackground());
607 * Save Structure settings
609 Cache.applicationProperties.setProperty(ADD_TEMPFACT_ANN,
610 Boolean.toString(addTempFactor.isSelected()));
611 Cache.applicationProperties.setProperty(ADD_SS_ANN,
612 Boolean.toString(addSecondaryStructure.isSelected()));
613 Cache.applicationProperties.setProperty(USE_RNAVIEW,
614 Boolean.toString(useRnaView.isSelected()));
615 Cache.applicationProperties.setProperty(STRUCT_FROM_PDB,
616 Boolean.toString(structFromPdb.isSelected()));
617 Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY, structViewer
618 .getSelectedItem().toString());
619 Cache.setOrRemove(CHIMERA_PATH, chimeraPath.getText());
620 Cache.applicationProperties.setProperty("MAP_WITH_SIFTS",
621 Boolean.toString(siftsMapping.isSelected()));
622 SiftsSettings.setMapWithSifts(siftsMapping.isSelected());
625 * Save Output settings
627 Cache.applicationProperties.setProperty("EPS_RENDERING",
628 ((OptionsParam) epsRendering.getSelectedItem()).getCode());
631 * Save Connections settings
633 Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
635 jalview.util.BrowserLauncher.resetBrowser();
637 // save user-defined and selected links
638 String links = linkUrlTable.getModel().toString();
641 Cache.applicationProperties.remove("SEQUENCE_LINKS");
645 Cache.applicationProperties.setProperty("SEQUENCE_LINKS",
649 Cache.applicationProperties.setProperty("USE_PROXY",
650 Boolean.toString(useProxy.isSelected()));
652 Cache.setOrRemove("PROXY_SERVER", proxyServerTB.getText());
654 Cache.setOrRemove("PROXY_PORT", proxyPortTB.getText());
656 if (useProxy.isSelected())
658 System.setProperty("http.proxyHost", proxyServerTB.getText());
659 System.setProperty("http.proxyPort", proxyPortTB.getText());
663 System.setProperty("http.proxyHost", "");
664 System.setProperty("http.proxyPort", "");
666 Cache.setProperty("VERSION_CHECK",
667 Boolean.toString(versioncheck.isSelected()));
668 if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
670 // default is false - we only set this if the user has actively agreed
671 Cache.setProperty("USAGESTATS",
672 Boolean.toString(usagestats.isSelected()));
674 if (!questionnaire.isSelected())
676 Cache.setProperty("NOQUESTIONNAIRES", "true");
680 // special - made easy to edit a property file to disable questionnaires
681 // by just adding the given line
682 Cache.removeProperty("NOQUESTIONNAIRES");
686 * Save Output settings
688 Cache.applicationProperties.setProperty("BLC_JVSUFFIX",
689 Boolean.toString(blcjv.isSelected()));
690 Cache.applicationProperties.setProperty("CLUSTAL_JVSUFFIX",
691 Boolean.toString(clustaljv.isSelected()));
692 Cache.applicationProperties.setProperty("FASTA_JVSUFFIX",
693 Boolean.toString(fastajv.isSelected()));
694 Cache.applicationProperties.setProperty("MSF_JVSUFFIX",
695 Boolean.toString(msfjv.isSelected()));
696 Cache.applicationProperties.setProperty("PFAM_JVSUFFIX",
697 Boolean.toString(pfamjv.isSelected()));
698 Cache.applicationProperties.setProperty("PILEUP_JVSUFFIX",
699 Boolean.toString(pileupjv.isSelected()));
700 Cache.applicationProperties.setProperty("PIR_JVSUFFIX",
701 Boolean.toString(pirjv.isSelected()));
702 Cache.applicationProperties.setProperty("PIR_MODELLER",
703 Boolean.toString(modellerOutput.isSelected()));
704 Cache.applicationProperties.setProperty("EXPORT_EMBBED_BIOJSON",
705 Boolean.toString(embbedBioJSON.isSelected()));
706 jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
708 Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH",
709 Boolean.toString(autoIdWidth.isSelected()));
710 userIdWidth_actionPerformed();
711 Cache.applicationProperties.setProperty("FIGURE_USERIDWIDTH",
712 userIdWidth.getText());
715 * Save Editing settings
717 Cache.applicationProperties.setProperty("AUTO_CALC_CONSENSUS",
718 Boolean.toString(autoCalculateConsCheck.isSelected()));
719 Cache.applicationProperties.setProperty("SORT_BY_TREE",
720 Boolean.toString(sortByTree.isSelected()));
721 Cache.applicationProperties.setProperty("PAD_GAPS",
722 Boolean.toString(padGaps.isSelected()));
724 dasSource.saveProperties(Cache.applicationProperties);
725 wsPrefs.updateAndRefreshWsMenuConfig(false);
726 Cache.saveProperties();
727 Desktop.instance.doConfigureStructurePrefs();
730 frame.setClosed(true);
731 } catch (Exception ex)
737 * Do any necessary validation before saving settings. Return focus to the
738 * first tab which fails validation.
742 private boolean validateSettings()
744 if (!validateStructure())
746 structureTab.requestFocusInWindow();
753 protected boolean validateStructure()
755 return validateChimeraPath();
763 public void startupFileTextfield_mouseClicked()
765 JalviewFileChooser chooser = new JalviewFileChooser(
766 jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] {
767 "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc",
768 "jar" }, new String[] { "Fasta", "Clustal", "PFAM", "MSF",
769 "PIR", "BLC", "Jalview" },
770 jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT"));
771 chooser.setFileView(new JalviewFileView());
772 chooser.setDialogTitle(MessageManager
773 .getString("label.select_startup_file"));
775 int value = chooser.showOpenDialog(this);
777 if (value == JalviewFileChooser.APPROVE_OPTION)
779 jalview.bin.Cache.applicationProperties.setProperty(
780 "DEFAULT_FILE_FORMAT", chooser.getSelectedFormat());
781 startupFileTextfield.setText(chooser.getSelectedFile()
793 public void cancel_actionPerformed(ActionEvent e)
797 wsPrefs.updateWsMenuConfig(true);
798 wsPrefs.refreshWs_actionPerformed(e);
799 frame.setClosed(true);
800 } catch (Exception ex)
812 public void annotations_actionPerformed(ActionEvent e)
814 conservation.setEnabled(annotations.isSelected());
815 quality.setEnabled(annotations.isSelected());
816 identity.setEnabled(annotations.isSelected());
817 showGroupConsensus.setEnabled(annotations.isSelected());
818 showGroupConservation.setEnabled(annotations.isSelected());
819 showConsensHistogram.setEnabled(annotations.isSelected()
820 && (identity.isSelected() || showGroupConsensus.isSelected()));
821 showConsensLogo.setEnabled(annotations.isSelected()
822 && (identity.isSelected() || showGroupConsensus.isSelected()));
826 public void newLink_actionPerformed(ActionEvent e)
828 GSequenceLink link = new GSequenceLink();
829 boolean valid = false;
832 if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
833 MessageManager.getString("label.new_sequence_url_link"),
834 JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
836 if (link.checkValid())
838 ((UrlLinkTableModel) linkUrlTable.getModel()).insertRow(
839 link.getName(), link.getURL());
851 public void editLink_actionPerformed(ActionEvent e)
853 GSequenceLink link = new GSequenceLink();
855 int index = linkUrlTable.getSelectedRow();
858 // no row was selected
859 JOptionPane.showInternalMessageDialog(Desktop.desktop,
860 MessageManager.getString("label.no_link_selected"),
861 MessageManager.getString("label.no_link_selected"),
862 JOptionPane.WARNING_MESSAGE);
866 link.setName(linkUrlTable.getValueAt(index, 0).toString());
867 link.setURL(linkUrlTable.getValueAt(index, 1).toString());
869 boolean valid = false;
872 if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
873 MessageManager.getString("label.new_sequence_url_link"),
874 JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
876 if (link.checkValid())
878 linkUrlTable.setValueAt(link.getName(), index, 0);
879 linkUrlTable.setValueAt(link.getURL(), index, 1);
891 public void deleteLink_actionPerformed(ActionEvent e)
893 int index = linkUrlTable.getSelectedRow();
897 // no row is selected
898 JOptionPane.showInternalMessageDialog(Desktop.desktop,
899 MessageManager.getString("label.no_link_selected"),
900 MessageManager.getString("label.no_link_selected"),
901 JOptionPane.WARNING_MESSAGE);
906 modelIndex = linkUrlTable.convertRowIndexToModel(index);
909 // make sure we use the model index to delete, and not the table index
910 ((UrlLinkTableModel) linkUrlTable.getModel()).removeRow(modelIndex);
915 public void defaultBrowser_mouseClicked(MouseEvent e)
917 JFileChooser chooser = new JFileChooser(".");
918 chooser.setDialogTitle(MessageManager
919 .getString("label.select_default_browser"));
921 int value = chooser.showOpenDialog(this);
923 if (value == JFileChooser.APPROVE_OPTION)
925 defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath());
934 * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event
938 protected void showunconserved_actionPerformed(ActionEvent e)
940 // TODO Auto-generated method stub
941 super.showunconserved_actionPerformed(e);
944 public static List<String> getGroupURLLinks()
946 return groupURLLinks;
950 public void minColour_actionPerformed(JPanel panel)
952 Color col = JColorChooser.showDialog(this,
953 MessageManager.getString("label.select_colour_minimum_value"),
954 minColour.getBackground());
957 panel.setBackground(col);
963 public void maxColour_actionPerformed(JPanel panel)
965 Color col = JColorChooser.showDialog(this,
966 MessageManager.getString("label.select_colour_maximum_value"),
967 maxColour.getBackground());
970 panel.setBackground(col);
976 protected void userIdWidth_actionPerformed()
980 String val = userIdWidth.getText().trim();
981 if (val.length() > 0)
983 Integer iw = Integer.parseInt(val);
984 if (iw.intValue() < 12)
986 throw new NumberFormatException();
988 userIdWidth.setText(iw.toString());
990 } catch (NumberFormatException x)
992 JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
993 .getString("warn.user_defined_width_requirements"),
994 MessageManager.getString("label.invalid_id_column_width"),
995 JOptionPane.WARNING_MESSAGE);
996 userIdWidth.setText("");
1001 protected void autoIdWidth_actionPerformed()
1003 userIdWidth.setEnabled(!autoIdWidth.isSelected());
1004 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
1008 * Returns true if chimera path is to a valid executable, else show an error
1011 private boolean validateChimeraPath()
1013 if (chimeraPath.getText().trim().length() > 0)
1015 File f = new File(chimeraPath.getText());
1016 if (!f.canExecute())
1018 JOptionPane.showInternalMessageDialog(Desktop.desktop,
1019 MessageManager.getString("label.invalid_chimera_path"),
1020 MessageManager.getString("label.invalid_name"),
1021 JOptionPane.ERROR_MESSAGE);
1029 * If Chimera is selected, check it can be found on default or user-specified
1030 * path, if not show a warning/help dialog.
1033 protected void structureViewer_actionPerformed(String selectedItem)
1035 if (!selectedItem.equals(ViewerType.CHIMERA.name()))
1039 boolean found = false;
1042 * Try user-specified and standard paths for Chimera executable.
1044 List<String> paths = StructureManager.getChimeraPaths();
1045 paths.add(0, chimeraPath.getText());
1046 for (String path : paths)
1048 if (new File(path.trim()).canExecute())
1056 String[] options = { "OK", "Help" };
1057 int showHelp = JOptionPane.showInternalOptionDialog(
1059 JvSwingUtils.wrapTooltip(true,
1060 MessageManager.getString("label.chimera_missing")),
1061 "", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE,
1062 null, options, options[0]);
1063 if (showHelp == JOptionPane.NO_OPTION)
1067 Help.showHelpWindow(HelpId.StructureViewer);
1068 } catch (HelpSetException e)
1070 e.printStackTrace();
1076 public class OptionsParam
1078 private String name;
1080 private String code;
1082 public OptionsParam(String name, String code)
1088 public String getName()
1093 public void setName(String name)
1098 public String getCode()
1103 public void setCode(String code)
1109 public String toString()
1115 public boolean equals(Object that)
1117 if (!(that instanceof OptionsParam))
1121 return this.code.equalsIgnoreCase(((OptionsParam) that).code);
1125 public int hashCode()
1127 return name.hashCode() + code.hashCode();
1131 private class UrlListSelectionHandler implements ListSelectionListener
1135 public void valueChanged(ListSelectionEvent e)
1137 ListSelectionModel lsm = (ListSelectionModel) e.getSource();
1139 int index = lsm.getMinSelectionIndex();
1142 // no selection, so disable delete/edit buttons
1143 editLink.setEnabled(false);
1144 deleteLink.setEnabled(false);
1147 int modelIndex = linkUrlTable.convertRowIndexToModel(index);
1149 // determine if the new selection is a custom url or not
1150 if (!sequenceUrlLinks.isUserEntry((String) linkUrlTable
1152 .getValueAt(modelIndex, 4))) // KM TODO do this better
1154 // entry is not a user-defined url and so should not be edited
1155 // disable edit and delete buttons
1156 deleteLink.setEnabled(false);
1157 editLink.setEnabled(false);
1161 deleteLink.setEnabled(true);
1162 editLink.setEnabled(true);
1165 // BUT it's the default url, don't allow deletion
1166 if ((boolean) linkUrlTable.getValueAt(index, 3))
1168 deleteLink.setEnabled(false);