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 java.awt.BorderLayout;
24 import java.awt.Color;
25 import java.awt.Component;
26 import java.awt.Dimension;
28 import java.awt.event.ActionEvent;
29 import java.awt.event.ActionListener;
30 import java.awt.event.FocusAdapter;
31 import java.awt.event.FocusEvent;
32 import java.awt.event.MouseEvent;
34 import java.util.ArrayList;
35 import java.util.List;
37 import javax.help.HelpSetException;
38 import javax.swing.JComboBox;
39 import javax.swing.JFileChooser;
40 import javax.swing.JInternalFrame;
41 import javax.swing.JPanel;
42 import javax.swing.JTextField;
43 import javax.swing.ListSelectionModel;
44 import javax.swing.RowFilter;
45 import javax.swing.RowSorter;
46 import javax.swing.SortOrder;
47 import javax.swing.event.DocumentEvent;
48 import javax.swing.event.DocumentListener;
49 import javax.swing.event.ListSelectionEvent;
50 import javax.swing.event.ListSelectionListener;
51 import javax.swing.table.TableCellRenderer;
52 import javax.swing.table.TableColumn;
53 import javax.swing.table.TableModel;
54 import javax.swing.table.TableRowSorter;
56 import jalview.hmmer.HmmerCommand;
57 import jalview.util.FileUtils;
59 import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
60 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
61 import jalview.bin.Cache;
62 import jalview.gui.Help.HelpId;
63 import jalview.gui.StructureViewer.ViewerType;
64 import jalview.io.BackupFiles;
65 import jalview.io.BackupFilesPresetEntry;
66 import jalview.io.FileFormatI;
67 import jalview.io.JalviewFileChooser;
68 import jalview.io.JalviewFileView;
69 import jalview.jbgui.GPreferences;
70 import jalview.jbgui.GSequenceLink;
71 import jalview.schemes.ColourSchemeI;
72 import jalview.schemes.ColourSchemes;
73 import jalview.schemes.ResidueColourScheme;
74 import jalview.urls.UrlLinkTableModel;
75 import jalview.urls.api.UrlProviderFactoryI;
76 import jalview.urls.api.UrlProviderI;
77 import jalview.urls.desktop.DesktopUrlProviderFactory;
78 import jalview.util.MessageManager;
79 import jalview.util.Platform;
80 import jalview.util.UrlConstants;
81 import jalview.ws.sifts.SiftsSettings;
89 public class Preferences extends GPreferences
91 // suggested list delimiter character
92 public static final String COMMA = ",";
94 public static final String HMMSEARCH_SEQCOUNT = "HMMSEARCH_SEQCOUNT";
96 public static final String HMMINFO_GLOBAL_BACKGROUND = "HMMINFO_GLOBAL_BACKGROUND";
98 public static final String HMMALIGN_TRIM_TERMINI = "HMMALIGN_TRIM_TERMINI";
100 public static final String ADD_SS_ANN = "ADD_SS_ANN";
102 public static final String ADD_TEMPFACT_ANN = "ADD_TEMPFACT_ANN";
104 public static final String ALLOW_UNPUBLISHED_PDB_QUERYING = "ALLOW_UNPUBLISHED_PDB_QUERYING";
106 public static final String ANNOTATIONCOLOUR_MAX = "ANNOTATIONCOLOUR_MAX";
108 public static final String ANNOTATIONCOLOUR_MIN = "ANNOTATIONCOLOUR_MIN";
110 public static final String ANTI_ALIAS = "ANTI_ALIAS";
112 public static final String AUTO_CALC_CONSENSUS = "AUTO_CALC_CONSENSUS";
114 public static final String AUTOASSOCIATE_PDBANDSEQS = "AUTOASSOCIATE_PDBANDSEQS";
116 public static final String BLOSUM62_PCA_FOR_NUCLEOTIDE = "BLOSUM62_PCA_FOR_NUCLEOTIDE";
118 public static final String CENTRE_COLUMN_LABELS = "CENTRE_COLUMN_LABELS";
120 public static final String CHIMERA_PATH = "CHIMERA_PATH";
122 public static final String DBREFFETCH_USEPICR = "DBREFFETCH_USEPICR";
124 public static final String DEFAULT_COLOUR = "DEFAULT_COLOUR";
126 public static final String DEFAULT_COLOUR_NUC = "DEFAULT_COLOUR_NUC";
128 public static final String DEFAULT_COLOUR_PROT = "DEFAULT_COLOUR_PROT";
130 public static final String ENABLE_SPLIT_FRAME = "ENABLE_SPLIT_FRAME";
132 public static final String FIGURE_AUTOIDWIDTH = "FIGURE_AUTOIDWIDTH";
134 public static final String FIGURE_FIXEDIDWIDTH = "FIGURE_FIXEDIDWIDTH";
136 public static final String FOLLOW_SELECTIONS = "FOLLOW_SELECTIONS";
138 public static final String FONT_NAME = "FONT_NAME";
140 public static final String FONT_SIZE = "FONT_SIZE";
142 public static final String FONT_STYLE = "FONT_STYLE";
144 public static final String HMMER_PATH = "HMMER_PATH";
146 public static final String CYGWIN_PATH = "CYGWIN_PATH";
148 public static final String HMMSEARCH_DBS = "HMMSEARCH_DBS";
150 public static final String GAP_COLOUR = "GAP_COLOUR";
152 public static final String GAP_SYMBOL = "GAP_SYMBOL";
154 public static final String HIDDEN_COLOUR = "HIDDEN_COLOUR";
156 public static final String HIDE_INTRONS = "HIDE_INTRONS";
158 public static final String ID_ITALICS = "ID_ITALICS";
160 public static final String ID_ORG_HOSTURL = "ID_ORG_HOSTURL";
162 public static final String MAP_WITH_SIFTS = "MAP_WITH_SIFTS";
164 public static final String NOQUESTIONNAIRES = "NOQUESTIONNAIRES";
166 public static final String NORMALISE_CONSENSUS_LOGO = "NORMALISE_CONSENSUS_LOGO";
168 public static final String NORMALISE_LOGO = "NORMALISE_LOGO";
170 public static final String PAD_GAPS = "PAD_GAPS";
172 public static final String PDB_DOWNLOAD_FORMAT = "PDB_DOWNLOAD_FORMAT";
174 public static final String QUESTIONNAIRE = "QUESTIONNAIRE";
176 public static final String RELAXEDSEQIDMATCHING = "RELAXEDSEQIDMATCHING";
178 public static final String RIGHT_ALIGN_IDS = "RIGHT_ALIGN_IDS";
180 public static final String SCALE_PROTEIN_TO_CDNA = "SCALE_PROTEIN_TO_CDNA";
182 public static final String SHOW_ANNOTATIONS = "SHOW_ANNOTATIONS";
184 public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE";
186 public static final String SHOW_CONSENSUS = "SHOW_CONSENSUS";
188 public static final String SHOW_CONSENSUS_HISTOGRAM = "SHOW_CONSENSUS_HISTOGRAM";
190 public static final String SHOW_CONSENSUS_LOGO = "SHOW_CONSENSUS_LOGO";
192 public static final String SHOW_CONSERVATION = "SHOW_CONSERVATION";
194 public static final String SHOW_DBREFS_TOOLTIP = "SHOW_DBREFS_TOOLTIP";
196 public static final String SHOW_GROUP_CONSENSUS = "SHOW_GROUP_CONSENSUS";
198 public static final String SHOW_GROUP_CONSERVATION = "SHOW_GROUP_CONSERVATION";
200 public static final String SHOW_JVSUFFIX = "SHOW_JVSUFFIX";
202 public static final String SHOW_NPFEATS_TOOLTIP = "SHOW_NPFEATS_TOOLTIP";
204 public static final String SHOW_OCCUPANCY = "SHOW_OCCUPANCY";
206 public static final String SHOW_OV_HIDDEN_AT_START = "SHOW_OV_HIDDEN_AT_START";
208 public static final String SHOW_OVERVIEW = "SHOW_OVERVIEW";
210 public static final String SHOW_QUALITY = "SHOW_QUALITY";
212 public static final String SHOW_UNCONSERVED = "SHOW_UNCONSERVED";
214 public static final String SORT_ALIGNMENT = "SORT_ALIGNMENT";
216 public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS";
218 public static final String SORT_BY_TREE = "SORT_BY_TREE";
220 public static final String STRUCT_FROM_PDB = "STRUCT_FROM_PDB";
222 public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY";
224 public static final String STRUCTURE_DIMENSIONS = "STRUCTURE_DIMENSIONS";
226 public static final String UNIPROT_DOMAIN = "UNIPROT_DOMAIN";
228 public static final String USE_FULL_SO = "USE_FULL_SO";
230 public static final String USE_LEGACY_GAP = "USE_LEGACY_GAP";
232 public static final String USE_RNAVIEW = "USE_RNAVIEW";
234 public static final String USER_DEFINED_COLOURS = "USER_DEFINED_COLOURS";
236 public static final String WRAP_ALIGNMENT = "WRAP_ALIGNMENT";
239 private static final int MIN_FONT_SIZE = 1;
241 private static final int MAX_FONT_SIZE = 30;
244 * Holds name and link separated with | character. Sequence ID must be
245 * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$
247 public static UrlProviderI sequenceUrlLinks;
249 public static UrlLinkTableModel dataModel;
252 * Holds name and link separated with | character. Sequence IDS and Sequences
253 * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and
254 * $SEQUENCES$ or $SEQUENCES=/.possible | chars ./=$ and separation character
255 * for first and second token specified after a pipe character at end |,|.
256 * (TODO: proper escape for using | to separate ids or sequences
259 public static List<String> groupURLLinks;
262 // get links selected to be in the menu (SEQUENCE_LINKS)
263 // and links entered by the user but not selected (STORED_LINKS)
264 String inMenuString = Cache.getDefault("SEQUENCE_LINKS", "");
265 String notInMenuString = Cache.getDefault("STORED_LINKS", "");
266 String defaultUrl = Cache.getDefault("DEFAULT_URL",
267 UrlConstants.DEFAULT_LABEL);
269 // if both links lists are empty, add the DEFAULT_URL link
270 // otherwise we assume the default link is in one of the lists
271 if (inMenuString.isEmpty() && notInMenuString.isEmpty())
273 inMenuString = UrlConstants.DEFAULT_STRING;
275 UrlProviderFactoryI factory = new DesktopUrlProviderFactory(defaultUrl,
276 inMenuString, notInMenuString);
277 sequenceUrlLinks = factory.createUrlProvider();
278 dataModel = new UrlLinkTableModel(sequenceUrlLinks);
281 * TODO: reformulate groupURL encoding so two or more can be stored in the
282 * .properties file as '|' separated strings
285 groupURLLinks = new ArrayList<>();
288 JInternalFrame frame;
290 private WsPreferences wsPrefs;
292 private SlivkaPreferences slivkaPrefs;
294 private OptionsParam promptEachTimeOpt = new OptionsParam(
295 MessageManager.getString("label.prompt_each_time"),
298 private OptionsParam lineArtOpt = new OptionsParam(
299 MessageManager.getString("label.lineart"), "Lineart");
301 private OptionsParam textOpt = new OptionsParam(
302 MessageManager.getString("action.text"), "Text");
305 * Creates a new Preferences object.
310 frame = new JInternalFrame();
311 frame.setContentPane(this);
312 if (!Platform.isJS())
319 wsPrefs = new WsPreferences();
320 wsTab.add(wsPrefs, BorderLayout.CENTER);
321 slivkaPrefs = new SlivkaPreferences();
322 slivkaTab.add(slivkaPrefs, BorderLayout.CENTER);
324 int width = 500, height = 450;
325 if (Platform.isAMacAndNotJS())
331 Desktop.addInternalFrame(frame,
332 MessageManager.getString("label.preferences"), width, height);
333 frame.setMinimumSize(new Dimension(width, height));
336 * Set HMMER tab defaults
338 hmmrTrimTermini.setSelected(Cache.getDefault(HMMALIGN_TRIM_TERMINI, false));
339 if (Cache.getDefault(HMMINFO_GLOBAL_BACKGROUND, false))
341 hmmerBackgroundUniprot.setSelected(true);
345 hmmerBackgroundAlignment.setSelected(true);
348 .setText(Cache.getProperty(HMMSEARCH_SEQCOUNT));
349 hmmerPath.setText(Cache.getProperty(HMMER_PATH));
350 hmmerPath.addActionListener(new ActionListener()
353 public void actionPerformed(ActionEvent e)
358 hmmerPath.addFocusListener(new FocusAdapter()
361 public void focusLost(FocusEvent e)
366 if (cygwinPath != null)
368 String path = Cache.getProperty(CYGWIN_PATH);
371 path = FileUtils.getPathTo("bash");
373 cygwinPath.setText(path);
374 cygwinPath.addActionListener(new ActionListener()
377 public void actionPerformed(ActionEvent e)
379 validateCygwinPath();
382 cygwinPath.addFocusListener(new FocusAdapter()
385 public void focusLost(FocusEvent e)
387 validateCygwinPath();
393 * Set Visual tab defaults
395 seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true));
396 rightAlign.setSelected(Cache.getDefault("RIGHT_ALIGN_IDS", false));
397 fullScreen.setSelected(Cache.getDefault("SHOW_FULLSCREEN", false));
398 annotations.setSelected(Cache.getDefault("SHOW_ANNOTATIONS", true));
400 conservation.setSelected(Cache.getDefault("SHOW_CONSERVATION", true));
401 quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));
402 identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
403 openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false));
405 .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
406 showOccupancy.setSelected(Cache.getDefault(SHOW_OCCUPANCY, false));
408 .setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS", false));
409 showGroupConservation.setSelected(
410 Cache.getDefault("SHOW_GROUP_CONSERVATION", false));
411 showConsensHistogram.setSelected(
412 Cache.getDefault("SHOW_CONSENSUS_HISTOGRAM", true));
414 .setSelected(Cache.getDefault("SHOW_CONSENSUS_LOGO", false));
415 showInformationHistogram.setSelected(
416 Cache.getDefault("SHOW_INFORMATION_HISTOGRAM", true));
417 showHMMLogo.setSelected(Cache.getDefault("SHOW_HMM_LOGO", false));
419 .setSelected(Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true));
421 .setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP", true));
423 String[] fonts = java.awt.GraphicsEnvironment
424 .getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
425 for (int i = 0; i < fonts.length; i++)
427 fontNameCB.addItem(fonts[i]);
430 for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++)
432 fontSizeCB.addItem(i + "");
435 fontStyleCB.addItem("plain");
436 fontStyleCB.addItem("bold");
437 fontStyleCB.addItem("italic");
439 fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif"));
440 fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10"));
441 fontStyleCB.setSelectedItem(
442 Cache.getDefault("FONT_STYLE", Font.PLAIN + ""));
444 smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", true));
446 .setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA, false));
448 idItalics.setSelected(Cache.getDefault("ID_ITALICS", true));
450 wrap.setSelected(Cache.getDefault("WRAP_ALIGNMENT", false));
452 gapSymbolCB.addItem("-");
453 gapSymbolCB.addItem(".");
455 gapSymbolCB.setSelectedItem(Cache.getDefault("GAP_SYMBOL", "-"));
457 sortby.addItem("No sort");
458 sortby.addItem("Id");
459 sortby.addItem("Pairwise Identity");
460 sortby.setSelectedItem(Cache.getDefault("SORT_ALIGNMENT", "No sort"));
462 sortAnnBy.addItem(SequenceAnnotationOrder.NONE.toString());
464 .addItem(SequenceAnnotationOrder.SEQUENCE_AND_LABEL.toString());
466 .addItem(SequenceAnnotationOrder.LABEL_AND_SEQUENCE.toString());
467 SequenceAnnotationOrder savedSort = SequenceAnnotationOrder
468 .valueOf(Cache.getDefault(SORT_ANNOTATIONS,
469 SequenceAnnotationOrder.NONE.name()));
470 sortAnnBy.setSelectedItem(savedSort.toString());
472 sortAutocalc.addItem("Autocalculated first");
473 sortAutocalc.addItem("Autocalculated last");
474 final boolean showAbove = Cache.getDefault(SHOW_AUTOCALC_ABOVE, true);
475 sortAutocalc.setSelectedItem(showAbove ? sortAutocalc.getItemAt(0)
476 : sortAutocalc.getItemAt(1));
478 .setSelected(Cache.getDefault("SHOW_STARTUP_FILE", true));
479 startupFileTextfield.setText(Cache.getDefault("STARTUP_FILE",
480 Cache.getDefault("www.jalview.org", "http://www.jalview.org")
481 + "/examples/exampleFile_2_3.jar"));
484 * Set Colours tab defaults
486 protColour.addItem(ResidueColourScheme.NONE);
487 nucColour.addItem(ResidueColourScheme.NONE);
488 for (ColourSchemeI cs : ColourSchemes.getInstance().getColourSchemes())
490 String name = cs.getSchemeName();
491 protColour.addItem(name);
492 nucColour.addItem(name);
494 String oldProp = Cache.getDefault(DEFAULT_COLOUR,
495 ResidueColourScheme.NONE);
496 String newProp = Cache.getDefault(DEFAULT_COLOUR_PROT, null);
497 protColour.setSelectedItem(newProp != null ? newProp : oldProp);
498 newProp = Cache.getDefault(DEFAULT_COLOUR_NUC, null);
499 nucColour.setSelectedItem(newProp != null ? newProp : oldProp);
500 minColour.setBackground(
501 Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN", Color.orange));
502 maxColour.setBackground(
503 Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX", Color.red));
506 * Set overview panel defaults
508 gapColour.setBackground(
509 Cache.getDefaultColour(GAP_COLOUR,
510 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP));
511 hiddenColour.setBackground(
512 Cache.getDefaultColour(HIDDEN_COLOUR,
513 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_HIDDEN));
514 useLegacyGap.setSelected(Cache.getDefault(USE_LEGACY_GAP, false));
515 gapLabel.setEnabled(!useLegacyGap.isSelected());
516 gapColour.setEnabled(!useLegacyGap.isSelected());
518 .setSelected(Cache.getDefault(SHOW_OV_HIDDEN_AT_START, false));
521 * Set Structure tab defaults.
523 final boolean structSelected = Cache.getDefault(STRUCT_FROM_PDB, false);
524 structFromPdb.setSelected(structSelected);
525 useRnaView.setSelected(Cache.getDefault(USE_RNAVIEW, false));
526 useRnaView.setEnabled(structSelected);
527 addSecondaryStructure.setSelected(Cache.getDefault(ADD_SS_ANN, false));
528 addSecondaryStructure.setEnabled(structSelected);
529 addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, false));
530 addTempFactor.setEnabled(structSelected);
531 if (!Platform.isJS())
533 structViewer.setSelectedItem(
534 Cache.getDefault(STRUCTURE_DISPLAY, ViewerType.JMOL.name()));
536 chimeraPath.setText(Cache.getDefault(CHIMERA_PATH, ""));
537 chimeraPath.addActionListener(new ActionListener()
540 public void actionPerformed(ActionEvent e)
542 validateChimeraPath();
546 if (Cache.getDefault("MAP_WITH_SIFTS", false))
548 siftsMapping.setSelected(true);
552 nwMapping.setSelected(true);
556 .setMapWithSifts(Cache.getDefault("MAP_WITH_SIFTS", false));
559 * Set Connections tab defaults
563 linkUrlTable.setModel(dataModel);
564 final TableRowSorter<TableModel> sorter = new TableRowSorter<>(
565 linkUrlTable.getModel());
566 linkUrlTable.setRowSorter(sorter);
567 List<RowSorter.SortKey> sortKeys = new ArrayList<>();
569 UrlLinkTableModel m = (UrlLinkTableModel) linkUrlTable.getModel();
570 sortKeys.add(new RowSorter.SortKey(m.getPrimaryColumn(),
571 SortOrder.DESCENDING));
572 sortKeys.add(new RowSorter.SortKey(m.getSelectedColumn(),
573 SortOrder.DESCENDING));
575 new RowSorter.SortKey(m.getNameColumn(), SortOrder.ASCENDING));
577 sorter.setSortKeys(sortKeys);
578 // BH 2018 setSortKeys will do the sort
582 ActionListener onReset;
583 onReset = new ActionListener()
586 public void actionPerformed(ActionEvent e)
588 filterTB.setText("");
589 sorter.setRowFilter(RowFilter.regexFilter(""));
593 doReset.addActionListener(onReset);
595 // filter to display only custom urls
596 final RowFilter<TableModel, Object> customUrlFilter = new RowFilter<>()
599 public boolean include(
600 Entry<? extends TableModel, ? extends Object> entry)
602 return ((UrlLinkTableModel) entry.getModel()).isUserEntry(entry);
606 final TableRowSorter<TableModel> customSorter = new TableRowSorter<>(
607 linkUrlTable.getModel());
608 customSorter.setRowFilter(customUrlFilter);
610 ActionListener onCustomOnly;
611 onCustomOnly = new ActionListener()
614 public void actionPerformed(ActionEvent e)
616 filterTB.setText("");
617 sorter.setRowFilter(customUrlFilter);
620 userOnly.addActionListener(onCustomOnly);
622 filterTB.getDocument().addDocumentListener(new DocumentListener()
624 String caseInsensitiveFlag = "(?i)";
627 public void changedUpdate(DocumentEvent e)
629 sorter.setRowFilter(RowFilter
630 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
634 public void removeUpdate(DocumentEvent e)
636 sorter.setRowFilter(RowFilter
637 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
641 public void insertUpdate(DocumentEvent e)
643 sorter.setRowFilter(RowFilter
644 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
648 // set up list selection functionality
649 linkUrlTable.getSelectionModel()
650 .addListSelectionListener(new UrlListSelectionHandler());
652 // set up radio buttons
653 int onClickCol = ((UrlLinkTableModel) linkUrlTable.getModel())
655 String onClickName = linkUrlTable.getColumnName(onClickCol);
656 linkUrlTable.getColumn(onClickName)
657 .setCellRenderer(new RadioButtonRenderer());
658 linkUrlTable.getColumn(onClickName)
659 .setCellEditor(new RadioButtonEditor());
661 // get boolean columns and resize those to min possible
662 for (int column = 0; column < linkUrlTable.getColumnCount(); column++)
664 if (linkUrlTable.getModel().getColumnClass(column)
665 .equals(Boolean.class))
667 TableColumn tableColumn = linkUrlTable.getColumnModel()
669 int preferredWidth = tableColumn.getMinWidth();
671 TableCellRenderer cellRenderer = linkUrlTable.getCellRenderer(0,
673 Component c = linkUrlTable.prepareRenderer(cellRenderer, 0, column);
674 int cwidth = c.getPreferredSize().width
675 + linkUrlTable.getIntercellSpacing().width;
676 preferredWidth = Math.max(preferredWidth, cwidth);
678 tableColumn.setPreferredWidth(preferredWidth);
682 useProxy.setSelected(Cache.getDefault("USE_PROXY", false));
683 useProxy_actionPerformed(); // make sure useProxy is correctly initialised
684 proxyServerTB.setText(Cache.getDefault("PROXY_SERVER", ""));
685 proxyPortTB.setText(Cache.getDefault("PROXY_PORT", ""));
687 defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
689 usagestats.setSelected(Cache.getDefault("USAGESTATS", false));
690 // note antisense here: default is true
692 .setSelected(Cache.getProperty("NOQUESTIONNAIRES") == null);
693 versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true));
696 * Set Output tab defaults
698 setupOutputCombo(epsRendering, "EPS_RENDERING");
699 setupOutputCombo(htmlRendering, "HTML_RENDERING");
700 setupOutputCombo(svgRendering, "SVG_RENDERING");
701 autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
702 userIdWidth.setEnabled(!autoIdWidth.isSelected());
703 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
704 Integer wi = Cache.getIntegerProperty("FIGURE_FIXEDIDWIDTH");
705 userIdWidth.setText(wi == null ? "" : wi.toString());
706 // TODO: refactor to use common enum via FormatAdapter and allow extension
707 // for new flat file formats
708 blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
709 clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
710 fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
711 msfjv.setSelected(Cache.getDefault("MSF_JVSUFFIX", true));
712 pfamjv.setSelected(Cache.getDefault("PFAM_JVSUFFIX", true));
713 pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true));
714 pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true));
715 modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false));
717 .setSelected(Cache.getDefault("EXPORT_EMBBED_BIOJSON", true));
720 * Set Editing tab defaults
722 autoCalculateConsCheck
723 .setSelected(Cache.getDefault("AUTO_CALC_CONSENSUS", true));
724 padGaps.setSelected(Cache.getDefault("PAD_GAPS", false));
725 sortByTree.setSelected(Cache.getDefault("SORT_BY_TREE", false));
727 annotations_actionPerformed(null); // update the display of the annotation
732 * Set Backups tab defaults
734 loadLastSavedBackupsOptions();
738 * A helper method that sets the items and initial selection in a character
739 * rendering option list (Prompt each time/Lineart/Text)
744 protected void setupOutputCombo(JComboBox<Object> comboBox,
747 comboBox.addItem(promptEachTimeOpt);
748 comboBox.addItem(lineArtOpt);
749 comboBox.addItem(textOpt);
752 * JalviewJS doesn't support Lineart so force it to Text
754 String defaultOption = Platform.isJS() ? "Text"
755 : Cache.getDefault(propertyKey, "Prompt each time");
756 if (defaultOption.equalsIgnoreCase("Text"))
758 comboBox.setSelectedItem(textOpt);
760 else if (defaultOption.equalsIgnoreCase("Lineart"))
762 comboBox.setSelectedItem(lineArtOpt);
766 comboBox.setSelectedItem(promptEachTimeOpt);
771 * Save user selections on the Preferences tabs to the Cache and write out to
777 public void ok_actionPerformed(ActionEvent e)
779 if (!validateSettings())
785 * Save Visual settings
787 Cache.setPropertyNoSave("SHOW_JVSUFFIX",
788 Boolean.toString(seqLimit.isSelected()));
789 Cache.setPropertyNoSave("RIGHT_ALIGN_IDS",
790 Boolean.toString(rightAlign.isSelected()));
791 Cache.setPropertyNoSave("SHOW_FULLSCREEN",
792 Boolean.toString(fullScreen.isSelected()));
793 Cache.setPropertyNoSave("SHOW_OVERVIEW",
794 Boolean.toString(openoverv.isSelected()));
795 Cache.setPropertyNoSave("SHOW_ANNOTATIONS",
796 Boolean.toString(annotations.isSelected()));
797 Cache.setPropertyNoSave("SHOW_CONSERVATION",
798 Boolean.toString(conservation.isSelected()));
799 Cache.setPropertyNoSave("SHOW_QUALITY",
800 Boolean.toString(quality.isSelected()));
801 Cache.setPropertyNoSave("SHOW_IDENTITY",
802 Boolean.toString(identity.isSelected()));
804 Cache.setPropertyNoSave("GAP_SYMBOL",
805 gapSymbolCB.getSelectedItem().toString());
807 Cache.setPropertyNoSave("FONT_NAME",
808 fontNameCB.getSelectedItem().toString());
809 Cache.setPropertyNoSave("FONT_STYLE",
810 fontStyleCB.getSelectedItem().toString());
811 Cache.setPropertyNoSave("FONT_SIZE",
812 fontSizeCB.getSelectedItem().toString());
814 Cache.setPropertyNoSave("ID_ITALICS",
815 Boolean.toString(idItalics.isSelected()));
816 Cache.setPropertyNoSave("SHOW_UNCONSERVED",
817 Boolean.toString(showUnconserved.isSelected()));
818 Cache.setPropertyNoSave(SHOW_OCCUPANCY,
819 Boolean.toString(showOccupancy.isSelected()));
820 Cache.setPropertyNoSave("SHOW_GROUP_CONSENSUS",
821 Boolean.toString(showGroupConsensus.isSelected()));
822 Cache.setPropertyNoSave("SHOW_GROUP_CONSERVATION",
823 Boolean.toString(showGroupConservation.isSelected()));
824 Cache.setPropertyNoSave("SHOW_CONSENSUS_HISTOGRAM",
825 Boolean.toString(showConsensHistogram.isSelected()));
826 Cache.setPropertyNoSave("SHOW_CONSENSUS_LOGO",
827 Boolean.toString(showConsensLogo.isSelected()));
828 Cache.setPropertyNoSave("SHOW_INFORMATION_HISTOGRAM",
829 Boolean.toString(showConsensHistogram.isSelected()));
830 Cache.setPropertyNoSave("SHOW_HMM_LOGO",
831 Boolean.toString(showHMMLogo.isSelected()));
832 Cache.setPropertyNoSave("ANTI_ALIAS",
833 Boolean.toString(smoothFont.isSelected()));
834 Cache.setPropertyNoSave(SCALE_PROTEIN_TO_CDNA,
835 Boolean.toString(scaleProteinToCdna.isSelected()));
836 Cache.setPropertyNoSave("SHOW_NPFEATS_TOOLTIP",
837 Boolean.toString(showNpTooltip.isSelected()));
838 Cache.setPropertyNoSave("SHOW_DBREFS_TOOLTIP",
839 Boolean.toString(showDbRefTooltip.isSelected()));
841 Cache.setPropertyNoSave("WRAP_ALIGNMENT",
842 Boolean.toString(wrap.isSelected()));
844 Cache.setPropertyNoSave("STARTUP_FILE",
845 startupFileTextfield.getText());
846 Cache.setPropertyNoSave("SHOW_STARTUP_FILE",
847 Boolean.toString(startupCheckbox.isSelected()));
849 Cache.setPropertyNoSave("SORT_ALIGNMENT",
850 sortby.getSelectedItem().toString());
852 // convert description of sort order to enum name for save
853 SequenceAnnotationOrder annSortOrder = SequenceAnnotationOrder
854 .forDescription(sortAnnBy.getSelectedItem().toString());
855 if (annSortOrder != null)
857 Cache.setPropertyNoSave(SORT_ANNOTATIONS,
858 annSortOrder.name());
861 final boolean showAutocalcFirst = sortAutocalc.getSelectedIndex() == 0;
862 Cache.setPropertyNoSave(SHOW_AUTOCALC_ABOVE,
863 Boolean.valueOf(showAutocalcFirst).toString());
866 * Save Colours settings
868 Cache.setPropertyNoSave(DEFAULT_COLOUR_PROT,
869 protColour.getSelectedItem().toString());
870 Cache.setPropertyNoSave(DEFAULT_COLOUR_NUC,
871 nucColour.getSelectedItem().toString());
872 Cache.setColourPropertyNoSave("ANNOTATIONCOLOUR_MIN",
873 minColour.getBackground());
874 Cache.setColourPropertyNoSave("ANNOTATIONCOLOUR_MAX",
875 maxColour.getBackground());
878 * Save HMMER settings
880 Cache.setPropertyNoSave(HMMALIGN_TRIM_TERMINI,
881 Boolean.toString(hmmrTrimTermini.isSelected()));
882 Cache.setPropertyNoSave(HMMINFO_GLOBAL_BACKGROUND,
883 Boolean.toString(hmmerBackgroundUniprot.isSelected()));
884 Cache.setPropertyNoSave(HMMSEARCH_SEQCOUNT,
885 hmmerSequenceCount.getText());
886 Cache.setOrRemove(HMMER_PATH, hmmerPath.getText());
887 if (cygwinPath != null)
889 Cache.setOrRemove(CYGWIN_PATH, cygwinPath.getText());
891 AlignFrame[] frames = Desktop.getAlignFrames();
892 if (frames != null && frames.length > 0)
894 for (AlignFrame f : frames)
896 f.updateHMMERStatus();
900 hmmrTrimTermini.setSelected(Cache.getDefault(HMMALIGN_TRIM_TERMINI, false));
901 if (Cache.getDefault(HMMINFO_GLOBAL_BACKGROUND, false))
903 hmmerBackgroundUniprot.setSelected(true);
907 hmmerBackgroundAlignment.setSelected(true);
910 .setText(Cache.getProperty(HMMSEARCH_SEQCOUNT));
911 hmmerPath.setText(Cache.getProperty(HMMER_PATH));
914 * Save Overview settings
916 Cache.setColourPropertyNoSave(GAP_COLOUR, gapColour.getBackground());
917 Cache.setColourPropertyNoSave(HIDDEN_COLOUR, hiddenColour.getBackground());
918 Cache.setPropertyNoSave(USE_LEGACY_GAP,
919 Boolean.toString(useLegacyGap.isSelected()));
920 Cache.setPropertyNoSave(SHOW_OV_HIDDEN_AT_START,
921 Boolean.toString(showHiddenAtStart.isSelected()));
924 * Save Structure settings
926 Cache.setPropertyNoSave(ADD_TEMPFACT_ANN,
927 Boolean.toString(addTempFactor.isSelected()));
928 Cache.setPropertyNoSave(ADD_SS_ANN,
929 Boolean.toString(addSecondaryStructure.isSelected()));
930 Cache.setPropertyNoSave(USE_RNAVIEW,
931 Boolean.toString(useRnaView.isSelected()));
932 Cache.setPropertyNoSave(STRUCT_FROM_PDB,
933 Boolean.toString(structFromPdb.isSelected()));
934 if (!Platform.isJS())
936 Cache.setPropertyNoSave(STRUCTURE_DISPLAY,
937 structViewer.getSelectedItem().toString());
939 Cache.setOrRemove(CHIMERA_PATH, chimeraPath.getText());
940 Cache.setPropertyNoSave("MAP_WITH_SIFTS",
941 Boolean.toString(siftsMapping.isSelected()));
942 SiftsSettings.setMapWithSifts(siftsMapping.isSelected());
945 * Save Output settings
947 Cache.setPropertyNoSave("EPS_RENDERING",
948 ((OptionsParam) epsRendering.getSelectedItem()).getCode());
949 Cache.setPropertyNoSave("HTML_RENDERING",
950 ((OptionsParam) htmlRendering.getSelectedItem()).getCode());
951 Cache.setPropertyNoSave("SVG_RENDERING",
952 ((OptionsParam) svgRendering.getSelectedItem()).getCode());
955 * Save Connections settings
957 Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
959 jalview.util.BrowserLauncher.resetBrowser();
961 // save user-defined and selected links
962 String menuLinks = sequenceUrlLinks.writeUrlsAsString(true);
963 if (menuLinks.isEmpty())
965 Cache.removePropertyNoSave("SEQUENCE_LINKS");
969 Cache.setPropertyNoSave("SEQUENCE_LINKS",
970 menuLinks.toString());
973 String nonMenuLinks = sequenceUrlLinks.writeUrlsAsString(false);
974 if (nonMenuLinks.isEmpty())
976 Cache.removePropertyNoSave("STORED_LINKS");
980 Cache.setPropertyNoSave("STORED_LINKS",
981 nonMenuLinks.toString());
984 Cache.setPropertyNoSave("DEFAULT_URL",
985 sequenceUrlLinks.getPrimaryUrlId());
987 Cache.setPropertyNoSave("USE_PROXY",
988 Boolean.toString(useProxy.isSelected()));
990 Cache.setOrRemove("PROXY_SERVER", proxyServerTB.getText());
992 Cache.setOrRemove("PROXY_PORT", proxyPortTB.getText());
994 if (useProxy.isSelected())
996 System.setProperty("http.proxyHost", proxyServerTB.getText());
997 System.setProperty("http.proxyPort", proxyPortTB.getText());
1001 System.setProperty("http.proxyHost", "");
1002 System.setProperty("http.proxyPort", "");
1004 Cache.setProperty("VERSION_CHECK",
1005 Boolean.toString(versioncheck.isSelected()));
1006 if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
1008 // default is false - we only set this if the user has actively agreed
1009 Cache.setProperty("USAGESTATS",
1010 Boolean.toString(usagestats.isSelected()));
1012 if (!questionnaire.isSelected())
1014 Cache.setProperty("NOQUESTIONNAIRES", "true");
1018 // special - made easy to edit a property file to disable questionnaires
1019 // by just adding the given line
1020 Cache.removeProperty("NOQUESTIONNAIRES");
1024 * Save Output settings
1026 Cache.setPropertyNoSave("BLC_JVSUFFIX",
1027 Boolean.toString(blcjv.isSelected()));
1028 Cache.setPropertyNoSave("CLUSTAL_JVSUFFIX",
1029 Boolean.toString(clustaljv.isSelected()));
1030 Cache.setPropertyNoSave("FASTA_JVSUFFIX",
1031 Boolean.toString(fastajv.isSelected()));
1032 Cache.setPropertyNoSave("MSF_JVSUFFIX",
1033 Boolean.toString(msfjv.isSelected()));
1034 Cache.setPropertyNoSave("PFAM_JVSUFFIX",
1035 Boolean.toString(pfamjv.isSelected()));
1036 Cache.setPropertyNoSave("PILEUP_JVSUFFIX",
1037 Boolean.toString(pileupjv.isSelected()));
1038 Cache.setPropertyNoSave("PIR_JVSUFFIX",
1039 Boolean.toString(pirjv.isSelected()));
1040 Cache.setPropertyNoSave("PIR_MODELLER",
1041 Boolean.toString(modellerOutput.isSelected()));
1042 Cache.setPropertyNoSave("EXPORT_EMBBED_BIOJSON",
1043 Boolean.toString(embbedBioJSON.isSelected()));
1044 jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
1046 Cache.setPropertyNoSave("FIGURE_AUTOIDWIDTH",
1047 Boolean.toString(autoIdWidth.isSelected()));
1048 userIdWidth_actionPerformed();
1049 Cache.setPropertyNoSave("FIGURE_FIXEDIDWIDTH",
1050 userIdWidth.getText());
1053 * Save Editing settings
1055 Cache.setPropertyNoSave("AUTO_CALC_CONSENSUS",
1056 Boolean.toString(autoCalculateConsCheck.isSelected()));
1057 Cache.setPropertyNoSave("SORT_BY_TREE",
1058 Boolean.toString(sortByTree.isSelected()));
1059 Cache.setPropertyNoSave("PAD_GAPS",
1060 Boolean.toString(padGaps.isSelected()));
1062 if (!Platform.isJS())
1064 wsPrefs.updateAndRefreshWsMenuConfig(false);
1068 * Save Backups settings
1070 Cache.setPropertyNoSave(BackupFiles.ENABLED,
1071 Boolean.toString(enableBackupFiles.isSelected()));
1072 int preset = getComboIntStringKey(backupfilesPresetsCombo);
1073 Cache.setPropertyNoSave(BackupFiles.NS + "_PRESET", Integer.toString(preset));
1075 if (preset == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
1077 BackupFilesPresetEntry customBFPE = getBackupfilesCurrentEntry();
1078 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
1079 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM, customBFPE);
1080 Cache.setPropertyNoSave(BackupFilesPresetEntry.CUSTOMCONFIG,
1081 customBFPE.toString());
1084 BackupFilesPresetEntry savedBFPE = BackupFilesPresetEntry.backupfilesPresetEntriesValues
1086 Cache.setPropertyNoSave(
1087 BackupFilesPresetEntry.SAVEDCONFIG, savedBFPE.toString());
1089 Cache.saveProperties();
1090 Desktop.getInstance().doConfigureStructurePrefs();
1093 frame.setClosed(true);
1094 } catch (Exception ex)
1099 public static void setAppletDefaults()
1102 // http://www.jalview.org/old/v2_8/examples/appletParameters.html
1104 // showConservation true or false Default is true.
1105 // showQuality true or false Default is true.
1106 // showConsensus true or false Default is true.
1107 // showFeatureSettings true or false Shows the feature settings window when
1109 // showTreeBootstraps true or false (default is true) show or hide branch
1111 // showTreeDistances true or false (default is true) show or hide branch
1113 // showUnlinkedTreeNodes true or false (default is false) indicate if
1114 // unassociated nodes should be highlighted in the tree view
1115 // showUnconserved true of false (default is false) When true, only gaps and
1116 // symbols different to the consensus sequence ions of the alignment
1117 // showGroupConsensus true of false (default is false) When true, shows
1118 // consensus annotation row for any groups on the alignment. (since 2.7)
1119 // showGroupConservation true of false (default is false) When true, shows
1120 // amino-acid property conservation annotation row for any groups on the
1121 // showConsensusHistogram true of false (default is true) When true, shows
1122 // the percentage occurence of the consensus symbol for each column as a
1123 // showSequenceLogo true of false (default is false) When true, shows a
1124 // sequence logo above the consensus sequence (overlaid above the Consensus
1126 Cache.setPropertyNoSave(SHOW_CONSERVATION, "true");
1127 Cache.setPropertyNoSave(SHOW_QUALITY, "false");
1128 Cache.setPropertyNoSave(SHOW_CONSENSUS, "true");
1129 Cache.setPropertyNoSave(SHOW_UNCONSERVED, "false");
1130 Cache.setPropertyNoSave(SHOW_GROUP_CONSERVATION, "false");
1131 Cache.setPropertyNoSave(SHOW_GROUP_CONSENSUS, "false");
1133 // TODO -- just a start here
1136 * Do any necessary validation before saving settings. Return focus to the
1137 * first tab which fails validation.
1141 private boolean validateSettings()
1143 if (!validateStructure())
1145 structureTab.requestFocusInWindow();
1152 protected boolean validateStructure()
1154 return validateChimeraPath();
1162 public void startupFileTextfield_mouseClicked()
1164 // TODO: JAL-3048 not needed for Jalview-JS
1165 String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
1166 JalviewFileChooser chooser = JalviewFileChooser
1167 .forRead(Cache.getProperty("LAST_DIRECTORY"), fileFormat);
1168 chooser.setFileView(new JalviewFileView());
1169 chooser.setDialogTitle(
1170 MessageManager.getString("label.select_startup_file"));
1172 int value = chooser.showOpenDialog(this);
1174 if (value == JalviewFileChooser.APPROVE_OPTION)
1176 FileFormatI format = chooser.getSelectedFormat();
1179 Cache.setPropertyNoSave("DEFAULT_FILE_FORMAT",
1182 startupFileTextfield
1183 .setText(chooser.getSelectedFile().getAbsolutePath());
1194 public void cancel_actionPerformed(ActionEvent e)
1198 if (!Platform.isJS())
1200 wsPrefs.updateWsMenuConfig(true);
1201 wsPrefs.refreshWs_actionPerformed(e);
1203 frame.setClosed(true);
1204 } catch (Exception ex)
1216 public void annotations_actionPerformed(ActionEvent e)
1218 conservation.setEnabled(annotations.isSelected());
1219 quality.setEnabled(annotations.isSelected());
1220 identity.setEnabled(annotations.isSelected());
1221 showOccupancy.setEnabled(annotations.isSelected());
1222 showGroupConsensus.setEnabled(annotations.isSelected());
1223 showGroupConservation.setEnabled(annotations.isSelected());
1224 showConsensHistogram.setEnabled(annotations.isSelected()
1225 && (identity.isSelected() || showGroupConsensus.isSelected()));
1226 showConsensLogo.setEnabled(annotations.isSelected()
1227 && (identity.isSelected() || showGroupConsensus.isSelected()));
1228 showInformationHistogram.setEnabled(annotations.isSelected());
1229 showHMMLogo.setEnabled(annotations.isSelected());
1233 public void newLink_actionPerformed(ActionEvent e)
1235 GSequenceLink link = new GSequenceLink();
1236 boolean valid = false;
1239 if (JvOptionPane.showInternalConfirmDialog(Desktop.getDesktopPane(), link,
1240 MessageManager.getString("label.new_sequence_url_link"),
1241 JvOptionPane.OK_CANCEL_OPTION, -1,
1242 null) == JvOptionPane.OK_OPTION)
1244 if (link.checkValid())
1246 if (((UrlLinkTableModel) linkUrlTable.getModel())
1247 .isUniqueName(link.getName()))
1249 ((UrlLinkTableModel) linkUrlTable.getModel())
1250 .insertRow(link.getName(), link.getURL());
1255 link.notifyDuplicate();
1268 public void editLink_actionPerformed(ActionEvent e)
1270 GSequenceLink link = new GSequenceLink();
1272 int index = linkUrlTable.getSelectedRow();
1275 // button no longer enabled if row is not selected
1276 Cache.log.debug("Edit with no row selected in linkUrlTable");
1280 int nameCol = ((UrlLinkTableModel) linkUrlTable.getModel())
1282 int urlCol = ((UrlLinkTableModel) linkUrlTable.getModel())
1284 String oldName = linkUrlTable.getValueAt(index, nameCol).toString();
1285 link.setName(oldName);
1286 link.setURL(linkUrlTable.getValueAt(index, urlCol).toString());
1288 boolean valid = false;
1291 if (JvOptionPane.showInternalConfirmDialog(Desktop.getDesktopPane(), link,
1292 MessageManager.getString("label.edit_sequence_url_link"),
1293 JvOptionPane.OK_CANCEL_OPTION, -1,
1294 null) == JvOptionPane.OK_OPTION)
1296 if (link.checkValid())
1298 if ((oldName.equals(link.getName()))
1299 || (((UrlLinkTableModel) linkUrlTable.getModel())
1300 .isUniqueName(link.getName())))
1302 linkUrlTable.setValueAt(link.getName(), index, nameCol);
1303 linkUrlTable.setValueAt(link.getURL(), index, urlCol);
1308 link.notifyDuplicate();
1321 public void deleteLink_actionPerformed(ActionEvent e)
1323 int index = linkUrlTable.getSelectedRow();
1324 int modelIndex = -1;
1327 // button no longer enabled if row is not selected
1328 Cache.log.debug("Delete with no row selected in linkUrlTable");
1333 modelIndex = linkUrlTable.convertRowIndexToModel(index);
1336 // make sure we use the model index to delete, and not the table index
1337 ((UrlLinkTableModel) linkUrlTable.getModel()).removeRow(modelIndex);
1341 public void defaultBrowser_mouseClicked(MouseEvent e)
1343 // TODO: JAL-3048 not needed for j2s
1344 if (!Platform.isJS()) // BH 2019
1351 JFileChooser chooser = new JFileChooser(".");
1352 chooser.setDialogTitle(
1353 MessageManager.getString("label.select_default_browser"));
1355 int value = chooser.showOpenDialog(this);
1357 if (value == JFileChooser.APPROVE_OPTION)
1359 defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath());
1368 * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event
1372 protected void showunconserved_actionPerformed(ActionEvent e)
1374 // TODO Auto-generated method stub
1375 super.showunconserved_actionPerformed(e);
1378 public static List<String> getGroupURLLinks()
1380 return groupURLLinks;
1384 public void minColour_actionPerformed(JPanel panel)
1386 JalviewColourChooser.showColourChooser(this,
1387 MessageManager.getString("label.select_colour_minimum_value"),
1392 public void maxColour_actionPerformed(JPanel panel)
1394 JalviewColourChooser.showColourChooser(this,
1395 MessageManager.getString("label.select_colour_maximum_value"),
1400 public void gapColour_actionPerformed(JPanel gap)
1402 if (!useLegacyGap.isSelected())
1404 JalviewColourChooser.showColourChooser(this,
1405 MessageManager.getString("label.select_gap_colour"),
1411 public void hiddenColour_actionPerformed(JPanel hidden)
1413 JalviewColourChooser.showColourChooser(this,
1414 MessageManager.getString("label.select_hidden_colour"),
1419 protected void useLegacyGaps_actionPerformed(ActionEvent e)
1421 boolean enabled = useLegacyGap.isSelected();
1424 gapColour.setBackground(
1425 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_LEGACY_GAP);
1429 gapColour.setBackground(
1430 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP);
1432 gapColour.setEnabled(!enabled);
1433 gapLabel.setEnabled(!enabled);
1437 protected void resetOvDefaults_actionPerformed(ActionEvent e)
1439 useLegacyGap.setSelected(false);
1440 useLegacyGaps_actionPerformed(null);
1441 showHiddenAtStart.setSelected(false);
1442 hiddenColour.setBackground(
1443 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_HIDDEN);
1447 protected void userIdWidth_actionPerformed()
1451 String val = userIdWidth.getText().trim();
1452 if (val.length() > 0)
1454 Integer iw = Integer.parseInt(val);
1455 if (iw.intValue() < 12)
1457 throw new NumberFormatException();
1459 userIdWidth.setText(iw.toString());
1461 } catch (NumberFormatException x)
1463 userIdWidth.setText("");
1464 JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
1466 .getString("warn.user_defined_width_requirements"),
1467 MessageManager.getString("label.invalid_id_column_width"),
1468 JvOptionPane.WARNING_MESSAGE);
1473 protected void autoIdWidth_actionPerformed()
1475 userIdWidth.setEnabled(!autoIdWidth.isSelected());
1476 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
1480 * Returns true if chimera path is to a valid executable, else show an error
1483 private boolean validateChimeraPath()
1485 if (chimeraPath.getText().trim().length() > 0)
1487 File f = new File(chimeraPath.getText());
1488 if (!f.canExecute())
1490 JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
1491 MessageManager.getString("label.invalid_chimera_path"),
1492 MessageManager.getString("label.invalid_name"),
1493 JvOptionPane.ERROR_MESSAGE);
1501 * Returns true if the given text field contains a path to a folder that
1502 * contains an executable with the given name, else false (after showing a
1503 * warning dialog). The executable name will be tried with .exe appended if not
1509 protected boolean validateExecutablePath(JTextField textField, String executable)
1511 String folder = textField.getText().trim();
1513 if (FileUtils.getExecutable(executable, folder) != null)
1517 if (folder.length() > 0)
1519 JvOptionPane.showInternalMessageDialog(Desktop.getInstance(),
1520 MessageManager.formatMessage("label.executable_not_found",
1522 MessageManager.getString("label.invalid_folder"),
1523 JvOptionPane.ERROR_MESSAGE);
1529 * Checks if a file can be executed
1532 * the path to the file
1535 public boolean canExecute(String path)
1537 File file = new File(path);
1538 if (!file.canExecute())
1540 file = new File(path + ".exe");
1542 if (!file.canExecute())
1552 * If Chimera is selected, check it can be found on default or user-specified
1553 * path, if not show a warning/help dialog.
1556 protected void structureViewer_actionPerformed(String selectedItem)
1558 if (!selectedItem.equals(ViewerType.CHIMERA.name()))
1562 boolean found = false;
1565 * Try user-specified and standard paths for Chimera executable.
1567 List<String> paths = StructureManager.getChimeraPaths();
1568 paths.add(0, chimeraPath.getText());
1569 for (String path : paths)
1571 if (new File(path.trim()).canExecute())
1579 String[] options = { "OK", "Help" };
1580 int showHelp = JvOptionPane.showInternalOptionDialog(Desktop.getDesktopPane(),
1581 JvSwingUtils.wrapTooltip(true,
1582 MessageManager.getString("label.chimera_missing")),
1583 "", JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE,
1584 null, options, options[0]);
1585 if (showHelp == JvOptionPane.NO_OPTION)
1589 Help.showHelpWindow(HelpId.StructureViewer);
1590 } catch (HelpSetException e)
1592 e.printStackTrace();
1599 protected void validateHmmerPath()
1601 validateExecutablePath(hmmerPath, HmmerCommand.HMMBUILD);
1605 protected void validateCygwinPath()
1607 validateExecutablePath(cygwinPath, "run");
1610 public class OptionsParam
1612 private String name;
1614 private String code;
1616 public OptionsParam(String name, String code)
1622 public String getName()
1627 public void setName(String name)
1632 public String getCode()
1637 public void setCode(String code)
1643 public String toString()
1649 public boolean equals(Object that)
1651 if (!(that instanceof OptionsParam))
1655 return this.code.equalsIgnoreCase(((OptionsParam) that).code);
1659 public int hashCode()
1661 return name.hashCode() + code.hashCode();
1665 private class UrlListSelectionHandler implements ListSelectionListener
1669 public void valueChanged(ListSelectionEvent e)
1671 ListSelectionModel lsm = (ListSelectionModel) e.getSource();
1673 int index = lsm.getMinSelectionIndex();
1676 // no selection, so disable delete/edit buttons
1677 editLink.setEnabled(false);
1678 deleteLink.setEnabled(false);
1681 int modelIndex = linkUrlTable.convertRowIndexToModel(index);
1683 // enable/disable edit and delete link buttons
1684 if (((UrlLinkTableModel) linkUrlTable.getModel())
1685 .isRowDeletable(modelIndex))
1687 deleteLink.setEnabled(true);
1691 deleteLink.setEnabled(false);
1694 if (((UrlLinkTableModel) linkUrlTable.getModel())
1695 .isRowEditable(modelIndex))
1697 editLink.setEnabled(true);
1701 editLink.setEnabled(false);