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.UrlLinkTableModel;
33 import jalview.urls.UrlProvider;
34 import jalview.urls.UrlProviderI;
35 import jalview.util.MessageManager;
36 import jalview.util.Platform;
37 import jalview.util.UrlConstants;
38 import jalview.ws.sifts.SiftsSettings;
40 import java.awt.BorderLayout;
41 import java.awt.Color;
42 import java.awt.Component;
43 import java.awt.Dimension;
45 import java.awt.event.ActionEvent;
46 import java.awt.event.ActionListener;
47 import java.awt.event.MouseEvent;
49 import java.util.ArrayList;
50 import java.util.List;
52 import javax.help.HelpSetException;
53 import javax.swing.JColorChooser;
54 import javax.swing.JFileChooser;
55 import javax.swing.JInternalFrame;
56 import javax.swing.JOptionPane;
57 import javax.swing.JPanel;
58 import javax.swing.ListSelectionModel;
59 import javax.swing.RowFilter;
60 import javax.swing.RowSorter;
61 import javax.swing.SortOrder;
62 import javax.swing.event.DocumentEvent;
63 import javax.swing.event.DocumentListener;
64 import javax.swing.event.ListSelectionEvent;
65 import javax.swing.event.ListSelectionListener;
66 import javax.swing.table.TableCellRenderer;
67 import javax.swing.table.TableColumn;
68 import javax.swing.table.TableModel;
69 import javax.swing.table.TableRowSorter;
71 import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
79 public class Preferences extends GPreferences
81 public static final String ENABLE_SPLIT_FRAME = "ENABLE_SPLIT_FRAME";
83 public static final String SCALE_PROTEIN_TO_CDNA = "SCALE_PROTEIN_TO_CDNA";
85 public static final String DEFAULT_COLOUR = "DEFAULT_COLOUR";
87 public static final String DEFAULT_COLOUR_PROT = "DEFAULT_COLOUR_PROT";
89 public static final String DEFAULT_COLOUR_NUC = "DEFAULT_COLOUR_NUC";
91 public static final String ADD_TEMPFACT_ANN = "ADD_TEMPFACT_ANN";
93 public static final String ADD_SS_ANN = "ADD_SS_ANN";
95 public static final String USE_RNAVIEW = "USE_RNAVIEW";
97 public static final String STRUCT_FROM_PDB = "STRUCT_FROM_PDB";
99 public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY";
101 public static final String CHIMERA_PATH = "CHIMERA_PATH";
103 public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS";
105 public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE";
107 private static final int MIN_FONT_SIZE = 1;
109 private static final int MAX_FONT_SIZE = 30;
112 * Holds name and link separated with | character. Sequence ID must be
113 * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$
115 public static UrlProviderI sequenceUrlLinks;
117 public static UrlLinkTableModel dataModel;
120 * Holds name and link separated with | character. Sequence IDS and Sequences
121 * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and
122 * $SEQUENCES$ or $SEQUENCES=/.possible | chars ./=$ and separation character
123 * for first and second token specified after a pipe character at end |,|.
124 * (TODO: proper escape for using | to separate ids or sequences
127 public static List<String> groupURLLinks;
130 String string = Cache.getDefault("SEQUENCE_LINKS",
131 UrlConstants.DEFAULT_STRING);
132 sequenceUrlLinks = new UrlProvider(UrlConstants.DEFAULT_LABEL, string);
133 dataModel = new UrlLinkTableModel(sequenceUrlLinks);
136 * TODO: reformulate groupURL encoding so two or more can be stored in the
137 * .properties file as '|' separated strings
140 groupURLLinks = new ArrayList<String>();
143 JInternalFrame frame;
145 DasSourceBrowser dasSource;
147 private WsPreferences wsPrefs;
149 private OptionsParam promptEachTimeOpt = new OptionsParam(
150 MessageManager.getString("label.prompt_each_time"),
153 private OptionsParam lineArtOpt = new OptionsParam(
154 MessageManager.getString("label.lineart"), "Lineart");
156 private OptionsParam textOpt = new OptionsParam(
157 MessageManager.getString("action.text"), "Text");
160 * Creates a new Preferences object.
165 frame = new JInternalFrame();
166 frame.setContentPane(this);
167 dasSource = new DasSourceBrowser();
168 dasTab.add(dasSource, BorderLayout.CENTER);
169 wsPrefs = new WsPreferences();
170 wsTab.add(wsPrefs, BorderLayout.CENTER);
171 int width = 500, height = 450;
172 new jalview.util.Platform();
173 if (Platform.isAMac())
179 Desktop.addInternalFrame(frame,
180 MessageManager.getString("label.preferences"), width, height);
181 frame.setMinimumSize(new Dimension(width, height));
184 * Set Visual tab defaults
186 seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true));
187 rightAlign.setSelected(Cache.getDefault("RIGHT_ALIGN_IDS", false));
188 fullScreen.setSelected(Cache.getDefault("SHOW_FULLSCREEN", false));
189 annotations.setSelected(Cache.getDefault("SHOW_ANNOTATIONS", true));
191 conservation.setSelected(Cache.getDefault("SHOW_CONSERVATION", true));
192 quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));
193 identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
194 openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false));
196 .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
197 showGroupConsensus.setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS",
199 showGroupConservation.setSelected(Cache.getDefault(
200 "SHOW_GROUP_CONSERVATION", false));
201 showConsensHistogram.setSelected(Cache.getDefault(
202 "SHOW_CONSENSUS_HISTOGRAM", true));
203 showConsensLogo.setSelected(Cache.getDefault("SHOW_CONSENSUS_LOGO",
205 showNpTooltip.setSelected(Cache
206 .getDefault("SHOW_NPFEATS_TOOLTIP", true));
207 showDbRefTooltip.setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP",
210 String[] fonts = java.awt.GraphicsEnvironment
211 .getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
212 for (int i = 0; i < fonts.length; i++)
214 fontNameCB.addItem(fonts[i]);
217 for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++)
219 fontSizeCB.addItem(i + "");
222 fontStyleCB.addItem("plain");
223 fontStyleCB.addItem("bold");
224 fontStyleCB.addItem("italic");
226 fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif"));
227 fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10"));
228 fontStyleCB.setSelectedItem(Cache.getDefault("FONT_STYLE", Font.PLAIN
231 smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", false));
232 scaleProteinToCdna.setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA,
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, true);
262 sortAutocalc.setSelectedItem(showAbove ? sortAutocalc.getItemAt(0)
263 : sortAutocalc.getItemAt(1));
265 .setSelected(Cache.getDefault("SHOW_STARTUP_FILE", true));
266 startupFileTextfield.setText(Cache.getDefault("STARTUP_FILE",
267 Cache.getDefault("www.jalview.org", "http://www.jalview.org")
268 + "/examples/exampleFile_2_3.jar"));
271 * Set Colours tab defaults
273 for (int i = ColourSchemeProperty.FIRST_COLOUR; i <= ColourSchemeProperty.LAST_COLOUR; i++)
275 protColour.addItem(ColourSchemeProperty.getColourName(i));
276 nucColour.addItem(ColourSchemeProperty.getColourName(i));
278 String oldProp = Cache.getDefault(DEFAULT_COLOUR, "None");
279 String newProp = Cache.getDefault(DEFAULT_COLOUR_PROT, null);
280 protColour.setSelectedItem(newProp != null ? newProp : oldProp);
281 newProp = Cache.getDefault(DEFAULT_COLOUR_NUC, null);
282 nucColour.setSelectedItem(newProp != null ? newProp : oldProp);
283 minColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN",
285 maxColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX",
289 * Set Structure tab defaults.
291 final boolean structSelected = Cache.getDefault(STRUCT_FROM_PDB, false);
292 structFromPdb.setSelected(structSelected);
293 useRnaView.setSelected(Cache.getDefault(USE_RNAVIEW, false));
294 useRnaView.setEnabled(structSelected);
295 addSecondaryStructure.setSelected(Cache.getDefault(ADD_SS_ANN, false));
296 addSecondaryStructure.setEnabled(structSelected);
297 addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, false));
298 addTempFactor.setEnabled(structSelected);
299 structViewer.setSelectedItem(Cache.getDefault(STRUCTURE_DISPLAY,
300 ViewerType.JMOL.name()));
301 chimeraPath.setText(Cache.getDefault(CHIMERA_PATH, ""));
302 chimeraPath.addActionListener(new ActionListener()
305 public void actionPerformed(ActionEvent e)
307 validateChimeraPath();
311 if (Cache.getDefault("MAP_WITH_SIFTS", false))
313 siftsMapping.setSelected(true);
317 nwMapping.setSelected(true);
321 .setMapWithSifts(Cache.getDefault("MAP_WITH_SIFTS", false));
324 * Set Connections tab defaults
328 linkUrlTable.setModel(dataModel);
329 final TableRowSorter<TableModel> sorter = new TableRowSorter<>(
330 linkUrlTable.getModel());
331 linkUrlTable.setRowSorter(sorter);
332 List<RowSorter.SortKey> sortKeys = new ArrayList<>();
334 sortKeys.add(new RowSorter.SortKey(3,
335 SortOrder.DESCENDING));
336 sortKeys.add(new RowSorter.SortKey(2, SortOrder.DESCENDING));
337 sortKeys.add(new RowSorter.SortKey(0, SortOrder.ASCENDING));
339 sorter.setSortKeys(sortKeys);
343 ActionListener onReset;
344 onReset = new ActionListener()
347 public void actionPerformed(ActionEvent e)
349 filterTB.setText("");
350 sorter.setRowFilter(RowFilter.regexFilter(""));
354 doReset.addActionListener(onReset);
356 // filter to display only custom urls
357 final RowFilter<TableModel, Object> customUrlFilter = new RowFilter<TableModel, Object>()
360 public boolean include(
361 Entry<? extends TableModel, ? extends Object> entry)
363 String id = entry.getStringValue(4);
364 return sequenceUrlLinks.isUserEntry(id);
368 final TableRowSorter<TableModel> customSorter = new TableRowSorter<>(
369 linkUrlTable.getModel());
370 customSorter.setRowFilter(customUrlFilter);
372 ActionListener onCustomOnly;
373 onCustomOnly = new ActionListener()
376 public void actionPerformed(ActionEvent e)
378 filterTB.setText("");
379 sorter.setRowFilter(customUrlFilter);
382 userOnly.addActionListener(onCustomOnly);
384 filterTB.getDocument().addDocumentListener(new DocumentListener()
387 public void changedUpdate(DocumentEvent e)
389 sorter.setRowFilter(RowFilter.regexFilter("(?i)"
390 + filterTB.getText()));
394 public void removeUpdate(DocumentEvent e)
396 sorter.setRowFilter(RowFilter.regexFilter("(?i)"
397 + filterTB.getText()));
401 public void insertUpdate(DocumentEvent e)
403 sorter.setRowFilter(RowFilter.regexFilter("(?i)"
404 + filterTB.getText()));
408 // set up list selection functionality
409 linkUrlTable.getSelectionModel().addListSelectionListener(
410 new UrlListSelectionHandler());
412 // set up radio buttons
413 linkUrlTable.getColumn("Default").setCellRenderer(
414 new RadioButtonRenderer());
415 linkUrlTable.getColumn("Default")
416 .setCellEditor(new RadioButtonEditor());
418 // get boolean columns and resize those to min possible
419 for (int column = 0; column < linkUrlTable.getColumnCount(); column++)
421 if (linkUrlTable.getModel().getColumnClass(column)
422 .equals(Boolean.class))
424 TableColumn tableColumn = linkUrlTable.getColumnModel().getColumn(
426 int preferredWidth = tableColumn.getMinWidth();
428 TableCellRenderer cellRenderer = linkUrlTable.getCellRenderer(0,
430 Component c = linkUrlTable.prepareRenderer(cellRenderer, 0, column);
431 int cwidth = c.getPreferredSize().width
432 + linkUrlTable.getIntercellSpacing().width;
433 preferredWidth = Math.max(preferredWidth, cwidth);
435 tableColumn.setPreferredWidth(preferredWidth);
439 useProxy.setSelected(Cache.getDefault("USE_PROXY", false));
440 useProxy_actionPerformed(); // make sure useProxy is correctly initialised
441 proxyServerTB.setEnabled(useProxy.isSelected());
442 proxyPortTB.setEnabled(useProxy.isSelected());
443 proxyServerTB.setText(Cache.getDefault("PROXY_SERVER", ""));
444 proxyPortTB.setText(Cache.getDefault("PROXY_PORT", ""));
446 defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
448 usagestats.setSelected(Cache.getDefault("USAGESTATS", false));
449 // note antisense here: default is true
451 .setSelected(Cache.getProperty("NOQUESTIONNAIRES") == null);
452 versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true));
455 * Set Output tab defaults
457 epsRendering.addItem(promptEachTimeOpt);
458 epsRendering.addItem(lineArtOpt);
459 epsRendering.addItem(textOpt);
460 String defaultEPS = Cache.getDefault("EPS_RENDERING",
462 if (defaultEPS.equalsIgnoreCase("Text"))
464 epsRendering.setSelectedItem(textOpt);
466 else if (defaultEPS.equalsIgnoreCase("Lineart"))
468 epsRendering.setSelectedItem(lineArtOpt);
472 epsRendering.setSelectedItem(promptEachTimeOpt);
474 autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
475 userIdWidth.setEnabled(!autoIdWidth.isSelected());
476 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
477 Integer wi = Cache.getIntegerProperty("FIGURE_USERIDWIDTH");
478 userIdWidth.setText(wi == null ? "" : wi.toString());
479 blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
480 clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
481 fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
482 msfjv.setSelected(Cache.getDefault("MSF_JVSUFFIX", true));
483 pfamjv.setSelected(Cache.getDefault("PFAM_JVSUFFIX", true));
484 pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true));
485 pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true));
486 modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false));
487 embbedBioJSON.setSelected(Cache.getDefault("EXPORT_EMBBED_BIOJSON",
491 * Set Editing tab defaults
493 autoCalculateConsCheck.setSelected(Cache.getDefault(
494 "AUTO_CALC_CONSENSUS", true));
495 padGaps.setSelected(Cache.getDefault("PAD_GAPS", false));
496 sortByTree.setSelected(Cache.getDefault("SORT_BY_TREE", false));
498 annotations_actionPerformed(null); // update the display of the annotation
503 * Save user selections on the Preferences tabs to the Cache and write out to
509 public void ok_actionPerformed(ActionEvent e)
511 if (!validateSettings())
517 * Save Visual settings
519 Cache.applicationProperties.setProperty("SHOW_JVSUFFIX",
520 Boolean.toString(seqLimit.isSelected()));
521 Cache.applicationProperties.setProperty("RIGHT_ALIGN_IDS",
522 Boolean.toString(rightAlign.isSelected()));
523 Cache.applicationProperties.setProperty("SHOW_FULLSCREEN",
524 Boolean.toString(fullScreen.isSelected()));
525 Cache.applicationProperties.setProperty("SHOW_OVERVIEW",
526 Boolean.toString(openoverv.isSelected()));
527 Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
528 Boolean.toString(annotations.isSelected()));
529 Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
530 Boolean.toString(conservation.isSelected()));
531 Cache.applicationProperties.setProperty("SHOW_QUALITY",
532 Boolean.toString(quality.isSelected()));
533 Cache.applicationProperties.setProperty("SHOW_IDENTITY",
534 Boolean.toString(identity.isSelected()));
536 Cache.applicationProperties.setProperty("GAP_SYMBOL", gapSymbolCB
537 .getSelectedItem().toString());
539 Cache.applicationProperties.setProperty("FONT_NAME", fontNameCB
540 .getSelectedItem().toString());
541 Cache.applicationProperties.setProperty("FONT_STYLE", fontStyleCB
542 .getSelectedItem().toString());
543 Cache.applicationProperties.setProperty("FONT_SIZE", fontSizeCB
544 .getSelectedItem().toString());
546 Cache.applicationProperties.setProperty("ID_ITALICS",
547 Boolean.toString(idItalics.isSelected()));
548 Cache.applicationProperties.setProperty("SHOW_UNCONSERVED",
549 Boolean.toString(showUnconserved.isSelected()));
550 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSENSUS",
551 Boolean.toString(showGroupConsensus.isSelected()));
552 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSERVATION",
553 Boolean.toString(showGroupConservation.isSelected()));
554 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_HISTOGRAM",
555 Boolean.toString(showConsensHistogram.isSelected()));
556 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_LOGO",
557 Boolean.toString(showConsensLogo.isSelected()));
558 Cache.applicationProperties.setProperty("ANTI_ALIAS",
559 Boolean.toString(smoothFont.isSelected()));
560 Cache.applicationProperties.setProperty(SCALE_PROTEIN_TO_CDNA,
561 Boolean.toString(scaleProteinToCdna.isSelected()));
562 Cache.applicationProperties.setProperty("SHOW_NPFEATS_TOOLTIP",
563 Boolean.toString(showNpTooltip.isSelected()));
564 Cache.applicationProperties.setProperty("SHOW_DBREFS_TOOLTIP",
565 Boolean.toString(showDbRefTooltip.isSelected()));
567 Cache.applicationProperties.setProperty("WRAP_ALIGNMENT",
568 Boolean.toString(wrap.isSelected()));
570 Cache.applicationProperties.setProperty("STARTUP_FILE",
571 startupFileTextfield.getText());
572 Cache.applicationProperties.setProperty("SHOW_STARTUP_FILE",
573 Boolean.toString(startupCheckbox.isSelected()));
575 Cache.applicationProperties.setProperty("SORT_ALIGNMENT", sortby
576 .getSelectedItem().toString());
578 // convert description of sort order to enum name for save
579 SequenceAnnotationOrder annSortOrder = SequenceAnnotationOrder
580 .forDescription(sortAnnBy.getSelectedItem().toString());
581 if (annSortOrder != null)
583 Cache.applicationProperties.setProperty(SORT_ANNOTATIONS,
584 annSortOrder.name());
587 final boolean showAutocalcFirst = sortAutocalc.getSelectedIndex() == 0;
588 Cache.applicationProperties.setProperty(SHOW_AUTOCALC_ABOVE, Boolean
589 .valueOf(showAutocalcFirst).toString());
592 * Save Colours settings
594 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_PROT, protColour
595 .getSelectedItem().toString());
596 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_NUC, nucColour
597 .getSelectedItem().toString());
598 Cache.setColourProperty("ANNOTATIONCOLOUR_MIN",
599 minColour.getBackground());
600 Cache.setColourProperty("ANNOTATIONCOLOUR_MAX",
601 maxColour.getBackground());
604 * Save Structure settings
606 Cache.applicationProperties.setProperty(ADD_TEMPFACT_ANN,
607 Boolean.toString(addTempFactor.isSelected()));
608 Cache.applicationProperties.setProperty(ADD_SS_ANN,
609 Boolean.toString(addSecondaryStructure.isSelected()));
610 Cache.applicationProperties.setProperty(USE_RNAVIEW,
611 Boolean.toString(useRnaView.isSelected()));
612 Cache.applicationProperties.setProperty(STRUCT_FROM_PDB,
613 Boolean.toString(structFromPdb.isSelected()));
614 Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY, structViewer
615 .getSelectedItem().toString());
616 Cache.setOrRemove(CHIMERA_PATH, chimeraPath.getText());
617 Cache.applicationProperties.setProperty("MAP_WITH_SIFTS",
618 Boolean.toString(siftsMapping.isSelected()));
619 SiftsSettings.setMapWithSifts(siftsMapping.isSelected());
622 * Save Output settings
624 Cache.applicationProperties.setProperty("EPS_RENDERING",
625 ((OptionsParam) epsRendering.getSelectedItem()).getCode());
628 * Save Connections settings
630 Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
632 jalview.util.BrowserLauncher.resetBrowser();
634 // save user-defined and selected links
635 String links = linkUrlTable.getModel().toString();
638 Cache.applicationProperties.remove("SEQUENCE_LINKS");
642 Cache.applicationProperties.setProperty("SEQUENCE_LINKS",
646 Cache.applicationProperties.setProperty("USE_PROXY",
647 Boolean.toString(useProxy.isSelected()));
649 Cache.setOrRemove("PROXY_SERVER", proxyServerTB.getText());
651 Cache.setOrRemove("PROXY_PORT", proxyPortTB.getText());
653 if (useProxy.isSelected())
655 System.setProperty("http.proxyHost", proxyServerTB.getText());
656 System.setProperty("http.proxyPort", proxyPortTB.getText());
660 System.setProperty("http.proxyHost", "");
661 System.setProperty("http.proxyPort", "");
663 Cache.setProperty("VERSION_CHECK",
664 Boolean.toString(versioncheck.isSelected()));
665 if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
667 // default is false - we only set this if the user has actively agreed
668 Cache.setProperty("USAGESTATS",
669 Boolean.toString(usagestats.isSelected()));
671 if (!questionnaire.isSelected())
673 Cache.setProperty("NOQUESTIONNAIRES", "true");
677 // special - made easy to edit a property file to disable questionnaires
678 // by just adding the given line
679 Cache.removeProperty("NOQUESTIONNAIRES");
683 * Save Output settings
685 Cache.applicationProperties.setProperty("BLC_JVSUFFIX",
686 Boolean.toString(blcjv.isSelected()));
687 Cache.applicationProperties.setProperty("CLUSTAL_JVSUFFIX",
688 Boolean.toString(clustaljv.isSelected()));
689 Cache.applicationProperties.setProperty("FASTA_JVSUFFIX",
690 Boolean.toString(fastajv.isSelected()));
691 Cache.applicationProperties.setProperty("MSF_JVSUFFIX",
692 Boolean.toString(msfjv.isSelected()));
693 Cache.applicationProperties.setProperty("PFAM_JVSUFFIX",
694 Boolean.toString(pfamjv.isSelected()));
695 Cache.applicationProperties.setProperty("PILEUP_JVSUFFIX",
696 Boolean.toString(pileupjv.isSelected()));
697 Cache.applicationProperties.setProperty("PIR_JVSUFFIX",
698 Boolean.toString(pirjv.isSelected()));
699 Cache.applicationProperties.setProperty("PIR_MODELLER",
700 Boolean.toString(modellerOutput.isSelected()));
701 Cache.applicationProperties.setProperty("EXPORT_EMBBED_BIOJSON",
702 Boolean.toString(embbedBioJSON.isSelected()));
703 jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
705 Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH",
706 Boolean.toString(autoIdWidth.isSelected()));
707 userIdWidth_actionPerformed();
708 Cache.applicationProperties.setProperty("FIGURE_USERIDWIDTH",
709 userIdWidth.getText());
712 * Save Editing settings
714 Cache.applicationProperties.setProperty("AUTO_CALC_CONSENSUS",
715 Boolean.toString(autoCalculateConsCheck.isSelected()));
716 Cache.applicationProperties.setProperty("SORT_BY_TREE",
717 Boolean.toString(sortByTree.isSelected()));
718 Cache.applicationProperties.setProperty("PAD_GAPS",
719 Boolean.toString(padGaps.isSelected()));
721 dasSource.saveProperties(Cache.applicationProperties);
722 wsPrefs.updateAndRefreshWsMenuConfig(false);
723 Cache.saveProperties();
724 Desktop.instance.doConfigureStructurePrefs();
727 frame.setClosed(true);
728 } catch (Exception ex)
734 * Do any necessary validation before saving settings. Return focus to the
735 * first tab which fails validation.
739 private boolean validateSettings()
741 if (!validateStructure())
743 structureTab.requestFocusInWindow();
750 protected boolean validateStructure()
752 return validateChimeraPath();
760 public void startupFileTextfield_mouseClicked()
762 JalviewFileChooser chooser = new JalviewFileChooser(
763 jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] {
764 "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc",
765 "jar" }, new String[] { "Fasta", "Clustal", "PFAM", "MSF",
766 "PIR", "BLC", "Jalview" },
767 jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT"));
768 chooser.setFileView(new JalviewFileView());
769 chooser.setDialogTitle(MessageManager
770 .getString("label.select_startup_file"));
772 int value = chooser.showOpenDialog(this);
774 if (value == JalviewFileChooser.APPROVE_OPTION)
776 jalview.bin.Cache.applicationProperties.setProperty(
777 "DEFAULT_FILE_FORMAT", chooser.getSelectedFormat());
778 startupFileTextfield.setText(chooser.getSelectedFile()
790 public void cancel_actionPerformed(ActionEvent e)
794 wsPrefs.updateWsMenuConfig(true);
795 wsPrefs.refreshWs_actionPerformed(e);
796 frame.setClosed(true);
797 } catch (Exception ex)
809 public void annotations_actionPerformed(ActionEvent e)
811 conservation.setEnabled(annotations.isSelected());
812 quality.setEnabled(annotations.isSelected());
813 identity.setEnabled(annotations.isSelected());
814 showGroupConsensus.setEnabled(annotations.isSelected());
815 showGroupConservation.setEnabled(annotations.isSelected());
816 showConsensHistogram.setEnabled(annotations.isSelected()
817 && (identity.isSelected() || showGroupConsensus.isSelected()));
818 showConsensLogo.setEnabled(annotations.isSelected()
819 && (identity.isSelected() || showGroupConsensus.isSelected()));
823 public void newLink_actionPerformed(ActionEvent e)
825 GSequenceLink link = new GSequenceLink();
826 boolean valid = false;
829 if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
830 MessageManager.getString("label.new_sequence_url_link"),
831 JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
833 if (link.checkValid())
835 ((UrlLinkTableModel) linkUrlTable.getModel()).insertRow(
836 link.getName(), link.getURL());
848 public void editLink_actionPerformed(ActionEvent e)
850 GSequenceLink link = new GSequenceLink();
852 int index = linkUrlTable.getSelectedRow();
855 // no row was selected
856 JOptionPane.showInternalMessageDialog(Desktop.desktop,
857 MessageManager.getString("label.no_link_selected"),
858 MessageManager.getString("label.no_link_selected"),
859 JOptionPane.WARNING_MESSAGE);
863 link.setName(linkUrlTable.getValueAt(index, 0).toString());
864 link.setURL(linkUrlTable.getValueAt(index, 1).toString());
866 boolean valid = false;
869 if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
870 MessageManager.getString("label.new_sequence_url_link"),
871 JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
873 if (link.checkValid())
875 linkUrlTable.setValueAt(link.getName(), index, 0);
876 linkUrlTable.setValueAt(link.getURL(), index, 1);
888 public void deleteLink_actionPerformed(ActionEvent e)
890 int index = linkUrlTable.getSelectedRow();
894 // no row is selected
895 JOptionPane.showInternalMessageDialog(Desktop.desktop,
896 MessageManager.getString("label.no_link_selected"),
897 MessageManager.getString("label.no_link_selected"),
898 JOptionPane.WARNING_MESSAGE);
903 modelIndex = linkUrlTable.convertRowIndexToModel(index);
906 // make sure we use the model index to delete, and not the table index
907 ((UrlLinkTableModel) linkUrlTable.getModel()).removeRow(modelIndex);
912 public void defaultBrowser_mouseClicked(MouseEvent e)
914 JFileChooser chooser = new JFileChooser(".");
915 chooser.setDialogTitle(MessageManager
916 .getString("label.select_default_browser"));
918 int value = chooser.showOpenDialog(this);
920 if (value == JFileChooser.APPROVE_OPTION)
922 defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath());
931 * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event
935 protected void showunconserved_actionPerformed(ActionEvent e)
937 // TODO Auto-generated method stub
938 super.showunconserved_actionPerformed(e);
941 public static List<String> getGroupURLLinks()
943 return groupURLLinks;
947 public void minColour_actionPerformed(JPanel panel)
949 Color col = JColorChooser.showDialog(this,
950 MessageManager.getString("label.select_colour_minimum_value"),
951 minColour.getBackground());
954 panel.setBackground(col);
960 public void maxColour_actionPerformed(JPanel panel)
962 Color col = JColorChooser.showDialog(this,
963 MessageManager.getString("label.select_colour_maximum_value"),
964 maxColour.getBackground());
967 panel.setBackground(col);
973 protected void userIdWidth_actionPerformed()
977 String val = userIdWidth.getText().trim();
978 if (val.length() > 0)
980 Integer iw = Integer.parseInt(val);
981 if (iw.intValue() < 12)
983 throw new NumberFormatException();
985 userIdWidth.setText(iw.toString());
987 } catch (NumberFormatException x)
989 JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
990 .getString("warn.user_defined_width_requirements"),
991 MessageManager.getString("label.invalid_id_column_width"),
992 JOptionPane.WARNING_MESSAGE);
993 userIdWidth.setText("");
998 protected void autoIdWidth_actionPerformed()
1000 userIdWidth.setEnabled(!autoIdWidth.isSelected());
1001 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
1005 * Returns true if chimera path is to a valid executable, else show an error
1008 private boolean validateChimeraPath()
1010 if (chimeraPath.getText().trim().length() > 0)
1012 File f = new File(chimeraPath.getText());
1013 if (!f.canExecute())
1015 JOptionPane.showInternalMessageDialog(Desktop.desktop,
1016 MessageManager.getString("label.invalid_chimera_path"),
1017 MessageManager.getString("label.invalid_name"),
1018 JOptionPane.ERROR_MESSAGE);
1026 * If Chimera is selected, check it can be found on default or user-specified
1027 * path, if not show a warning/help dialog.
1030 protected void structureViewer_actionPerformed(String selectedItem)
1032 if (!selectedItem.equals(ViewerType.CHIMERA.name()))
1036 boolean found = false;
1039 * Try user-specified and standard paths for Chimera executable.
1041 List<String> paths = StructureManager.getChimeraPaths();
1042 paths.add(0, chimeraPath.getText());
1043 for (String path : paths)
1045 if (new File(path.trim()).canExecute())
1053 String[] options = { "OK", "Help" };
1054 int showHelp = JOptionPane.showInternalOptionDialog(
1056 JvSwingUtils.wrapTooltip(true,
1057 MessageManager.getString("label.chimera_missing")),
1058 "", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE,
1059 null, options, options[0]);
1060 if (showHelp == JOptionPane.NO_OPTION)
1064 Help.showHelpWindow(HelpId.StructureViewer);
1065 } catch (HelpSetException e)
1067 e.printStackTrace();
1073 public class OptionsParam
1075 private String name;
1077 private String code;
1079 public OptionsParam(String name, String code)
1085 public String getName()
1090 public void setName(String name)
1095 public String getCode()
1100 public void setCode(String code)
1106 public String toString()
1112 public boolean equals(Object that)
1114 if (!(that instanceof OptionsParam))
1118 return this.code.equalsIgnoreCase(((OptionsParam) that).code);
1122 public int hashCode()
1124 return name.hashCode() + code.hashCode();
1128 private class UrlListSelectionHandler implements ListSelectionListener
1132 public void valueChanged(ListSelectionEvent e)
1134 ListSelectionModel lsm = (ListSelectionModel) e.getSource();
1136 int index = lsm.getMinSelectionIndex();
1139 // no selection, so disable delete/edit buttons
1140 editLink.setEnabled(false);
1141 deleteLink.setEnabled(false);
1144 int modelIndex = linkUrlTable.convertRowIndexToModel(index);
1146 // determine if the new selection is a custom url or not
1147 if (!sequenceUrlLinks.isUserEntry((String) linkUrlTable
1149 .getValueAt(modelIndex, 4))) // KM TODO do this better
1151 // entry is not a user-defined url and so should not be edited
1152 // disable edit and delete buttons
1153 deleteLink.setEnabled(false);
1154 editLink.setEnabled(false);
1158 deleteLink.setEnabled(true);
1159 editLink.setEnabled(true);
1162 // BUT it's the default url, don't allow deletion
1163 if ((boolean) linkUrlTable.getValueAt(index, 3))
1165 deleteLink.setEnabled(false);