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.MouseEvent;
32 import java.util.ArrayList;
33 import java.util.List;
35 import javax.help.HelpSetException;
36 import javax.swing.JComboBox;
37 import javax.swing.JFileChooser;
38 import javax.swing.JInternalFrame;
39 import javax.swing.JPanel;
40 import javax.swing.ListSelectionModel;
41 import javax.swing.RowFilter;
42 import javax.swing.RowSorter;
43 import javax.swing.SortOrder;
44 import javax.swing.event.DocumentEvent;
45 import javax.swing.event.DocumentListener;
46 import javax.swing.event.ListSelectionEvent;
47 import javax.swing.event.ListSelectionListener;
48 import javax.swing.table.TableCellRenderer;
49 import javax.swing.table.TableColumn;
50 import javax.swing.table.TableModel;
51 import javax.swing.table.TableRowSorter;
53 import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
54 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
55 import jalview.bin.Cache;
56 import jalview.ext.pymol.PymolManager;
57 import jalview.gui.Help.HelpId;
58 import jalview.gui.StructureViewer.ViewerType;
59 import jalview.io.BackupFiles;
60 import jalview.io.BackupFilesPresetEntry;
61 import jalview.io.FileFormatI;
62 import jalview.io.JalviewFileChooser;
63 import jalview.io.JalviewFileView;
64 import jalview.jbgui.GPreferences;
65 import jalview.jbgui.GSequenceLink;
66 import jalview.schemes.ColourSchemeI;
67 import jalview.schemes.ColourSchemes;
68 import jalview.schemes.ResidueColourScheme;
69 import jalview.urls.UrlLinkTableModel;
70 import jalview.urls.api.UrlProviderFactoryI;
71 import jalview.urls.api.UrlProviderI;
72 import jalview.urls.desktop.DesktopUrlProviderFactory;
73 import jalview.util.MessageManager;
74 import jalview.util.Platform;
75 import jalview.util.UrlConstants;
76 import jalview.ws.sifts.SiftsSettings;
85 * for merge with Jalview-JS
86 public class Preferences extends GPreferences implements ApplicationSingletonI
88 public class Preferences extends GPreferences
90 public static final String ENABLE_SPLIT_FRAME = "ENABLE_SPLIT_FRAME";
92 public static final String SCALE_PROTEIN_TO_CDNA = "SCALE_PROTEIN_TO_CDNA";
94 public static final String DEFAULT_COLOUR = "DEFAULT_COLOUR";
96 public static final String DEFAULT_COLOUR_PROT = "DEFAULT_COLOUR_PROT";
98 public static final String DEFAULT_COLOUR_NUC = "DEFAULT_COLOUR_NUC";
100 public static final String ADD_TEMPFACT_ANN = "ADD_TEMPFACT_ANN";
102 public static final String ADD_SS_ANN = "ADD_SS_ANN";
104 public static final String USE_RNAVIEW = "USE_RNAVIEW";
106 public static final String STRUCT_FROM_PDB = "STRUCT_FROM_PDB";
108 public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY";
110 public static final String CHIMERA_PATH = "CHIMERA_PATH";
112 public static final String CHIMERAX_PATH = "CHIMERAX_PATH";
114 public static final String PYMOL_PATH = "PYMOL_PATH";
116 public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS";
118 public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE";
120 public static final String SHOW_OCCUPANCY = "SHOW_OCCUPANCY";
122 public static final String SHOW_OV_HIDDEN_AT_START = "SHOW_OV_HIDDEN_AT_START";
124 public static final String USE_LEGACY_GAP = "USE_LEGACY_GAP";
126 public static final String GAP_COLOUR = "GAP_COLOUR";
128 public static final String HIDDEN_COLOUR = "HIDDEN_COLOUR";
130 private static final int MIN_FONT_SIZE = 1;
132 private static final int MAX_FONT_SIZE = 30;
134 private String previousProxyType;
136 private static Preferences INSTANCE = null; // add "final"
139 * Holds name and link separated with | character. Sequence ID must be
140 * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$
142 public static UrlProviderI sequenceUrlLinks;
144 public static UrlLinkTableModel dataModel;
147 * Holds name and link separated with | character. Sequence IDS and Sequences
148 * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and
149 * $SEQUENCES$ or $SEQUENCES=/.possible | chars ./=$ and separation character
150 * for first and second token specified after a pipe character at end |,|.
151 * (TODO: proper escape for using | to separate ids or sequences
154 public static List<String> groupURLLinks;
157 // get links selected to be in the menu (SEQUENCE_LINKS)
158 // and links entered by the user but not selected (STORED_LINKS)
159 String inMenuString = Cache.getDefault("SEQUENCE_LINKS", "");
160 String notInMenuString = Cache.getDefault("STORED_LINKS", "");
161 String defaultUrl = Cache.getDefault("DEFAULT_URL",
162 UrlConstants.DEFAULT_LABEL);
164 // if both links lists are empty, add the DEFAULT_URL link
165 // otherwise we assume the default link is in one of the lists
166 if (inMenuString.isEmpty() && notInMenuString.isEmpty())
168 inMenuString = UrlConstants.DEFAULT_STRING;
170 UrlProviderFactoryI factory = new DesktopUrlProviderFactory(defaultUrl,
171 inMenuString, notInMenuString);
172 sequenceUrlLinks = factory.createUrlProvider();
173 dataModel = new UrlLinkTableModel(sequenceUrlLinks);
176 * TODO: reformulate groupURL encoding so two or more can be stored in the
177 * .properties file as '|' separated strings
180 groupURLLinks = new ArrayList<>();
183 JInternalFrame frame;
185 private WsPreferences wsPrefs;
187 private OptionsParam promptEachTimeOpt = new OptionsParam(
188 MessageManager.getString("label.prompt_each_time"),
191 private OptionsParam lineArtOpt = new OptionsParam(
192 MessageManager.getString("label.lineart"), "Lineart");
194 private OptionsParam textOpt = new OptionsParam(
195 MessageManager.getString("action.text"), "Text");
197 // get singleton Preferences instance
198 public static Preferences getInstance()
200 if (INSTANCE == null || INSTANCE.frame == null
201 || INSTANCE.frame.isClosed())
203 INSTANCE = new Preferences();
208 * Replace code with the following for Jalvew-JS
209 Preferences INSTANCE = ApplicationSingletonProvider.getInstance(Preferences.class);
210 if (INSTANCE == null || INSTANCE.frame == null
211 || INSTANCE.frame.isClosed())
213 ApplicationSingletonProvider.remove(Preferences.class);
214 INSTANCE = ApplicationSingletonProvider.getInstance(Preferences.class);
220 public static void openPreferences()
222 openPreferences(0, null);
225 public static void openPreferences(int selectTab, String message)
227 Preferences p = getInstance();
228 p.selectTab(selectTab);
229 p.setMessage(message);
231 p.frame.moveToFront();
236 * Creates a new Preferences object.
238 private Preferences()
241 frame = new JInternalFrame();
242 frame.setContentPane(this);
243 if (!Platform.isJS())
250 wsPrefs = new WsPreferences();
251 wsTab.add(wsPrefs, BorderLayout.CENTER);
253 int width = 500, height = 450;
254 if (Platform.isAMacAndNotJS())
260 Desktop.addInternalFrame(frame,
261 MessageManager.getString("label.preferences"), width, height);
262 frame.setMinimumSize(new Dimension(width, height));
265 * Set Visual tab defaults
267 seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true));
268 rightAlign.setSelected(Cache.getDefault("RIGHT_ALIGN_IDS", false));
269 fullScreen.setSelected(Cache.getDefault("SHOW_FULLSCREEN", false));
270 annotations.setSelected(Cache.getDefault("SHOW_ANNOTATIONS", true));
272 conservation.setSelected(Cache.getDefault("SHOW_CONSERVATION", true));
273 quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));
274 identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
275 openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false));
277 .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
278 showOccupancy.setSelected(Cache.getDefault(SHOW_OCCUPANCY, false));
280 .setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS", false));
281 showGroupConservation.setSelected(
282 Cache.getDefault("SHOW_GROUP_CONSERVATION", false));
283 showConsensHistogram.setSelected(
284 Cache.getDefault("SHOW_CONSENSUS_HISTOGRAM", true));
286 .setSelected(Cache.getDefault("SHOW_CONSENSUS_LOGO", false));
288 .setSelected(Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true));
290 .setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP", true));
292 String[] fonts = java.awt.GraphicsEnvironment
293 .getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
294 for (int i = 0; i < fonts.length; i++)
296 fontNameCB.addItem(fonts[i]);
299 for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++)
301 fontSizeCB.addItem(i + "");
304 fontStyleCB.addItem("plain");
305 fontStyleCB.addItem("bold");
306 fontStyleCB.addItem("italic");
308 fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif"));
309 fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10"));
310 fontStyleCB.setSelectedItem(
311 Cache.getDefault("FONT_STYLE", Font.PLAIN + ""));
313 smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", true));
315 .setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA, false));
317 idItalics.setSelected(Cache.getDefault("ID_ITALICS", true));
319 wrap.setSelected(Cache.getDefault("WRAP_ALIGNMENT", false));
321 gapSymbolCB.addItem("-");
322 gapSymbolCB.addItem(".");
324 gapSymbolCB.setSelectedItem(Cache.getDefault("GAP_SYMBOL", "-"));
326 sortby.addItem("No sort");
327 sortby.addItem("Id");
328 sortby.addItem("Pairwise Identity");
329 sortby.setSelectedItem(Cache.getDefault("SORT_ALIGNMENT", "No sort"));
331 sortAnnBy.addItem(SequenceAnnotationOrder.NONE.toString());
333 .addItem(SequenceAnnotationOrder.SEQUENCE_AND_LABEL.toString());
335 .addItem(SequenceAnnotationOrder.LABEL_AND_SEQUENCE.toString());
336 SequenceAnnotationOrder savedSort = SequenceAnnotationOrder
337 .valueOf(Cache.getDefault(SORT_ANNOTATIONS,
338 SequenceAnnotationOrder.NONE.name()));
339 sortAnnBy.setSelectedItem(savedSort.toString());
341 sortAutocalc.addItem("Autocalculated first");
342 sortAutocalc.addItem("Autocalculated last");
343 final boolean showAbove = Cache.getDefault(SHOW_AUTOCALC_ABOVE, true);
344 sortAutocalc.setSelectedItem(showAbove ? sortAutocalc.getItemAt(0)
345 : sortAutocalc.getItemAt(1));
347 .setSelected(Cache.getDefault("SHOW_STARTUP_FILE", true));
348 startupFileTextfield.setText(Cache.getDefault("STARTUP_FILE",
349 Cache.getDefault("www.jalview.org", "http://www.jalview.org")
350 + "/examples/exampleFile_2_3.jar"));
353 * Set Colours tab defaults
355 protColour.addItem(ResidueColourScheme.NONE);
356 nucColour.addItem(ResidueColourScheme.NONE);
357 for (ColourSchemeI cs : ColourSchemes.getInstance().getColourSchemes())
359 String name = cs.getSchemeName();
360 protColour.addItem(name);
361 nucColour.addItem(name);
363 String oldProp = Cache.getDefault(DEFAULT_COLOUR,
364 ResidueColourScheme.NONE);
365 String newProp = Cache.getDefault(DEFAULT_COLOUR_PROT, null);
366 protColour.setSelectedItem(newProp != null ? newProp : oldProp);
367 newProp = Cache.getDefault(DEFAULT_COLOUR_NUC, null);
368 nucColour.setSelectedItem(newProp != null ? newProp : oldProp);
369 minColour.setBackground(
370 Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN", Color.orange));
371 maxColour.setBackground(
372 Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX", Color.red));
375 * Set overview panel defaults
377 gapColour.setBackground(
378 Cache.getDefaultColour(GAP_COLOUR,
379 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP));
380 hiddenColour.setBackground(
381 Cache.getDefaultColour(HIDDEN_COLOUR,
382 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_HIDDEN));
383 useLegacyGap.setSelected(Cache.getDefault(USE_LEGACY_GAP, false));
384 gapLabel.setEnabled(!useLegacyGap.isSelected());
385 gapColour.setEnabled(!useLegacyGap.isSelected());
387 .setSelected(Cache.getDefault(SHOW_OV_HIDDEN_AT_START, false));
390 * Set Structure tab defaults
392 final boolean structSelected = Cache.getDefault(STRUCT_FROM_PDB, false);
393 structFromPdb.setSelected(structSelected);
394 useRnaView.setSelected(Cache.getDefault(USE_RNAVIEW, false));
395 useRnaView.setEnabled(structSelected);
396 addSecondaryStructure.setSelected(Cache.getDefault(ADD_SS_ANN, false));
397 addSecondaryStructure.setEnabled(structSelected);
398 addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, false));
399 addTempFactor.setEnabled(structSelected);
402 * set choice of structure viewer, and path if saved as a preference;
403 * default to Jmol (first choice) if an unexpected value is found
405 String viewerType = Cache.getDefault(STRUCTURE_DISPLAY, ViewerType.JMOL.name());
406 structViewer.setSelectedItem(viewerType);
407 String viewerPath = "";
408 ViewerType type = null;
411 type = ViewerType.valueOf(viewerType);
417 viewerPath = Cache.getDefault(CHIMERA_PATH, "");
420 viewerPath = Cache.getDefault(CHIMERAX_PATH, "");
423 viewerPath = Cache.getDefault(PYMOL_PATH, "");
426 } catch (IllegalArgumentException e)
428 Cache.log.error("Unknown structure viewer type: " + viewerType
429 + ", defaulting to Jmol");
430 type = ViewerType.JMOL;
432 structureViewerPath.setText(viewerPath);
434 structureViewerPath.addActionListener(new ActionListener()
437 public void actionPerformed(ActionEvent e)
439 if (validateViewerPath())
441 Cache.setProperty(structViewer.getSelectedItem()
442 .equals(ViewerType.CHIMERAX.name())
444 : CHIMERA_PATH, structureViewerPath.getText());
449 if (Cache.getDefault("MAP_WITH_SIFTS", false))
451 siftsMapping.setSelected(true);
455 nwMapping.setSelected(true);
459 .setMapWithSifts(Cache.getDefault("MAP_WITH_SIFTS", false));
462 * Set Connections tab defaults
466 linkUrlTable.setModel(dataModel);
467 final TableRowSorter<TableModel> sorter = new TableRowSorter<>(
468 linkUrlTable.getModel());
469 linkUrlTable.setRowSorter(sorter);
470 List<RowSorter.SortKey> sortKeys = new ArrayList<>();
472 UrlLinkTableModel m = (UrlLinkTableModel) linkUrlTable.getModel();
473 sortKeys.add(new RowSorter.SortKey(m.getPrimaryColumn(),
474 SortOrder.DESCENDING));
475 sortKeys.add(new RowSorter.SortKey(m.getSelectedColumn(),
476 SortOrder.DESCENDING));
478 new RowSorter.SortKey(m.getNameColumn(), SortOrder.ASCENDING));
480 sorter.setSortKeys(sortKeys);
481 // BH 2018 setSortKeys will do the sort
485 ActionListener onReset;
486 onReset = new ActionListener()
489 public void actionPerformed(ActionEvent e)
491 filterTB.setText("");
492 sorter.setRowFilter(RowFilter.regexFilter(""));
496 doReset.addActionListener(onReset);
498 // filter to display only custom urls
499 final RowFilter<TableModel, Object> customUrlFilter = new RowFilter<TableModel, Object>()
502 public boolean include(
503 Entry<? extends TableModel, ? extends Object> entry)
505 return ((UrlLinkTableModel) entry.getModel()).isUserEntry(entry);
509 final TableRowSorter<TableModel> customSorter = new TableRowSorter<>(
510 linkUrlTable.getModel());
511 customSorter.setRowFilter(customUrlFilter);
513 ActionListener onCustomOnly;
514 onCustomOnly = new ActionListener()
517 public void actionPerformed(ActionEvent e)
519 filterTB.setText("");
520 sorter.setRowFilter(customUrlFilter);
523 userOnly.addActionListener(onCustomOnly);
525 filterTB.getDocument().addDocumentListener(new DocumentListener()
527 String caseInsensitiveFlag = "(?i)";
530 public void changedUpdate(DocumentEvent e)
532 sorter.setRowFilter(RowFilter
533 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
537 public void removeUpdate(DocumentEvent e)
539 sorter.setRowFilter(RowFilter
540 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
544 public void insertUpdate(DocumentEvent e)
546 sorter.setRowFilter(RowFilter
547 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
551 // set up list selection functionality
552 linkUrlTable.getSelectionModel()
553 .addListSelectionListener(new UrlListSelectionHandler());
555 // set up radio buttons
556 int onClickCol = ((UrlLinkTableModel) linkUrlTable.getModel())
558 String onClickName = linkUrlTable.getColumnName(onClickCol);
559 linkUrlTable.getColumn(onClickName)
560 .setCellRenderer(new RadioButtonRenderer());
561 linkUrlTable.getColumn(onClickName)
562 .setCellEditor(new RadioButtonEditor());
564 // get boolean columns and resize those to min possible
565 for (int column = 0; column < linkUrlTable.getColumnCount(); column++)
567 if (linkUrlTable.getModel().getColumnClass(column)
568 .equals(Boolean.class))
570 TableColumn tableColumn = linkUrlTable.getColumnModel()
572 int preferredWidth = tableColumn.getMinWidth();
574 TableCellRenderer cellRenderer = linkUrlTable.getCellRenderer(0,
576 Component c = linkUrlTable.prepareRenderer(cellRenderer, 0, column);
577 int cwidth = c.getPreferredSize().width
578 + linkUrlTable.getIntercellSpacing().width;
579 preferredWidth = Math.max(preferredWidth, cwidth);
581 tableColumn.setPreferredWidth(preferredWidth);
585 String proxyTypeString = Cache.getDefault("USE_PROXY", "false");
586 previousProxyType = proxyTypeString;
587 switch (proxyTypeString)
589 case Cache.PROXYTYPE_NONE:
590 proxyType.setSelected(noProxy.getModel(), true);
592 case Cache.PROXYTYPE_SYSTEM:
593 proxyType.setSelected(systemProxy.getModel(), true);
595 case Cache.PROXYTYPE_CUSTOM:
596 proxyType.setSelected(customProxy.getModel(), true);
600 "Incorrect PROXY_TYPE - should be 'none' (clear proxy properties), 'false' (system settings), 'true' (custom settings): "
603 proxyServerHttpTB.setText(Cache.getDefault("PROXY_SERVER", ""));
604 proxyPortHttpTB.setText(Cache.getDefault("PROXY_PORT", ""));
605 proxyServerHttpsTB.setText(Cache.getDefault("PROXY_SERVER_HTTPS", ""));
606 proxyPortHttpsTB.setText(Cache.getDefault("PROXY_PORT_HTTPS", ""));
607 proxyAuth.setSelected(Cache.getDefault("PROXY_AUTH", false));
609 .setText(Cache.getDefault("PROXY_AUTH_USERNAME", ""));
610 // we are not storing or retrieving proxy password from .jalview_properties
611 proxyAuthPasswordPB.setText(Cache.proxyAuthPassword == null ? ""
612 : new String(Cache.proxyAuthPassword));
613 setCustomProxyEnabled();
614 applyProxyButtonEnabled(false);
616 defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
618 usagestats.setSelected(Cache.getDefault("USAGESTATS", false));
619 // note antisense here: default is true
621 .setSelected(Cache.getProperty("NOQUESTIONNAIRES") == null);
622 versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true));
625 * Set Output tab defaults
627 setupOutputCombo(epsRendering, "EPS_RENDERING");
628 setupOutputCombo(htmlRendering, "HTML_RENDERING");
629 setupOutputCombo(svgRendering, "SVG_RENDERING");
630 autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
631 userIdWidth.setEnabled(!autoIdWidth.isSelected());
632 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
633 Integer wi = Cache.getIntegerProperty("FIGURE_FIXEDIDWIDTH");
634 userIdWidth.setText(wi == null ? "" : wi.toString());
635 // TODO: refactor to use common enum via FormatAdapter and allow extension
636 // for new flat file formats
637 blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
638 clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
639 fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
640 msfjv.setSelected(Cache.getDefault("MSF_JVSUFFIX", true));
641 pfamjv.setSelected(Cache.getDefault("PFAM_JVSUFFIX", true));
642 pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true));
643 pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true));
644 modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false));
646 .setSelected(Cache.getDefault("EXPORT_EMBBED_BIOJSON", true));
649 * Set Editing tab defaults
651 autoCalculateConsCheck
652 .setSelected(Cache.getDefault("AUTO_CALC_CONSENSUS", true));
653 padGaps.setSelected(Cache.getDefault("PAD_GAPS", false));
654 sortByTree.setSelected(Cache.getDefault("SORT_BY_TREE", false));
656 annotations_actionPerformed(null); // update the display of the annotation
661 * Set Backups tab defaults
663 loadLastSavedBackupsOptions();
667 * A helper method that sets the items and initial selection in a character
668 * rendering option list (Prompt each time/Lineart/Text)
673 protected void setupOutputCombo(JComboBox<Object> comboBox,
676 comboBox.addItem(promptEachTimeOpt);
677 comboBox.addItem(lineArtOpt);
678 comboBox.addItem(textOpt);
681 * JalviewJS doesn't support Lineart so force it to Text
683 String defaultOption = Platform.isJS() ? "Text"
684 : Cache.getDefault(propertyKey, "Prompt each time");
685 if (defaultOption.equalsIgnoreCase("Text"))
687 comboBox.setSelectedItem(textOpt);
689 else if (defaultOption.equalsIgnoreCase("Lineart"))
691 comboBox.setSelectedItem(lineArtOpt);
695 comboBox.setSelectedItem(promptEachTimeOpt);
700 * Save user selections on the Preferences tabs to the Cache and write out to
706 public void ok_actionPerformed(ActionEvent e)
708 if (!validateSettings())
714 * Set proxy settings first (to be before web services refresh)
719 * Save Visual settings
721 Cache.applicationProperties.setProperty("SHOW_JVSUFFIX",
722 Boolean.toString(seqLimit.isSelected()));
723 Cache.applicationProperties.setProperty("RIGHT_ALIGN_IDS",
724 Boolean.toString(rightAlign.isSelected()));
725 Cache.applicationProperties.setProperty("SHOW_FULLSCREEN",
726 Boolean.toString(fullScreen.isSelected()));
727 Cache.applicationProperties.setProperty("SHOW_OVERVIEW",
728 Boolean.toString(openoverv.isSelected()));
729 Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
730 Boolean.toString(annotations.isSelected()));
731 Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
732 Boolean.toString(conservation.isSelected()));
733 Cache.applicationProperties.setProperty("SHOW_QUALITY",
734 Boolean.toString(quality.isSelected()));
735 Cache.applicationProperties.setProperty("SHOW_IDENTITY",
736 Boolean.toString(identity.isSelected()));
738 Cache.applicationProperties.setProperty("GAP_SYMBOL",
739 gapSymbolCB.getSelectedItem().toString());
741 Cache.applicationProperties.setProperty("FONT_NAME",
742 fontNameCB.getSelectedItem().toString());
743 Cache.applicationProperties.setProperty("FONT_STYLE",
744 fontStyleCB.getSelectedItem().toString());
745 Cache.applicationProperties.setProperty("FONT_SIZE",
746 fontSizeCB.getSelectedItem().toString());
748 Cache.applicationProperties.setProperty("ID_ITALICS",
749 Boolean.toString(idItalics.isSelected()));
750 Cache.applicationProperties.setProperty("SHOW_UNCONSERVED",
751 Boolean.toString(showUnconserved.isSelected()));
752 Cache.applicationProperties.setProperty(SHOW_OCCUPANCY,
753 Boolean.toString(showOccupancy.isSelected()));
754 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSENSUS",
755 Boolean.toString(showGroupConsensus.isSelected()));
756 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSERVATION",
757 Boolean.toString(showGroupConservation.isSelected()));
758 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_HISTOGRAM",
759 Boolean.toString(showConsensHistogram.isSelected()));
760 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_LOGO",
761 Boolean.toString(showConsensLogo.isSelected()));
762 Cache.applicationProperties.setProperty("ANTI_ALIAS",
763 Boolean.toString(smoothFont.isSelected()));
764 Cache.applicationProperties.setProperty(SCALE_PROTEIN_TO_CDNA,
765 Boolean.toString(scaleProteinToCdna.isSelected()));
766 Cache.applicationProperties.setProperty("SHOW_NPFEATS_TOOLTIP",
767 Boolean.toString(showNpTooltip.isSelected()));
768 Cache.applicationProperties.setProperty("SHOW_DBREFS_TOOLTIP",
769 Boolean.toString(showDbRefTooltip.isSelected()));
771 Cache.applicationProperties.setProperty("WRAP_ALIGNMENT",
772 Boolean.toString(wrap.isSelected()));
774 Cache.applicationProperties.setProperty("STARTUP_FILE",
775 startupFileTextfield.getText());
776 Cache.applicationProperties.setProperty("SHOW_STARTUP_FILE",
777 Boolean.toString(startupCheckbox.isSelected()));
779 Cache.applicationProperties.setProperty("SORT_ALIGNMENT",
780 sortby.getSelectedItem().toString());
782 // convert description of sort order to enum name for save
783 SequenceAnnotationOrder annSortOrder = SequenceAnnotationOrder
784 .forDescription(sortAnnBy.getSelectedItem().toString());
785 if (annSortOrder != null)
787 Cache.applicationProperties.setProperty(SORT_ANNOTATIONS,
788 annSortOrder.name());
791 final boolean showAutocalcFirst = sortAutocalc.getSelectedIndex() == 0;
792 Cache.applicationProperties.setProperty(SHOW_AUTOCALC_ABOVE,
793 Boolean.valueOf(showAutocalcFirst).toString());
796 * Save Colours settings
798 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_PROT,
799 protColour.getSelectedItem().toString());
800 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_NUC,
801 nucColour.getSelectedItem().toString());
802 Cache.setColourProperty("ANNOTATIONCOLOUR_MIN",
803 minColour.getBackground());
804 Cache.setColourProperty("ANNOTATIONCOLOUR_MAX",
805 maxColour.getBackground());
808 * Save Overview settings
810 Cache.setColourProperty(GAP_COLOUR, gapColour.getBackground());
811 Cache.setColourProperty(HIDDEN_COLOUR, hiddenColour.getBackground());
812 Cache.applicationProperties.setProperty(USE_LEGACY_GAP,
813 Boolean.toString(useLegacyGap.isSelected()));
814 Cache.applicationProperties.setProperty(SHOW_OV_HIDDEN_AT_START,
815 Boolean.toString(showHiddenAtStart.isSelected()));
818 * Save Structure settings
820 Cache.applicationProperties.setProperty(ADD_TEMPFACT_ANN,
821 Boolean.toString(addTempFactor.isSelected()));
822 Cache.applicationProperties.setProperty(ADD_SS_ANN,
823 Boolean.toString(addSecondaryStructure.isSelected()));
824 Cache.applicationProperties.setProperty(USE_RNAVIEW,
825 Boolean.toString(useRnaView.isSelected()));
826 Cache.applicationProperties.setProperty(STRUCT_FROM_PDB,
827 Boolean.toString(structFromPdb.isSelected()));
828 String viewer = structViewer.getSelectedItem().toString();
829 String viewerPath = structureViewerPath.getText();
830 Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY,
832 if (viewer.equals(ViewerType.CHIMERA.name()))
834 Cache.setOrRemove(CHIMERA_PATH, viewerPath);
836 else if (viewer.equals(ViewerType.CHIMERAX.name()))
838 Cache.setOrRemove(CHIMERAX_PATH, viewerPath);
840 else if (viewer.equals(ViewerType.PYMOL.name()))
842 Cache.setOrRemove(PYMOL_PATH, viewerPath);
844 Cache.applicationProperties.setProperty("MAP_WITH_SIFTS",
845 Boolean.toString(siftsMapping.isSelected()));
846 SiftsSettings.setMapWithSifts(siftsMapping.isSelected());
849 * Save Output settings
851 Cache.applicationProperties.setProperty("EPS_RENDERING",
852 ((OptionsParam) epsRendering.getSelectedItem()).getCode());
853 Cache.applicationProperties.setProperty("HTML_RENDERING",
854 ((OptionsParam) htmlRendering.getSelectedItem()).getCode());
855 Cache.applicationProperties.setProperty("SVG_RENDERING",
856 ((OptionsParam) svgRendering.getSelectedItem()).getCode());
859 * Save Connections settings
861 // Proxy settings set first (to catch web services)
863 Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
865 jalview.util.BrowserLauncher.resetBrowser();
867 // save user-defined and selected links
868 String menuLinks = sequenceUrlLinks.writeUrlsAsString(true);
869 if (menuLinks.isEmpty())
871 Cache.applicationProperties.remove("SEQUENCE_LINKS");
875 Cache.applicationProperties.setProperty("SEQUENCE_LINKS",
876 menuLinks.toString());
879 String nonMenuLinks = sequenceUrlLinks.writeUrlsAsString(false);
880 if (nonMenuLinks.isEmpty())
882 Cache.applicationProperties.remove("STORED_LINKS");
886 Cache.applicationProperties.setProperty("STORED_LINKS",
887 nonMenuLinks.toString());
890 Cache.applicationProperties.setProperty("DEFAULT_URL",
891 sequenceUrlLinks.getPrimaryUrlId());
893 Cache.setProperty("VERSION_CHECK",
894 Boolean.toString(versioncheck.isSelected()));
895 if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
897 // default is false - we only set this if the user has actively agreed
898 Cache.setProperty("USAGESTATS",
899 Boolean.toString(usagestats.isSelected()));
901 if (!questionnaire.isSelected())
903 Cache.setProperty("NOQUESTIONNAIRES", "true");
907 // special - made easy to edit a property file to disable questionnaires
908 // by just adding the given line
909 Cache.removeProperty("NOQUESTIONNAIRES");
913 * Save Output settings
915 Cache.applicationProperties.setProperty("BLC_JVSUFFIX",
916 Boolean.toString(blcjv.isSelected()));
917 Cache.applicationProperties.setProperty("CLUSTAL_JVSUFFIX",
918 Boolean.toString(clustaljv.isSelected()));
919 Cache.applicationProperties.setProperty("FASTA_JVSUFFIX",
920 Boolean.toString(fastajv.isSelected()));
921 Cache.applicationProperties.setProperty("MSF_JVSUFFIX",
922 Boolean.toString(msfjv.isSelected()));
923 Cache.applicationProperties.setProperty("PFAM_JVSUFFIX",
924 Boolean.toString(pfamjv.isSelected()));
925 Cache.applicationProperties.setProperty("PILEUP_JVSUFFIX",
926 Boolean.toString(pileupjv.isSelected()));
927 Cache.applicationProperties.setProperty("PIR_JVSUFFIX",
928 Boolean.toString(pirjv.isSelected()));
929 Cache.applicationProperties.setProperty("PIR_MODELLER",
930 Boolean.toString(modellerOutput.isSelected()));
931 Cache.applicationProperties.setProperty("EXPORT_EMBBED_BIOJSON",
932 Boolean.toString(embbedBioJSON.isSelected()));
933 jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
935 Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH",
936 Boolean.toString(autoIdWidth.isSelected()));
937 userIdWidth_actionPerformed();
938 Cache.applicationProperties.setProperty("FIGURE_FIXEDIDWIDTH",
939 userIdWidth.getText());
942 * Save Editing settings
944 Cache.applicationProperties.setProperty("AUTO_CALC_CONSENSUS",
945 Boolean.toString(autoCalculateConsCheck.isSelected()));
946 Cache.applicationProperties.setProperty("SORT_BY_TREE",
947 Boolean.toString(sortByTree.isSelected()));
948 Cache.applicationProperties.setProperty("PAD_GAPS",
949 Boolean.toString(padGaps.isSelected()));
951 if (!Platform.isJS())
953 wsPrefs.updateAndRefreshWsMenuConfig(false);
957 * Save Backups settings
959 Cache.applicationProperties.setProperty(BackupFiles.ENABLED,
960 Boolean.toString(enableBackupFiles.isSelected()));
961 int preset = getComboIntStringKey(backupfilesPresetsCombo);
962 Cache.applicationProperties.setProperty(BackupFiles.NS + "_PRESET", Integer.toString(preset));
964 if (preset == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
966 BackupFilesPresetEntry customBFPE = getBackupfilesCurrentEntry();
967 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
968 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM, customBFPE);
969 Cache.applicationProperties
970 .setProperty(BackupFilesPresetEntry.CUSTOMCONFIG,
971 customBFPE.toString());
974 BackupFilesPresetEntry savedBFPE = BackupFilesPresetEntry.backupfilesPresetEntriesValues
976 Cache.applicationProperties.setProperty(
977 BackupFilesPresetEntry.SAVEDCONFIG, savedBFPE.toString());
979 Cache.saveProperties();
980 Desktop.instance.doConfigureStructurePrefs();
983 frame.setClosed(true);
984 } catch (Exception ex)
989 public void saveProxySettings()
991 String newProxyType = customProxy.isSelected() ? Cache.PROXYTYPE_CUSTOM
992 : noProxy.isSelected() ? Cache.PROXYTYPE_NONE
993 : Cache.PROXYTYPE_SYSTEM;
994 Cache.applicationProperties.setProperty("USE_PROXY", newProxyType);
995 Cache.setOrRemove("PROXY_SERVER", proxyServerHttpTB.getText());
996 Cache.setOrRemove("PROXY_PORT", proxyPortHttpTB.getText());
997 Cache.setOrRemove("PROXY_SERVER_HTTPS", proxyServerHttpsTB.getText());
998 Cache.setOrRemove("PROXY_PORT_HTTPS", proxyPortHttpsTB.getText());
999 Cache.setOrRemove("PROXY_AUTH",
1000 Boolean.toString(proxyAuth.isSelected()));
1001 Cache.setOrRemove("PROXY_AUTH_USERNAME", proxyAuthUsernameTB.getText());
1002 Cache.proxyAuthPassword = proxyAuthPasswordPB.getPassword();
1003 Cache.setProxyPropertiesFromPreferences(previousProxyType);
1004 if (newProxyType.equals(Cache.PROXYTYPE_CUSTOM)
1005 || !newProxyType.equals(previousProxyType))
1007 // force a re-lookup of ws if proxytype is custom or has changed
1010 previousProxyType = newProxyType;
1014 * Do any necessary validation before saving settings. Return focus to the
1015 * first tab which fails validation.
1019 private boolean validateSettings()
1021 if (!validateStructure())
1023 structureTab.requestFocusInWindow();
1030 protected boolean validateStructure()
1032 return validateViewerPath();
1040 public void startupFileTextfield_mouseClicked()
1042 // TODO: JAL-3048 not needed for Jalview-JS
1043 String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
1044 JalviewFileChooser chooser = JalviewFileChooser
1045 .forRead(Cache.getProperty("LAST_DIRECTORY"), fileFormat);
1046 chooser.setFileView(new JalviewFileView());
1047 chooser.setDialogTitle(
1048 MessageManager.getString("label.select_startup_file"));
1050 int value = chooser.showOpenDialog(this);
1052 if (value == JalviewFileChooser.APPROVE_OPTION)
1054 FileFormatI format = chooser.getSelectedFormat();
1057 Cache.applicationProperties.setProperty("DEFAULT_FILE_FORMAT",
1060 startupFileTextfield
1061 .setText(chooser.getSelectedFile().getAbsolutePath());
1072 public void cancel_actionPerformed(ActionEvent e)
1076 if (!Platform.isJS())
1078 wsPrefs.updateWsMenuConfig(true);
1079 wsPrefs.refreshWs_actionPerformed(e);
1081 frame.setClosed(true);
1082 } catch (Exception ex)
1094 public void annotations_actionPerformed(ActionEvent e)
1096 conservation.setEnabled(annotations.isSelected());
1097 quality.setEnabled(annotations.isSelected());
1098 identity.setEnabled(annotations.isSelected());
1099 showOccupancy.setEnabled(annotations.isSelected());
1100 showGroupConsensus.setEnabled(annotations.isSelected());
1101 showGroupConservation.setEnabled(annotations.isSelected());
1102 showConsensHistogram.setEnabled(annotations.isSelected()
1103 && (identity.isSelected() || showGroupConsensus.isSelected()));
1104 showConsensLogo.setEnabled(annotations.isSelected()
1105 && (identity.isSelected() || showGroupConsensus.isSelected()));
1109 public void newLink_actionPerformed(ActionEvent e)
1111 GSequenceLink link = new GSequenceLink();
1112 boolean valid = false;
1115 if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
1116 MessageManager.getString("label.new_sequence_url_link"),
1117 JvOptionPane.OK_CANCEL_OPTION, -1,
1118 null) == JvOptionPane.OK_OPTION)
1120 if (link.checkValid())
1122 if (((UrlLinkTableModel) linkUrlTable.getModel())
1123 .isUniqueName(link.getName()))
1125 ((UrlLinkTableModel) linkUrlTable.getModel())
1126 .insertRow(link.getName(), link.getURL());
1131 link.notifyDuplicate();
1144 public void editLink_actionPerformed(ActionEvent e)
1146 GSequenceLink link = new GSequenceLink();
1148 int index = linkUrlTable.getSelectedRow();
1151 // button no longer enabled if row is not selected
1152 Cache.log.debug("Edit with no row selected in linkUrlTable");
1156 int nameCol = ((UrlLinkTableModel) linkUrlTable.getModel())
1158 int urlCol = ((UrlLinkTableModel) linkUrlTable.getModel())
1160 String oldName = linkUrlTable.getValueAt(index, nameCol).toString();
1161 link.setName(oldName);
1162 link.setURL(linkUrlTable.getValueAt(index, urlCol).toString());
1164 boolean valid = false;
1167 if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
1168 MessageManager.getString("label.edit_sequence_url_link"),
1169 JvOptionPane.OK_CANCEL_OPTION, -1,
1170 null) == JvOptionPane.OK_OPTION)
1172 if (link.checkValid())
1174 if ((oldName.equals(link.getName()))
1175 || (((UrlLinkTableModel) linkUrlTable.getModel())
1176 .isUniqueName(link.getName())))
1178 linkUrlTable.setValueAt(link.getName(), index, nameCol);
1179 linkUrlTable.setValueAt(link.getURL(), index, urlCol);
1184 link.notifyDuplicate();
1197 public void deleteLink_actionPerformed(ActionEvent e)
1199 int index = linkUrlTable.getSelectedRow();
1200 int modelIndex = -1;
1203 // button no longer enabled if row is not selected
1204 Cache.log.debug("Delete with no row selected in linkUrlTable");
1209 modelIndex = linkUrlTable.convertRowIndexToModel(index);
1212 // make sure we use the model index to delete, and not the table index
1213 ((UrlLinkTableModel) linkUrlTable.getModel()).removeRow(modelIndex);
1217 public void defaultBrowser_mouseClicked(MouseEvent e)
1219 // TODO: JAL-3048 not needed for j2s
1220 if (!Platform.isJS()) // BH 2019
1227 JFileChooser chooser = new JFileChooser(".");
1228 chooser.setDialogTitle(
1229 MessageManager.getString("label.select_default_browser"));
1231 int value = chooser.showOpenDialog(this);
1233 if (value == JFileChooser.APPROVE_OPTION)
1235 defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath());
1244 * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event
1248 protected void showunconserved_actionPerformed(ActionEvent e)
1250 // TODO Auto-generated method stub
1251 super.showunconserved_actionPerformed(e);
1254 public static List<String> getGroupURLLinks()
1256 return groupURLLinks;
1260 public void minColour_actionPerformed(JPanel panel)
1262 JalviewColourChooser.showColourChooser(this,
1263 MessageManager.getString("label.select_colour_minimum_value"),
1268 public void maxColour_actionPerformed(JPanel panel)
1270 JalviewColourChooser.showColourChooser(this,
1271 MessageManager.getString("label.select_colour_maximum_value"),
1276 public void gapColour_actionPerformed(JPanel gap)
1278 if (!useLegacyGap.isSelected())
1280 JalviewColourChooser.showColourChooser(this,
1281 MessageManager.getString("label.select_gap_colour"),
1287 public void hiddenColour_actionPerformed(JPanel hidden)
1289 JalviewColourChooser.showColourChooser(this,
1290 MessageManager.getString("label.select_hidden_colour"),
1295 protected void useLegacyGaps_actionPerformed(ActionEvent e)
1297 boolean enabled = useLegacyGap.isSelected();
1300 gapColour.setBackground(
1301 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_LEGACY_GAP);
1305 gapColour.setBackground(
1306 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP);
1308 gapColour.setEnabled(!enabled);
1309 gapLabel.setEnabled(!enabled);
1313 protected void resetOvDefaults_actionPerformed(ActionEvent e)
1315 useLegacyGap.setSelected(false);
1316 useLegacyGaps_actionPerformed(null);
1317 showHiddenAtStart.setSelected(false);
1318 hiddenColour.setBackground(
1319 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_HIDDEN);
1323 protected void userIdWidth_actionPerformed()
1327 String val = userIdWidth.getText().trim();
1328 if (val.length() > 0)
1330 Integer iw = Integer.parseInt(val);
1331 if (iw.intValue() < 12)
1333 throw new NumberFormatException();
1335 userIdWidth.setText(iw.toString());
1337 } catch (NumberFormatException x)
1339 userIdWidth.setText("");
1340 JvOptionPane.showInternalMessageDialog(Desktop.desktop,
1342 .getString("warn.user_defined_width_requirements"),
1343 MessageManager.getString("label.invalid_id_column_width"),
1344 JvOptionPane.WARNING_MESSAGE);
1349 protected void autoIdWidth_actionPerformed()
1351 userIdWidth.setEnabled(!autoIdWidth.isSelected());
1352 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
1356 * Returns true if structure viewer path is to a valid executable, else shows
1357 * an error dialog. Does nothing if the path is empty, as is the case for Jmol
1358 * (built in to Jalview) or when Jalview is left to try default paths.
1360 private boolean validateViewerPath()
1362 if (structureViewerPath.getText().trim().length() > 0)
1364 File f = new File(structureViewerPath.getText());
1365 if (!f.canExecute())
1367 JvOptionPane.showInternalMessageDialog(Desktop.desktop,
1368 MessageManager.getString("label.invalid_viewer_path"),
1369 MessageManager.getString("label.invalid_viewer_path"),
1370 JvOptionPane.ERROR_MESSAGE);
1378 * If Chimera or ChimeraX or Pymol is selected, check it can be found on
1379 * default or user-specified path, if not show a warning/help dialog
1382 protected void structureViewer_actionPerformed(String selectedItem)
1384 if (selectedItem.equals(ViewerType.JMOL.name()))
1386 structureViewerPath.setEnabled(false);
1387 structureViewerPathLabel.setEnabled(false);
1390 boolean found = false;
1391 structureViewerPath.setEnabled(true);
1392 structureViewerPathLabel.setEnabled(true);
1393 structureViewerPathLabel.setText(MessageManager
1394 .formatMessage("label.viewer_path", selectedItem));
1397 * Try user-specified and standard paths for structure viewer executable
1399 String viewerPath = "";
1400 List<String> paths = null;
1403 ViewerType viewerType = ViewerType.valueOf(selectedItem);
1410 viewerPath = Cache.getDefault(CHIMERA_PATH, "");
1411 paths = StructureManager.getChimeraPaths(false);
1414 viewerPath = Cache.getDefault(CHIMERAX_PATH, "");
1415 paths = StructureManager.getChimeraPaths(true);
1418 viewerPath = Cache.getDefault(PYMOL_PATH, "");
1419 paths = PymolManager.getPymolPaths();
1422 } catch (IllegalArgumentException e)
1424 // only valid entries should be in the drop-down
1426 structureViewerPath.setText(viewerPath);
1428 paths.add(0, structureViewerPath.getText());
1429 for (String path : paths)
1431 if (new File(path.trim()).canExecute())
1440 String[] options = { "OK", "Help" };
1441 int showHelp = JvOptionPane.showInternalOptionDialog(Desktop.desktop,
1442 JvSwingUtils.wrapTooltip(true,
1443 MessageManager.getString("label.viewer_missing")),
1444 "", JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE,
1445 null, options, options[0]);
1446 if (showHelp == JvOptionPane.NO_OPTION)
1450 Help.showHelpWindow(HelpId.StructureViewer);
1451 } catch (HelpSetException e)
1453 e.printStackTrace();
1459 public class OptionsParam
1461 private String name;
1463 private String code;
1465 public OptionsParam(String name, String code)
1471 public String getName()
1476 public void setName(String name)
1481 public String getCode()
1486 public void setCode(String code)
1492 public String toString()
1498 public boolean equals(Object that)
1500 if (!(that instanceof OptionsParam))
1504 return this.code.equalsIgnoreCase(((OptionsParam) that).code);
1508 public int hashCode()
1510 return name.hashCode() + code.hashCode();
1514 private class UrlListSelectionHandler implements ListSelectionListener
1518 public void valueChanged(ListSelectionEvent e)
1520 ListSelectionModel lsm = (ListSelectionModel) e.getSource();
1522 int index = lsm.getMinSelectionIndex();
1525 // no selection, so disable delete/edit buttons
1526 editLink.setEnabled(false);
1527 deleteLink.setEnabled(false);
1530 int modelIndex = linkUrlTable.convertRowIndexToModel(index);
1532 // enable/disable edit and delete link buttons
1533 if (((UrlLinkTableModel) linkUrlTable.getModel())
1534 .isRowDeletable(modelIndex))
1536 deleteLink.setEnabled(true);
1540 deleteLink.setEnabled(false);
1543 if (((UrlLinkTableModel) linkUrlTable.getModel())
1544 .isRowEditable(modelIndex))
1546 editLink.setEnabled(true);
1550 editLink.setEnabled(false);