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.BackupFiles;
28 import jalview.io.BackupFilesPresetEntry;
29 import jalview.io.FileFormatI;
30 import jalview.io.JalviewFileChooser;
31 import jalview.io.JalviewFileView;
32 import jalview.jbgui.GPreferences;
33 import jalview.jbgui.GSequenceLink;
34 import jalview.schemes.ColourSchemeI;
35 import jalview.schemes.ColourSchemes;
36 import jalview.schemes.ResidueColourScheme;
37 import jalview.urls.UrlLinkTableModel;
38 import jalview.urls.api.UrlProviderFactoryI;
39 import jalview.urls.api.UrlProviderI;
40 import jalview.urls.desktop.DesktopUrlProviderFactory;
41 import jalview.util.BrowserLauncher;
42 import jalview.util.MessageManager;
43 import jalview.util.Platform;
44 import jalview.util.UrlConstants;
45 import jalview.ws.sifts.SiftsSettings;
47 import java.awt.BorderLayout;
48 import java.awt.Color;
49 import java.awt.Component;
50 import java.awt.Dimension;
52 import java.awt.event.ActionEvent;
53 import java.awt.event.ActionListener;
54 import java.awt.event.MouseEvent;
56 import java.util.ArrayList;
57 import java.util.List;
59 import javax.help.HelpSetException;
60 import javax.swing.JComboBox;
61 import javax.swing.JFileChooser;
62 import javax.swing.JInternalFrame;
63 import javax.swing.JPanel;
64 import javax.swing.ListSelectionModel;
65 import javax.swing.RowFilter;
66 import javax.swing.RowSorter;
67 import javax.swing.SortOrder;
68 import javax.swing.event.DocumentEvent;
69 import javax.swing.event.DocumentListener;
70 import javax.swing.event.ListSelectionEvent;
71 import javax.swing.event.ListSelectionListener;
72 import javax.swing.table.TableCellRenderer;
73 import javax.swing.table.TableColumn;
74 import javax.swing.table.TableModel;
75 import javax.swing.table.TableRowSorter;
77 import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
85 @SuppressWarnings("serial")
86 public class Preferences extends GPreferences
89 // original to develop
91 public static final String ENABLE_SPLIT_FRAME = "ENABLE_SPLIT_FRAME";
93 public static final String SCALE_PROTEIN_TO_CDNA = "SCALE_PROTEIN_TO_CDNA";
95 public static final String DEFAULT_COLOUR = "DEFAULT_COLOUR";
97 public static final String DEFAULT_COLOUR_PROT = "DEFAULT_COLOUR_PROT";
99 public static final String DEFAULT_COLOUR_NUC = "DEFAULT_COLOUR_NUC";
101 public static final String ADD_TEMPFACT_ANN = "ADD_TEMPFACT_ANN";
103 public static final String ADD_SS_ANN = "ADD_SS_ANN";
105 public static final String USE_RNAVIEW = "USE_RNAVIEW";
107 public static final String STRUCT_FROM_PDB = "STRUCT_FROM_PDB";
109 public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY";
111 public static final String CHIMERA_PATH = "CHIMERA_PATH";
113 public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS";
115 public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE";
117 public static final String SHOW_OCCUPANCY = "SHOW_OCCUPANCY";
119 public static final String SHOW_OV_HIDDEN_AT_START = "SHOW_OV_HIDDEN_AT_START";
121 public static final String USE_LEGACY_GAP = "USE_LEGACY_GAP";
123 public static final String GAP_COLOUR = "GAP_COLOUR";
125 public static final String HIDDEN_COLOUR = "HIDDEN_COLOUR";
127 private static final int MIN_FONT_SIZE = 1;
129 private static final int MAX_FONT_SIZE = 30;
133 public static final String ALLOW_UNPUBLISHED_PDB_QUERYING = "ALLOW_UNPUBLISHED_PDB_QUERYING";
135 public static final String ANNOTATIONCOLOUR_MAX = "ANNOTATIONCOLOUR_MAX";
137 public static final String ANNOTATIONCOLOUR_MIN = "ANNOTATIONCOLOUR_MIN";
139 public static final String ANTI_ALIAS = "ANTI_ALIAS";
141 public static final String AUTO_CALC_CONSENSUS = "AUTO_CALC_CONSENSUS";
143 public static final String AUTOASSOCIATE_PDBANDSEQS = "AUTOASSOCIATE_PDBANDSEQS";
145 public static final String BLOSUM62_PCA_FOR_NUCLEOTIDE = "BLOSUM62_PCA_FOR_NUCLEOTIDE";
147 public static final String CENTRE_COLUMN_LABELS = "CENTRE_COLUMN_LABELS";
149 public static final String DBREFFETCH_USEPICR = "DBREFFETCH_USEPICR";
151 public static final String FIGURE_AUTOIDWIDTH = "FIGURE_AUTOIDWIDTH";
153 public static final String FIGURE_FIXEDIDWIDTH = "FIGURE_FIXEDIDWIDTH";
155 public static final String FOLLOW_SELECTIONS = "FOLLOW_SELECTIONS";
157 public static final String FONT_NAME = "FONT_NAME";
159 public static final String FONT_SIZE = "FONT_SIZE";
161 public static final String FONT_STYLE = "FONT_STYLE";
163 public static final String GAP_SYMBOL = "GAP_SYMBOL";
165 public static final String HIDE_INTRONS = "HIDE_INTRONS";
167 public static final String ID_ITALICS = "ID_ITALICS";
169 public static final String ID_ORG_HOSTURL = "ID_ORG_HOSTURL";
171 public static final String MAP_WITH_SIFTS = "MAP_WITH_SIFTS";
173 public static final String NOQUESTIONNAIRES = "NOQUESTIONNAIRES";
175 public static final String NORMALISE_CONSENSUS_LOGO = "NORMALISE_CONSENSUS_LOGO";
177 public static final String NORMALISE_LOGO = "NORMALISE_LOGO";
179 public static final String PAD_GAPS = "PAD_GAPS";
181 public static final String PDB_DOWNLOAD_FORMAT = "PDB_DOWNLOAD_FORMAT";
183 public static final String QUESTIONNAIRE = "QUESTIONNAIRE";
185 public static final String RELAXEDSEQIDMATCHING = "RELAXEDSEQIDMATCHING";
187 public static final String RIGHT_ALIGN_IDS = "RIGHT_ALIGN_IDS";
189 public static final String SHOW_ANNOTATIONS = "SHOW_ANNOTATIONS";
191 public static final String SHOW_CONSENSUS = "SHOW_CONSENSUS";
193 public static final String SHOW_CONSENSUS_HISTOGRAM = "SHOW_CONSENSUS_HISTOGRAM";
195 public static final String SHOW_CONSENSUS_LOGO = "SHOW_CONSENSUS_LOGO";
197 public static final String SHOW_CONSERVATION = "SHOW_CONSERVATION";
199 public static final String SHOW_DBREFS_TOOLTIP = "SHOW_DBREFS_TOOLTIP";
201 public static final String SHOW_GROUP_CONSENSUS = "SHOW_GROUP_CONSENSUS";
203 public static final String SHOW_GROUP_CONSERVATION = "SHOW_GROUP_CONSERVATION";
205 public static final String SHOW_IDENTITY = "SHOW_IDENTITY";
207 public static final String SHOW_FULLSCREEN = "SHOW_FULLSCREEN";
209 public static final String SHOW_JVSUFFIX = "SHOW_JVSUFFIX";
211 public static final String SHOW_NPFEATS_TOOLTIP = "SHOW_NPFEATS_TOOLTIP";
213 public static final String SHOW_OVERVIEW = "SHOW_OVERVIEW";
215 public static final String SHOW_QUALITY = "SHOW_QUALITY";
217 public static final String SHOW_UNCONSERVED = "SHOW_UNCONSERVED";
219 public static final String SORT_ALIGNMENT = "SORT_ALIGNMENT";
221 public static final String SORT_BY_TREE = "SORT_BY_TREE";
223 public static final String STRUCTURE_DIMENSIONS = "STRUCTURE_DIMENSIONS";
225 public static final String UNIPROT_DOMAIN = "UNIPROT_DOMAIN";
227 public static final String USE_FULL_SO = "USE_FULL_SO";
229 public static final String USER_DEFINED_COLOURS = "USER_DEFINED_COLOURS";
231 public static final String WRAP_ALIGNMENT = "WRAP_ALIGNMENT";
234 public static final Dimension DEFAULT_STRUCTURE_DIMENSIONS = new Dimension(
238 * Holds name and link separated with | character. Sequence ID must be
239 * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$
241 public static UrlProviderI sequenceUrlLinks; // must be nonfinal for test
243 public final static UrlLinkTableModel dataModel;
246 * Holds name and link separated with | character. Sequence IDS and Sequences
247 * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and
248 * $SEQUENCES$ or $SEQUENCES=/.possible | chars ./=$ and separation character
249 * for first and second token specified after a pipe character at end |,|.
250 * (TODO: proper escape for using | to separate ids or sequences
253 public static final List<String> groupURLLinks; // not implemented
257 // get links selected to be in the menu (SEQUENCE_LINKS)
258 // and links entered by the user but not selected (STORED_LINKS)
259 String inMenuString = Cache.getDefault("SEQUENCE_LINKS", "");
260 String notInMenuString = Cache.getDefault("STORED_LINKS", "");
261 String defaultUrl = Cache.getDefault("DEFAULT_URL",
262 UrlConstants.DEFAULT_LABEL);
264 // if both links lists are empty, add the DEFAULT_URL link
265 // otherwise we assume the default link is in one of the lists
266 if (inMenuString.isEmpty() && notInMenuString.isEmpty())
268 inMenuString = UrlConstants.DEFAULT_STRING;
270 UrlProviderFactoryI factory = new DesktopUrlProviderFactory(defaultUrl,
271 inMenuString, notInMenuString);
272 sequenceUrlLinks = factory.createUrlProvider();
273 dataModel = new UrlLinkTableModel(sequenceUrlLinks);
276 * TODO: reformulate groupURL encoding so two or more can be stored in the
277 * .properties file as '|' separated strings
280 groupURLLinks = new ArrayList<>(); // not implemented
283 JInternalFrame frame;
285 private WsPreferences wsPrefs;
287 private OptionsParam promptEachTimeOpt = new OptionsParam(
288 MessageManager.getString("label.prompt_each_time"),
291 private OptionsParam lineArtOpt = new OptionsParam(
292 MessageManager.getString("label.lineart"), "Lineart");
294 private OptionsParam textOpt = new OptionsParam(
295 MessageManager.getString("action.text"), "Text");
298 * Creates a new Preferences object.
303 frame = new JInternalFrame();
304 frame.setContentPane(this);
305 if (!Platform.isJS())
312 wsPrefs = new WsPreferences();
313 wsTab.add(wsPrefs, BorderLayout.CENTER);
315 int width = 700, height = 510; // BH 2019.07.12 added 60 to height and 40 to
316 // width (for Visual check boxes and Links
317 // "Double Click" header)
318 // BH 2019.09.24 added 20 to width
319 // (structure panel was too small anyway, and I added a default dimension
321 if (Platform.isAMacAndNotJS())
324 height = 540; // BH 2019.07.12 added 30
327 Desktop.addInternalFrame(frame,
328 MessageManager.getString("label.preferences"), width, height);
329 frame.setMinimumSize(new Dimension(width, height));
332 * Set Visual tab defaults
334 seqLimit.setSelected(Cache.getDefault(SHOW_JVSUFFIX, true));
335 rightAlign.setSelected(Cache.getDefault(RIGHT_ALIGN_IDS, false));
336 fullScreen.setSelected(Cache.getDefault(SHOW_FULLSCREEN, false));
337 annotations.setSelected(Cache.getDefault(SHOW_ANNOTATIONS, true));
339 conservation.setSelected(Cache.getDefault(SHOW_CONSERVATION, true));
340 quality.setSelected(Cache.getDefault(SHOW_QUALITY, true));
341 identity.setSelected(Cache.getDefault(SHOW_IDENTITY, true));
342 openoverv.setSelected(Cache.getDefault(SHOW_OVERVIEW, false));
344 .setSelected(Cache.getDefault(SHOW_UNCONSERVED, false));
345 showOccupancy.setSelected(Cache.getDefault(SHOW_OCCUPANCY, false));
347 .setSelected(Cache.getDefault(SHOW_GROUP_CONSENSUS, false));
348 showGroupConservation.setSelected(
349 Cache.getDefault(SHOW_GROUP_CONSERVATION, false));
350 showConsensHistogram.setSelected(
351 Cache.getDefault(SHOW_CONSENSUS_HISTOGRAM, true));
353 .setSelected(Cache.getDefault(SHOW_CONSENSUS_LOGO, false));
355 .setSelected(Cache.getDefault(SHOW_NPFEATS_TOOLTIP, true));
357 .setSelected(Cache.getDefault(SHOW_DBREFS_TOOLTIP, true));
359 String[] fonts = java.awt.GraphicsEnvironment
360 .getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
361 for (int i = 0; i < fonts.length; i++)
363 fontNameCB.addItem(fonts[i]);
366 for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++)
368 fontSizeCB.addItem(i + "");
371 fontStyleCB.addItem("plain");
372 fontStyleCB.addItem("bold");
373 fontStyleCB.addItem("italic");
375 fontNameCB.setSelectedItem(Cache.getDefault(FONT_NAME, "SansSerif"));
376 fontSizeCB.setSelectedItem(Cache.getDefault(FONT_SIZE, "10"));
377 fontStyleCB.setSelectedItem(
378 Cache.getDefault(FONT_STYLE, Font.PLAIN + ""));
380 smoothFont.setSelected(Cache.getDefault(ANTI_ALIAS, false));
382 .setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA, false));
384 idItalics.setSelected(Cache.getDefault(ID_ITALICS, true));
386 wrap.setSelected(Cache.getDefault(WRAP_ALIGNMENT, false));
388 gapSymbolCB.addItem("-");
389 gapSymbolCB.addItem(".");
391 gapSymbolCB.setSelectedItem(Cache.getDefault(GAP_SYMBOL, "-"));
393 sortby.addItem("No sort");
394 sortby.addItem("Id");
395 sortby.addItem("Pairwise Identity");
396 sortby.setSelectedItem(Cache.getDefault(SORT_ALIGNMENT, "No sort"));
398 sortAnnBy.addItem(SequenceAnnotationOrder.NONE.toString());
400 .addItem(SequenceAnnotationOrder.SEQUENCE_AND_LABEL.toString());
402 .addItem(SequenceAnnotationOrder.LABEL_AND_SEQUENCE.toString());
403 SequenceAnnotationOrder savedSort = SequenceAnnotationOrder
404 .valueOf(Cache.getDefault(SORT_ANNOTATIONS,
405 SequenceAnnotationOrder.NONE.name()));
406 sortAnnBy.setSelectedItem(savedSort.toString());
408 sortAutocalc.addItem("Autocalculated first");
409 sortAutocalc.addItem("Autocalculated last");
410 final boolean showAbove = Cache.getDefault(SHOW_AUTOCALC_ABOVE, true);
411 sortAutocalc.setSelectedItem(showAbove ? sortAutocalc.getItemAt(0)
412 : sortAutocalc.getItemAt(1));
414 .setSelected(Cache.getDefault("SHOW_STARTUP_FILE", true));
415 startupFileTextfield.setText(Cache.getDefault("STARTUP_FILE",
416 Cache.getDefault("www.jalview.org", "http://www.jalview.org")
417 + "/examples/exampleFile_2_3.jar"));
420 * Set Colours tab defaults
422 protColour.addItem(ResidueColourScheme.NONE);
423 nucColour.addItem(ResidueColourScheme.NONE);
424 for (ColourSchemeI cs : ColourSchemes.getInstance().getColourSchemes())
426 String name = cs.getSchemeName();
427 protColour.addItem(name);
428 nucColour.addItem(name);
430 String oldProp = Cache.getDefault(DEFAULT_COLOUR,
431 ResidueColourScheme.NONE);
432 String newProp = Cache.getDefault(DEFAULT_COLOUR_PROT, null);
433 protColour.setSelectedItem(newProp != null ? newProp : oldProp);
434 newProp = Cache.getDefault(DEFAULT_COLOUR_NUC, null);
435 nucColour.setSelectedItem(newProp != null ? newProp : oldProp);
436 minColour.setBackground(
437 Cache.getDefaultColour(ANNOTATIONCOLOUR_MIN, Color.orange));
438 maxColour.setBackground(
439 Cache.getDefaultColour(ANNOTATIONCOLOUR_MAX, Color.red));
442 * Set overview panel defaults
444 gapColour.setBackground(
445 Cache.getDefaultColour(GAP_COLOUR,
446 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP));
447 hiddenColour.setBackground(
448 Cache.getDefaultColour(HIDDEN_COLOUR,
449 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_HIDDEN));
450 useLegacyGap.setSelected(Cache.getDefault(USE_LEGACY_GAP, false));
451 gapLabel.setEnabled(!useLegacyGap.isSelected());
452 gapColour.setEnabled(!useLegacyGap.isSelected());
454 .setSelected(Cache.getDefault(SHOW_OV_HIDDEN_AT_START, false));
457 * Set Structure tab defaults.
459 final boolean structSelected = Cache.getDefault(STRUCT_FROM_PDB, false);
460 structFromPdb.setSelected(structSelected);
461 useRnaView.setSelected(Cache.getDefault(USE_RNAVIEW, false));
462 useRnaView.setEnabled(structSelected);
463 addSecondaryStructure.setSelected(Cache.getDefault(ADD_SS_ANN, false));
464 addSecondaryStructure.setEnabled(structSelected);
465 addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, false));
466 addTempFactor.setEnabled(structSelected);
467 structViewer.setSelectedItem(
468 Cache.getDefault(STRUCTURE_DISPLAY, ViewerType.JMOL.name()));
469 Dimension d = Cache.getDefaultDim(STRUCTURE_DIMENSIONS,
470 DEFAULT_STRUCTURE_DIMENSIONS);
471 String s = d.width + "," + d.height;
472 structureDimensions.setText(s);
473 chimeraPath.setText(Cache.getDefault(CHIMERA_PATH, ""));
474 chimeraPath.addActionListener(new ActionListener()
477 public void actionPerformed(ActionEvent e)
479 validateChimeraPath();
483 if (Cache.getDefault(MAP_WITH_SIFTS, false))
485 siftsMapping.setSelected(true);
489 nwMapping.setSelected(true);
493 .setMapWithSifts(Cache.getDefault(MAP_WITH_SIFTS, false));
496 * Set Connections tab defaults
500 linkUrlTable.setModel(dataModel);
501 final TableRowSorter<TableModel> sorter = new TableRowSorter<>(
502 linkUrlTable.getModel());
503 linkUrlTable.setRowSorter(sorter);
504 List<RowSorter.SortKey> sortKeys = new ArrayList<>();
506 UrlLinkTableModel m = (UrlLinkTableModel) linkUrlTable.getModel();
507 sortKeys.add(new RowSorter.SortKey(m.getPrimaryColumn(),
508 SortOrder.DESCENDING));
509 sortKeys.add(new RowSorter.SortKey(m.getSelectedColumn(),
510 SortOrder.DESCENDING));
512 new RowSorter.SortKey(m.getNameColumn(), SortOrder.ASCENDING));
514 sorter.setSortKeys(sortKeys);
515 // BH 2018 setSortKeys will do the sort
519 ActionListener onReset;
520 onReset = new ActionListener()
523 public void actionPerformed(ActionEvent e)
525 filterTB.setText("");
526 sorter.setRowFilter(RowFilter.regexFilter(""));
530 doReset.addActionListener(onReset);
532 // filter to display only custom urls
533 final RowFilter<TableModel, Object> customUrlFilter = new RowFilter<TableModel, Object>()
536 public boolean include(
537 Entry<? extends TableModel, ? extends Object> entry)
539 return ((UrlLinkTableModel) entry.getModel()).isUserEntry(entry);
543 final TableRowSorter<TableModel> customSorter = new TableRowSorter<>(
544 linkUrlTable.getModel());
545 customSorter.setRowFilter(customUrlFilter);
547 ActionListener onCustomOnly;
548 onCustomOnly = new ActionListener()
551 public void actionPerformed(ActionEvent e)
553 filterTB.setText("");
554 sorter.setRowFilter(customUrlFilter);
557 userOnly.addActionListener(onCustomOnly);
559 filterTB.getDocument().addDocumentListener(new DocumentListener()
561 String caseInsensitiveFlag = "(?i)";
564 public void changedUpdate(DocumentEvent e)
566 sorter.setRowFilter(RowFilter
567 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
571 public void removeUpdate(DocumentEvent e)
573 sorter.setRowFilter(RowFilter
574 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
578 public void insertUpdate(DocumentEvent e)
580 sorter.setRowFilter(RowFilter
581 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
585 // set up list selection functionality
586 linkUrlTable.getSelectionModel()
587 .addListSelectionListener(new UrlListSelectionHandler());
589 // set up radio buttons
590 int onClickCol = ((UrlLinkTableModel) linkUrlTable.getModel())
592 String onClickName = linkUrlTable.getColumnName(onClickCol);
593 linkUrlTable.getColumn(onClickName)
594 .setCellRenderer(new RadioButtonRenderer());
595 linkUrlTable.getColumn(onClickName)
596 .setCellEditor(new RadioButtonEditor());
598 // get boolean columns and resize those to min possible
599 for (int column = 0; column < linkUrlTable.getColumnCount(); column++)
601 if (linkUrlTable.getModel().getColumnClass(column)
602 .equals(Boolean.class))
604 TableColumn tableColumn = linkUrlTable.getColumnModel()
606 int preferredWidth = tableColumn.getMinWidth();
608 TableCellRenderer cellRenderer = linkUrlTable.getCellRenderer(0,
610 Component c = linkUrlTable.prepareRenderer(cellRenderer, 0, column);
611 int cwidth = c.getPreferredSize().width
612 + linkUrlTable.getIntercellSpacing().width;
613 preferredWidth = Math.max(preferredWidth, cwidth);
615 tableColumn.setPreferredWidth(preferredWidth);
619 useProxy.setSelected(Cache.getDefault("USE_PROXY", false));
620 useProxy_actionPerformed(); // make sure useProxy is correctly initialised
621 proxyServerTB.setText(Cache.getDefault("PROXY_SERVER", ""));
622 proxyPortTB.setText(Cache.getDefault("PROXY_PORT", ""));
624 defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
626 usagestats.setSelected(Cache.getDefault("USAGESTATS", false));
627 // note antisense here: default is true
629 .setSelected(Cache.getProperty(NOQUESTIONNAIRES) == null);
630 versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true));
633 * Set Output tab defaults
635 setupOutputCombo(epsRendering, "EPS_RENDERING");
636 setupOutputCombo(htmlRendering, "HTML_RENDERING");
637 setupOutputCombo(svgRendering, "SVG_RENDERING");
638 autoIdWidth.setSelected(Cache.getDefault(FIGURE_AUTOIDWIDTH, false));
639 userIdWidth.setEnabled(!autoIdWidth.isSelected());
640 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
641 Integer wi = Cache.getIntegerProperty(FIGURE_FIXEDIDWIDTH);
642 userIdWidth.setText(wi == null ? "" : wi.toString());
643 // TODO: refactor to use common enum via FormatAdapter and allow extension
644 // for new flat file formats
645 blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
646 clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
647 fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
648 msfjv.setSelected(Cache.getDefault("MSF_JVSUFFIX", true));
649 pfamjv.setSelected(Cache.getDefault("PFAM_JVSUFFIX", true));
650 pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true));
651 pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true));
652 modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false));
654 .setSelected(Cache.getDefault("EXPORT_EMBBED_BIOJSON", true));
657 * Set Editing tab defaults
659 autoCalculateConsCheck
660 .setSelected(Cache.getDefault(AUTO_CALC_CONSENSUS, true));
661 padGaps.setSelected(Cache.getDefault(PAD_GAPS, false));
662 sortByTree.setSelected(Cache.getDefault(SORT_BY_TREE, false));
664 annotations_actionPerformed(null); // update the display of the annotation
669 * Set Backups tab defaults
671 if (!Platform.isJS())
673 loadLastSavedBackupsOptions();
679 * A helper method that sets the items and initial selection in a character
680 * rendering option list (Prompt each time/Lineart/Text)
685 protected void setupOutputCombo(JComboBox<Object> comboBox,
688 comboBox.addItem(promptEachTimeOpt);
689 comboBox.addItem(lineArtOpt);
690 comboBox.addItem(textOpt);
693 * JalviewJS doesn't support Lineart so force it to Text
695 String defaultOption = Platform.isJS() ? "Text"
696 : Cache.getDefault(propertyKey, "Prompt each time");
697 if (defaultOption.equalsIgnoreCase("Text"))
699 comboBox.setSelectedItem(textOpt);
701 else if (defaultOption.equalsIgnoreCase("Lineart"))
703 comboBox.setSelectedItem(lineArtOpt);
707 comboBox.setSelectedItem(promptEachTimeOpt);
712 * Save user selections on the Preferences tabs to the Cache and write out to
718 public void ok_actionPerformed(ActionEvent e)
720 if (!validateSettings())
726 * Save Visual settings
728 Cache.setPropertyNoSave(SHOW_JVSUFFIX,
729 Boolean.toString(seqLimit.isSelected()));
730 Cache.setPropertyNoSave(RIGHT_ALIGN_IDS,
731 Boolean.toString(rightAlign.isSelected()));
732 Cache.setPropertyNoSave(SHOW_FULLSCREEN,
733 Boolean.toString(fullScreen.isSelected()));
734 Cache.setPropertyNoSave(SHOW_OVERVIEW,
735 Boolean.toString(openoverv.isSelected()));
736 Cache.setPropertyNoSave(SHOW_ANNOTATIONS,
737 Boolean.toString(annotations.isSelected()));
738 Cache.setPropertyNoSave(SHOW_CONSERVATION,
739 Boolean.toString(conservation.isSelected()));
740 Cache.setPropertyNoSave(SHOW_QUALITY,
741 Boolean.toString(quality.isSelected()));
742 Cache.setPropertyNoSave(SHOW_IDENTITY,
743 Boolean.toString(identity.isSelected()));
745 Cache.setPropertyNoSave(GAP_SYMBOL,
746 gapSymbolCB.getSelectedItem().toString());
748 Cache.setPropertyNoSave(FONT_NAME,
749 fontNameCB.getSelectedItem().toString());
750 Cache.setPropertyNoSave(FONT_STYLE,
751 fontStyleCB.getSelectedItem().toString());
752 Cache.setPropertyNoSave(FONT_SIZE,
753 fontSizeCB.getSelectedItem().toString());
755 Cache.setPropertyNoSave(ID_ITALICS,
756 Boolean.toString(idItalics.isSelected()));
757 Cache.setPropertyNoSave(SHOW_UNCONSERVED,
758 Boolean.toString(showUnconserved.isSelected()));
759 Cache.setPropertyNoSave(SHOW_OCCUPANCY,
760 Boolean.toString(showOccupancy.isSelected()));
761 Cache.setPropertyNoSave(SHOW_GROUP_CONSENSUS,
762 Boolean.toString(showGroupConsensus.isSelected()));
763 Cache.setPropertyNoSave(SHOW_GROUP_CONSERVATION,
764 Boolean.toString(showGroupConservation.isSelected()));
765 Cache.setPropertyNoSave(SHOW_CONSENSUS_HISTOGRAM,
766 Boolean.toString(showConsensHistogram.isSelected()));
767 Cache.setPropertyNoSave(SHOW_CONSENSUS_LOGO,
768 Boolean.toString(showConsensLogo.isSelected()));
769 Cache.setPropertyNoSave(ANTI_ALIAS,
770 Boolean.toString(smoothFont.isSelected()));
771 Cache.setPropertyNoSave(SCALE_PROTEIN_TO_CDNA,
772 Boolean.toString(scaleProteinToCdna.isSelected()));
773 Cache.setPropertyNoSave(SHOW_NPFEATS_TOOLTIP,
774 Boolean.toString(showNpTooltip.isSelected()));
775 Cache.setPropertyNoSave(SHOW_DBREFS_TOOLTIP,
776 Boolean.toString(showDbRefTooltip.isSelected()));
778 Cache.setPropertyNoSave(WRAP_ALIGNMENT,
779 Boolean.toString(wrap.isSelected()));
781 Cache.setPropertyNoSave("STARTUP_FILE", startupFileTextfield.getText());
782 Cache.setPropertyNoSave("SHOW_STARTUP_FILE",
783 Boolean.toString(startupCheckbox.isSelected()));
785 Cache.setPropertyNoSave(SORT_ALIGNMENT,
786 sortby.getSelectedItem().toString());
788 // convert description of sort order to enum name for save
789 SequenceAnnotationOrder annSortOrder = SequenceAnnotationOrder
790 .forDescription(sortAnnBy.getSelectedItem().toString());
791 if (annSortOrder != null)
793 Cache.setPropertyNoSave(SORT_ANNOTATIONS, annSortOrder.name());
796 final boolean showAutocalcFirst = sortAutocalc.getSelectedIndex() == 0;
797 Cache.setPropertyNoSave(SHOW_AUTOCALC_ABOVE,
798 Boolean.valueOf(showAutocalcFirst).toString());
801 * Save Colours settings
803 Cache.setPropertyNoSave(DEFAULT_COLOUR_PROT,
804 protColour.getSelectedItem().toString());
805 Cache.setPropertyNoSave(DEFAULT_COLOUR_NUC,
806 nucColour.getSelectedItem().toString());
807 Cache.setColourPropertyNoSave(ANNOTATIONCOLOUR_MIN,
808 minColour.getBackground());
809 Cache.setColourPropertyNoSave(ANNOTATIONCOLOUR_MAX,
810 maxColour.getBackground());
813 * Save Overview settings
815 Cache.setColourPropertyNoSave(GAP_COLOUR, gapColour.getBackground());
816 Cache.setColourPropertyNoSave(HIDDEN_COLOUR,
817 hiddenColour.getBackground());
818 Cache.setPropertyNoSave(USE_LEGACY_GAP,
819 Boolean.toString(useLegacyGap.isSelected()));
820 Cache.setPropertyNoSave(SHOW_OV_HIDDEN_AT_START,
821 Boolean.toString(showHiddenAtStart.isSelected()));
824 * Save Structure settings
826 Cache.setPropertyNoSave(ADD_TEMPFACT_ANN,
827 Boolean.toString(addTempFactor.isSelected()));
828 Cache.setPropertyNoSave(ADD_SS_ANN,
829 Boolean.toString(addSecondaryStructure.isSelected()));
830 Cache.setPropertyNoSave(USE_RNAVIEW,
831 Boolean.toString(useRnaView.isSelected()));
832 Cache.setPropertyNoSave(STRUCT_FROM_PDB,
833 Boolean.toString(structFromPdb.isSelected()));
834 Cache.setPropertyNoSave(STRUCTURE_DISPLAY,
835 structViewer.getSelectedItem().toString());
836 Cache.setPropertyNoSave(STRUCTURE_DIMENSIONS,
837 structureDimensions.getText()); // BH 2019.07.12
838 Cache.setOrRemove(CHIMERA_PATH, chimeraPath.getText());
839 Cache.setPropertyNoSave(MAP_WITH_SIFTS,
840 Boolean.toString(siftsMapping.isSelected()));
841 SiftsSettings.setMapWithSifts(siftsMapping.isSelected());
844 * Save Output settings
846 Cache.setPropertyNoSave("EPS_RENDERING",
847 ((OptionsParam) epsRendering.getSelectedItem()).getCode());
848 Cache.setPropertyNoSave("HTML_RENDERING",
849 ((OptionsParam) htmlRendering.getSelectedItem()).getCode());
850 Cache.setPropertyNoSave("SVG_RENDERING",
851 ((OptionsParam) svgRendering.getSelectedItem()).getCode());
853 if (!Platform.isJS())
859 // Save Connections settings
860 Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
861 BrowserLauncher.resetBrowser();
864 // save user-defined and selected links
865 String menuLinks = sequenceUrlLinks.writeUrlsAsString(true);
866 if (menuLinks.isEmpty())
868 Cache.removePropertyNoSave("SEQUENCE_LINKS");
872 Cache.setPropertyNoSave("SEQUENCE_LINKS", menuLinks.toString());
875 String nonMenuLinks = sequenceUrlLinks.writeUrlsAsString(false);
876 if (nonMenuLinks.isEmpty())
878 Cache.removePropertyNoSave("STORED_LINKS");
882 Cache.setPropertyNoSave("STORED_LINKS", nonMenuLinks.toString());
885 Cache.setPropertyNoSave("DEFAULT_URL",
886 sequenceUrlLinks.getPrimaryUrlId());
888 Cache.setPropertyNoSave("USE_PROXY",
889 Boolean.toString(useProxy.isSelected()));
891 Cache.setOrRemove("PROXY_SERVER", proxyServerTB.getText());
893 Cache.setOrRemove("PROXY_PORT", proxyPortTB.getText());
895 if (useProxy.isSelected())
897 System.setProperty("http.proxyHost", proxyServerTB.getText());
898 System.setProperty("http.proxyPort", proxyPortTB.getText());
902 System.setProperty("http.proxyHost", "");
903 System.setProperty("http.proxyPort", "");
905 Cache.setProperty("VERSION_CHECK",
906 Boolean.toString(versioncheck.isSelected()));
907 if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
909 // default is false - we only set this if the user has actively agreed
910 Cache.setProperty("USAGESTATS",
911 Boolean.toString(usagestats.isSelected()));
913 if (!questionnaire.isSelected())
915 Cache.setProperty(NOQUESTIONNAIRES, "true");
919 // special - made easy to edit a property file to disable questionnaires
920 // by just adding the given line
921 Cache.removeProperty(NOQUESTIONNAIRES);
925 * Save Output settings
927 Cache.setPropertyNoSave("BLC_JVSUFFIX",
928 Boolean.toString(blcjv.isSelected()));
929 Cache.setPropertyNoSave("CLUSTAL_JVSUFFIX",
930 Boolean.toString(clustaljv.isSelected()));
931 Cache.setPropertyNoSave("FASTA_JVSUFFIX",
932 Boolean.toString(fastajv.isSelected()));
933 Cache.setPropertyNoSave("MSF_JVSUFFIX",
934 Boolean.toString(msfjv.isSelected()));
935 Cache.setPropertyNoSave("PFAM_JVSUFFIX",
936 Boolean.toString(pfamjv.isSelected()));
937 Cache.setPropertyNoSave("PILEUP_JVSUFFIX",
938 Boolean.toString(pileupjv.isSelected()));
939 Cache.setPropertyNoSave("PIR_JVSUFFIX",
940 Boolean.toString(pirjv.isSelected()));
941 Cache.setPropertyNoSave("PIR_MODELLER",
942 Boolean.toString(modellerOutput.isSelected()));
943 Cache.setPropertyNoSave("EXPORT_EMBBED_BIOJSON",
944 Boolean.toString(embbedBioJSON.isSelected()));
945 jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
947 Cache.setPropertyNoSave("FIGURE_AUTOIDWIDTH",
948 Boolean.toString(autoIdWidth.isSelected()));
949 userIdWidth_actionPerformed();
950 Cache.setPropertyNoSave("FIGURE_FIXEDIDWIDTH", userIdWidth.getText());
953 * Save Editing settings
955 Cache.setPropertyNoSave(AUTO_CALC_CONSENSUS,
956 Boolean.toString(autoCalculateConsCheck.isSelected()));
957 Cache.setPropertyNoSave(SORT_BY_TREE,
958 Boolean.toString(sortByTree.isSelected()));
959 Cache.setPropertyNoSave(PAD_GAPS,
960 Boolean.toString(padGaps.isSelected()));
962 if (!Platform.isJS())
964 wsPrefs.updateAndRefreshWsMenuConfig(false);
968 * Save Backups settings
970 Cache.setPropertyNoSave(BackupFiles.ENABLED,
971 Boolean.toString(enableBackupFiles.isSelected()));
972 int preset = getComboIntStringKey(backupfilesPresetsCombo);
973 Cache.setPropertyNoSave(BackupFiles.NS + "_PRESET",
974 Integer.toString(preset));
976 if (preset == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
978 BackupFilesPresetEntry customBFPE = getBackupfilesCurrentEntry();
979 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
980 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM, customBFPE);
981 Cache.setPropertyNoSave(BackupFilesPresetEntry.CUSTOMCONFIG,
982 customBFPE.toString());
985 BackupFilesPresetEntry savedBFPE = BackupFilesPresetEntry.backupfilesPresetEntriesValues
987 Cache.setPropertyNoSave(BackupFilesPresetEntry.SAVEDCONFIG,
988 savedBFPE.toString());
990 Cache.saveProperties();
991 Desktop.getInstance().doConfigureStructurePrefs();
994 frame.setClosed(true);
995 } catch (Exception ex)
1000 public static void setAppletDefaults()
1003 // http://www.jalview.org/old/v2_8/examples/appletParameters.html
1005 // showConservation true or false Default is true.
1006 // showQuality true or false Default is true.
1007 // showConsensus true or false Default is true.
1008 // showFeatureSettings true or false Shows the feature settings window when
1010 // showTreeBootstraps true or false (default is true) show or hide branch
1012 // showTreeDistances true or false (default is true) show or hide branch
1014 // showUnlinkedTreeNodes true or false (default is false) indicate if
1015 // unassociated nodes should be highlighted in the tree view
1016 // showUnconserved true of false (default is false) When true, only gaps and
1017 // symbols different to the consensus sequence ions of the alignment
1018 // showGroupConsensus true of false (default is false) When true, shows
1019 // consensus annotation row for any groups on the alignment. (since 2.7)
1020 // showGroupConservation true of false (default is false) When true, shows
1021 // amino-acid property conservation annotation row for any groups on the
1022 // showConsensusHistogram true of false (default is true) When true, shows
1023 // the percentage occurence of the consensus symbol for each column as a
1024 // showSequenceLogo true of false (default is false) When true, shows a
1025 // sequence logo above the consensus sequence (overlaid above the Consensus
1027 Cache.setPropertyNoSave(SHOW_CONSERVATION, "true");
1028 Cache.setPropertyNoSave(SHOW_QUALITY, "false");
1029 Cache.setPropertyNoSave(SHOW_CONSENSUS, "true");
1030 Cache.setPropertyNoSave(SHOW_UNCONSERVED, "false");
1031 Cache.setPropertyNoSave(SHOW_GROUP_CONSERVATION, "false");
1032 Cache.setPropertyNoSave(SHOW_GROUP_CONSENSUS, "false");
1034 // TODO -- just a start here
1038 * Do any necessary validation before saving settings. Return focus to the
1039 * first tab which fails validation.
1043 private boolean validateSettings()
1045 if (!validateStructure())
1047 structureTab.requestFocusInWindow();
1054 protected boolean validateStructure()
1056 return validateChimeraPath();
1061 * Opens a file browser, and if a file is chosen, sets its path as the text of
1062 * the 'startup file' text field
1065 public void startupFileTextfield_mouseClicked()
1067 // TODO: JAL-3048 not needed for Jalview-JS
1068 String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
1069 JalviewFileChooser chooser = JalviewFileChooser
1070 .forRead(Cache.getProperty("LAST_DIRECTORY"), fileFormat);
1071 chooser.setFileView(new JalviewFileView());
1072 chooser.setDialogTitle(
1073 MessageManager.getString("label.select_startup_file"));
1075 int value = chooser.showOpenDialog(this);
1077 if (value == JalviewFileChooser.APPROVE_OPTION)
1079 FileFormatI format = chooser.getSelectedFormat();
1083 * saving properties to file is deferred to the 'OK' action
1085 Cache.setPropertyNoSave("DEFAULT_FILE_FORMAT", format.getName());
1087 startupFileTextfield
1088 .setText(chooser.getSelectedFile().getAbsolutePath());
1099 public void cancel_actionPerformed(ActionEvent e)
1103 if (!Platform.isJS())
1105 wsPrefs.updateWsMenuConfig(true);
1106 wsPrefs.refreshWs_actionPerformed(e);
1108 frame.setClosed(true);
1109 } catch (Exception ex)
1121 public void annotations_actionPerformed(ActionEvent e)
1123 conservation.setEnabled(annotations.isSelected());
1124 quality.setEnabled(annotations.isSelected());
1125 identity.setEnabled(annotations.isSelected());
1126 showOccupancy.setEnabled(annotations.isSelected());
1127 showGroupConsensus.setEnabled(annotations.isSelected());
1128 showGroupConservation.setEnabled(annotations.isSelected());
1129 showConsensHistogram.setEnabled(annotations.isSelected()
1130 && (identity.isSelected() || showGroupConsensus.isSelected()));
1131 showConsensLogo.setEnabled(annotations.isSelected()
1132 && (identity.isSelected() || showGroupConsensus.isSelected()));
1136 public void newLink_actionPerformed(ActionEvent e)
1138 GSequenceLink link = new GSequenceLink();
1139 boolean valid = false;
1142 if (JvOptionPane.showInternalConfirmDialog(Desktop.getDesktopPane(), link,
1143 MessageManager.getString("label.new_sequence_url_link"),
1144 JvOptionPane.OK_CANCEL_OPTION, -1,
1145 null) == JvOptionPane.OK_OPTION)
1147 if (link.checkValid())
1149 if (((UrlLinkTableModel) linkUrlTable.getModel())
1150 .isUniqueName(link.getName()))
1152 ((UrlLinkTableModel) linkUrlTable.getModel())
1153 .insertRow(link.getName(), link.getURL());
1158 link.notifyDuplicate();
1171 public void editLink_actionPerformed(ActionEvent e)
1173 GSequenceLink link = new GSequenceLink();
1175 int index = linkUrlTable.getSelectedRow();
1178 // button no longer enabled if row is not selected
1179 Cache.log.debug("Edit with no row selected in linkUrlTable");
1183 int nameCol = ((UrlLinkTableModel) linkUrlTable.getModel())
1185 int urlCol = ((UrlLinkTableModel) linkUrlTable.getModel())
1187 String oldName = linkUrlTable.getValueAt(index, nameCol).toString();
1188 link.setName(oldName);
1189 link.setURL(linkUrlTable.getValueAt(index, urlCol).toString());
1191 boolean valid = false;
1194 if (JvOptionPane.showInternalConfirmDialog(Desktop.getDesktopPane(), link,
1195 MessageManager.getString("label.edit_sequence_url_link"),
1196 JvOptionPane.OK_CANCEL_OPTION, -1,
1197 null) == JvOptionPane.OK_OPTION)
1199 if (link.checkValid())
1201 if ((oldName.equals(link.getName()))
1202 || (((UrlLinkTableModel) linkUrlTable.getModel())
1203 .isUniqueName(link.getName())))
1205 linkUrlTable.setValueAt(link.getName(), index, nameCol);
1206 linkUrlTable.setValueAt(link.getURL(), index, urlCol);
1211 link.notifyDuplicate();
1224 public void deleteLink_actionPerformed(ActionEvent e)
1226 int index = linkUrlTable.getSelectedRow();
1227 int modelIndex = -1;
1230 // button no longer enabled if row is not selected
1231 Cache.log.debug("Delete with no row selected in linkUrlTable");
1236 modelIndex = linkUrlTable.convertRowIndexToModel(index);
1239 // make sure we use the model index to delete, and not the table index
1240 ((UrlLinkTableModel) linkUrlTable.getModel()).removeRow(modelIndex);
1244 public void defaultBrowser_mouseClicked(MouseEvent e)
1246 // TODO: JAL-3048 not needed for j2s
1247 if (!Platform.isJS()) // BH 2019
1254 JFileChooser chooser = new JFileChooser(".");
1255 chooser.setDialogTitle(
1256 MessageManager.getString("label.select_default_browser"));
1258 int value = chooser.showOpenDialog(this);
1260 if (value == JFileChooser.APPROVE_OPTION)
1262 defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath());
1271 * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event
1275 protected void showunconserved_actionPerformed(ActionEvent e)
1277 // TODO Auto-generated method stub
1278 super.showunconserved_actionPerformed(e);
1282 * not implemented -- returns empty list
1286 public static List<String> getGroupURLLinks()
1288 return groupURLLinks;
1292 public void minColour_actionPerformed(JPanel panel)
1294 JalviewColourChooser.showColourChooser(this,
1295 MessageManager.getString("label.select_colour_minimum_value"),
1300 public void maxColour_actionPerformed(JPanel panel)
1302 JalviewColourChooser.showColourChooser(this,
1303 MessageManager.getString("label.select_colour_maximum_value"),
1308 public void gapColour_actionPerformed(JPanel gap)
1310 if (!useLegacyGap.isSelected())
1312 JalviewColourChooser.showColourChooser(this,
1313 MessageManager.getString("label.select_gap_colour"),
1319 public void hiddenColour_actionPerformed(JPanel hidden)
1321 JalviewColourChooser.showColourChooser(this,
1322 MessageManager.getString("label.select_hidden_colour"),
1327 protected void useLegacyGaps_actionPerformed(ActionEvent e)
1329 boolean enabled = useLegacyGap.isSelected();
1332 gapColour.setBackground(
1333 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_LEGACY_GAP);
1337 gapColour.setBackground(
1338 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP);
1340 gapColour.setEnabled(!enabled);
1341 gapLabel.setEnabled(!enabled);
1345 protected void resetOvDefaults_actionPerformed(ActionEvent e)
1347 useLegacyGap.setSelected(false);
1348 useLegacyGaps_actionPerformed(null);
1349 showHiddenAtStart.setSelected(false);
1350 hiddenColour.setBackground(
1351 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_HIDDEN);
1355 protected void userIdWidth_actionPerformed()
1359 String val = userIdWidth.getText().trim();
1360 if (val.length() > 0)
1362 Integer iw = Integer.parseInt(val);
1363 if (iw.intValue() < 12)
1365 throw new NumberFormatException();
1367 userIdWidth.setText(iw.toString());
1369 } catch (NumberFormatException x)
1371 userIdWidth.setText("");
1372 JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
1374 .getString("warn.user_defined_width_requirements"),
1375 MessageManager.getString("label.invalid_id_column_width"),
1376 JvOptionPane.WARNING_MESSAGE);
1381 protected void autoIdWidth_actionPerformed()
1383 userIdWidth.setEnabled(!autoIdWidth.isSelected());
1384 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
1388 * Returns true if chimera path is to a valid executable, else show an error
1391 protected boolean validateChimeraPath()
1393 if (chimeraPath.getText().trim().length() > 0)
1395 File f = new File(chimeraPath.getText());
1396 if (!f.canExecute())
1398 JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
1399 MessageManager.getString("label.invalid_chimera_path"),
1400 MessageManager.getString("label.invalid_name"),
1401 JvOptionPane.ERROR_MESSAGE);
1409 * If Chimera is selected, check it can be found on default or user-specified
1410 * path, if not show a warning/help dialog.
1413 protected void structureViewer_actionPerformed(String selectedItem)
1415 if (!selectedItem.equals(ViewerType.CHIMERA.name()))
1419 boolean found = false;
1422 * Try user-specified and standard paths for Chimera executable.
1424 List<String> paths = StructureManager.getChimeraPaths();
1425 paths.add(0, chimeraPath.getText());
1426 for (String path : paths)
1428 if (new File(path.trim()).canExecute())
1436 String[] options = { "OK", "Help" };
1437 int showHelp = JvOptionPane.showInternalOptionDialog(Desktop.getDesktopPane(),
1438 JvSwingUtils.wrapTooltip(true,
1439 MessageManager.getString("label.chimera_missing")),
1440 "", JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE,
1441 null, options, options[0]);
1442 if (showHelp == JvOptionPane.NO_OPTION)
1446 Help.showHelpWindow(HelpId.StructureViewer);
1447 } catch (HelpSetException e)
1449 e.printStackTrace();
1455 public class OptionsParam
1457 private String name;
1459 private String code;
1461 public OptionsParam(String name, String code)
1467 public String getName()
1472 public void setName(String name)
1477 public String getCode()
1482 public void setCode(String code)
1488 public String toString()
1494 public boolean equals(Object that)
1496 if (!(that instanceof OptionsParam))
1500 return this.code.equalsIgnoreCase(((OptionsParam) that).code);
1504 public int hashCode()
1506 return name.hashCode() + code.hashCode();
1510 protected class UrlListSelectionHandler implements ListSelectionListener
1514 public void valueChanged(ListSelectionEvent e)
1516 ListSelectionModel lsm = (ListSelectionModel) e.getSource();
1518 updateValueChanged(lsm.getMinSelectionIndex());
1522 public void updateValueChanged(int index)
1526 // no selection, so disable delete/edit buttons
1527 editLink.setEnabled(false);
1528 deleteLink.setEnabled(false);
1531 int modelIndex = linkUrlTable.convertRowIndexToModel(index);
1533 // enable/disable edit and delete link buttons
1534 if (((UrlLinkTableModel) linkUrlTable.getModel())
1535 .isRowDeletable(modelIndex))
1537 deleteLink.setEnabled(true);
1541 deleteLink.setEnabled(false);
1544 if (((UrlLinkTableModel) linkUrlTable.getModel())
1545 .isRowEditable(modelIndex))
1547 editLink.setEnabled(true);
1551 editLink.setEnabled(false);