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();
615 defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
617 usagestats.setSelected(Cache.getDefault("USAGESTATS", false));
618 // note antisense here: default is true
620 .setSelected(Cache.getProperty("NOQUESTIONNAIRES") == null);
621 versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true));
624 * Set Output tab defaults
626 setupOutputCombo(epsRendering, "EPS_RENDERING");
627 setupOutputCombo(htmlRendering, "HTML_RENDERING");
628 setupOutputCombo(svgRendering, "SVG_RENDERING");
629 autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
630 userIdWidth.setEnabled(!autoIdWidth.isSelected());
631 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
632 Integer wi = Cache.getIntegerProperty("FIGURE_FIXEDIDWIDTH");
633 userIdWidth.setText(wi == null ? "" : wi.toString());
634 // TODO: refactor to use common enum via FormatAdapter and allow extension
635 // for new flat file formats
636 blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
637 clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
638 fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
639 msfjv.setSelected(Cache.getDefault("MSF_JVSUFFIX", true));
640 pfamjv.setSelected(Cache.getDefault("PFAM_JVSUFFIX", true));
641 pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true));
642 pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true));
643 modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false));
645 .setSelected(Cache.getDefault("EXPORT_EMBBED_BIOJSON", true));
648 * Set Editing tab defaults
650 autoCalculateConsCheck
651 .setSelected(Cache.getDefault("AUTO_CALC_CONSENSUS", true));
652 padGaps.setSelected(Cache.getDefault("PAD_GAPS", false));
653 sortByTree.setSelected(Cache.getDefault("SORT_BY_TREE", false));
655 annotations_actionPerformed(null); // update the display of the annotation
660 * Set Backups tab defaults
662 loadLastSavedBackupsOptions();
666 * A helper method that sets the items and initial selection in a character
667 * rendering option list (Prompt each time/Lineart/Text)
672 protected void setupOutputCombo(JComboBox<Object> comboBox,
675 comboBox.addItem(promptEachTimeOpt);
676 comboBox.addItem(lineArtOpt);
677 comboBox.addItem(textOpt);
680 * JalviewJS doesn't support Lineart so force it to Text
682 String defaultOption = Platform.isJS() ? "Text"
683 : Cache.getDefault(propertyKey, "Prompt each time");
684 if (defaultOption.equalsIgnoreCase("Text"))
686 comboBox.setSelectedItem(textOpt);
688 else if (defaultOption.equalsIgnoreCase("Lineart"))
690 comboBox.setSelectedItem(lineArtOpt);
694 comboBox.setSelectedItem(promptEachTimeOpt);
699 * Save user selections on the Preferences tabs to the Cache and write out to
705 public void ok_actionPerformed(ActionEvent e)
707 if (!validateSettings())
713 * Set proxy settings first (to be before web services refresh)
718 * Save Visual settings
720 Cache.applicationProperties.setProperty("SHOW_JVSUFFIX",
721 Boolean.toString(seqLimit.isSelected()));
722 Cache.applicationProperties.setProperty("RIGHT_ALIGN_IDS",
723 Boolean.toString(rightAlign.isSelected()));
724 Cache.applicationProperties.setProperty("SHOW_FULLSCREEN",
725 Boolean.toString(fullScreen.isSelected()));
726 Cache.applicationProperties.setProperty("SHOW_OVERVIEW",
727 Boolean.toString(openoverv.isSelected()));
728 Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
729 Boolean.toString(annotations.isSelected()));
730 Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
731 Boolean.toString(conservation.isSelected()));
732 Cache.applicationProperties.setProperty("SHOW_QUALITY",
733 Boolean.toString(quality.isSelected()));
734 Cache.applicationProperties.setProperty("SHOW_IDENTITY",
735 Boolean.toString(identity.isSelected()));
737 Cache.applicationProperties.setProperty("GAP_SYMBOL",
738 gapSymbolCB.getSelectedItem().toString());
740 Cache.applicationProperties.setProperty("FONT_NAME",
741 fontNameCB.getSelectedItem().toString());
742 Cache.applicationProperties.setProperty("FONT_STYLE",
743 fontStyleCB.getSelectedItem().toString());
744 Cache.applicationProperties.setProperty("FONT_SIZE",
745 fontSizeCB.getSelectedItem().toString());
747 Cache.applicationProperties.setProperty("ID_ITALICS",
748 Boolean.toString(idItalics.isSelected()));
749 Cache.applicationProperties.setProperty("SHOW_UNCONSERVED",
750 Boolean.toString(showUnconserved.isSelected()));
751 Cache.applicationProperties.setProperty(SHOW_OCCUPANCY,
752 Boolean.toString(showOccupancy.isSelected()));
753 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSENSUS",
754 Boolean.toString(showGroupConsensus.isSelected()));
755 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSERVATION",
756 Boolean.toString(showGroupConservation.isSelected()));
757 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_HISTOGRAM",
758 Boolean.toString(showConsensHistogram.isSelected()));
759 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_LOGO",
760 Boolean.toString(showConsensLogo.isSelected()));
761 Cache.applicationProperties.setProperty("ANTI_ALIAS",
762 Boolean.toString(smoothFont.isSelected()));
763 Cache.applicationProperties.setProperty(SCALE_PROTEIN_TO_CDNA,
764 Boolean.toString(scaleProteinToCdna.isSelected()));
765 Cache.applicationProperties.setProperty("SHOW_NPFEATS_TOOLTIP",
766 Boolean.toString(showNpTooltip.isSelected()));
767 Cache.applicationProperties.setProperty("SHOW_DBREFS_TOOLTIP",
768 Boolean.toString(showDbRefTooltip.isSelected()));
770 Cache.applicationProperties.setProperty("WRAP_ALIGNMENT",
771 Boolean.toString(wrap.isSelected()));
773 Cache.applicationProperties.setProperty("STARTUP_FILE",
774 startupFileTextfield.getText());
775 Cache.applicationProperties.setProperty("SHOW_STARTUP_FILE",
776 Boolean.toString(startupCheckbox.isSelected()));
778 Cache.applicationProperties.setProperty("SORT_ALIGNMENT",
779 sortby.getSelectedItem().toString());
781 // convert description of sort order to enum name for save
782 SequenceAnnotationOrder annSortOrder = SequenceAnnotationOrder
783 .forDescription(sortAnnBy.getSelectedItem().toString());
784 if (annSortOrder != null)
786 Cache.applicationProperties.setProperty(SORT_ANNOTATIONS,
787 annSortOrder.name());
790 final boolean showAutocalcFirst = sortAutocalc.getSelectedIndex() == 0;
791 Cache.applicationProperties.setProperty(SHOW_AUTOCALC_ABOVE,
792 Boolean.valueOf(showAutocalcFirst).toString());
795 * Save Colours settings
797 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_PROT,
798 protColour.getSelectedItem().toString());
799 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_NUC,
800 nucColour.getSelectedItem().toString());
801 Cache.setColourProperty("ANNOTATIONCOLOUR_MIN",
802 minColour.getBackground());
803 Cache.setColourProperty("ANNOTATIONCOLOUR_MAX",
804 maxColour.getBackground());
807 * Save Overview settings
809 Cache.setColourProperty(GAP_COLOUR, gapColour.getBackground());
810 Cache.setColourProperty(HIDDEN_COLOUR, hiddenColour.getBackground());
811 Cache.applicationProperties.setProperty(USE_LEGACY_GAP,
812 Boolean.toString(useLegacyGap.isSelected()));
813 Cache.applicationProperties.setProperty(SHOW_OV_HIDDEN_AT_START,
814 Boolean.toString(showHiddenAtStart.isSelected()));
817 * Save Structure settings
819 Cache.applicationProperties.setProperty(ADD_TEMPFACT_ANN,
820 Boolean.toString(addTempFactor.isSelected()));
821 Cache.applicationProperties.setProperty(ADD_SS_ANN,
822 Boolean.toString(addSecondaryStructure.isSelected()));
823 Cache.applicationProperties.setProperty(USE_RNAVIEW,
824 Boolean.toString(useRnaView.isSelected()));
825 Cache.applicationProperties.setProperty(STRUCT_FROM_PDB,
826 Boolean.toString(structFromPdb.isSelected()));
827 String viewer = structViewer.getSelectedItem().toString();
828 String viewerPath = structureViewerPath.getText();
829 Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY,
831 if (viewer.equals(ViewerType.CHIMERA.name()))
833 Cache.setOrRemove(CHIMERA_PATH, viewerPath);
835 else if (viewer.equals(ViewerType.CHIMERAX.name()))
837 Cache.setOrRemove(CHIMERAX_PATH, viewerPath);
839 else if (viewer.equals(ViewerType.PYMOL.name()))
841 Cache.setOrRemove(PYMOL_PATH, viewerPath);
843 Cache.applicationProperties.setProperty("MAP_WITH_SIFTS",
844 Boolean.toString(siftsMapping.isSelected()));
845 SiftsSettings.setMapWithSifts(siftsMapping.isSelected());
848 * Save Output settings
850 Cache.applicationProperties.setProperty("EPS_RENDERING",
851 ((OptionsParam) epsRendering.getSelectedItem()).getCode());
852 Cache.applicationProperties.setProperty("HTML_RENDERING",
853 ((OptionsParam) htmlRendering.getSelectedItem()).getCode());
854 Cache.applicationProperties.setProperty("SVG_RENDERING",
855 ((OptionsParam) svgRendering.getSelectedItem()).getCode());
858 * Save Connections settings
860 // Proxy settings set first (to catch web services)
862 Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
864 jalview.util.BrowserLauncher.resetBrowser();
866 // save user-defined and selected links
867 String menuLinks = sequenceUrlLinks.writeUrlsAsString(true);
868 if (menuLinks.isEmpty())
870 Cache.applicationProperties.remove("SEQUENCE_LINKS");
874 Cache.applicationProperties.setProperty("SEQUENCE_LINKS",
875 menuLinks.toString());
878 String nonMenuLinks = sequenceUrlLinks.writeUrlsAsString(false);
879 if (nonMenuLinks.isEmpty())
881 Cache.applicationProperties.remove("STORED_LINKS");
885 Cache.applicationProperties.setProperty("STORED_LINKS",
886 nonMenuLinks.toString());
889 Cache.applicationProperties.setProperty("DEFAULT_URL",
890 sequenceUrlLinks.getPrimaryUrlId());
892 Cache.setProperty("VERSION_CHECK",
893 Boolean.toString(versioncheck.isSelected()));
894 if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
896 // default is false - we only set this if the user has actively agreed
897 Cache.setProperty("USAGESTATS",
898 Boolean.toString(usagestats.isSelected()));
900 if (!questionnaire.isSelected())
902 Cache.setProperty("NOQUESTIONNAIRES", "true");
906 // special - made easy to edit a property file to disable questionnaires
907 // by just adding the given line
908 Cache.removeProperty("NOQUESTIONNAIRES");
912 * Save Output settings
914 Cache.applicationProperties.setProperty("BLC_JVSUFFIX",
915 Boolean.toString(blcjv.isSelected()));
916 Cache.applicationProperties.setProperty("CLUSTAL_JVSUFFIX",
917 Boolean.toString(clustaljv.isSelected()));
918 Cache.applicationProperties.setProperty("FASTA_JVSUFFIX",
919 Boolean.toString(fastajv.isSelected()));
920 Cache.applicationProperties.setProperty("MSF_JVSUFFIX",
921 Boolean.toString(msfjv.isSelected()));
922 Cache.applicationProperties.setProperty("PFAM_JVSUFFIX",
923 Boolean.toString(pfamjv.isSelected()));
924 Cache.applicationProperties.setProperty("PILEUP_JVSUFFIX",
925 Boolean.toString(pileupjv.isSelected()));
926 Cache.applicationProperties.setProperty("PIR_JVSUFFIX",
927 Boolean.toString(pirjv.isSelected()));
928 Cache.applicationProperties.setProperty("PIR_MODELLER",
929 Boolean.toString(modellerOutput.isSelected()));
930 Cache.applicationProperties.setProperty("EXPORT_EMBBED_BIOJSON",
931 Boolean.toString(embbedBioJSON.isSelected()));
932 jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
934 Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH",
935 Boolean.toString(autoIdWidth.isSelected()));
936 userIdWidth_actionPerformed();
937 Cache.applicationProperties.setProperty("FIGURE_FIXEDIDWIDTH",
938 userIdWidth.getText());
941 * Save Editing settings
943 Cache.applicationProperties.setProperty("AUTO_CALC_CONSENSUS",
944 Boolean.toString(autoCalculateConsCheck.isSelected()));
945 Cache.applicationProperties.setProperty("SORT_BY_TREE",
946 Boolean.toString(sortByTree.isSelected()));
947 Cache.applicationProperties.setProperty("PAD_GAPS",
948 Boolean.toString(padGaps.isSelected()));
950 if (!Platform.isJS())
952 wsPrefs.updateAndRefreshWsMenuConfig(false);
956 * Save Backups settings
958 Cache.applicationProperties.setProperty(BackupFiles.ENABLED,
959 Boolean.toString(enableBackupFiles.isSelected()));
960 int preset = getComboIntStringKey(backupfilesPresetsCombo);
961 Cache.applicationProperties.setProperty(BackupFiles.NS + "_PRESET", Integer.toString(preset));
963 if (preset == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
965 BackupFilesPresetEntry customBFPE = getBackupfilesCurrentEntry();
966 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
967 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM, customBFPE);
968 Cache.applicationProperties
969 .setProperty(BackupFilesPresetEntry.CUSTOMCONFIG,
970 customBFPE.toString());
973 BackupFilesPresetEntry savedBFPE = BackupFilesPresetEntry.backupfilesPresetEntriesValues
975 Cache.applicationProperties.setProperty(
976 BackupFilesPresetEntry.SAVEDCONFIG, savedBFPE.toString());
978 Cache.saveProperties();
979 Desktop.instance.doConfigureStructurePrefs();
982 frame.setClosed(true);
983 } catch (Exception ex)
988 public void saveProxySettings()
990 String newProxyType = customProxy.isSelected() ? Cache.PROXYTYPE_CUSTOM
991 : noProxy.isSelected() ? Cache.PROXYTYPE_NONE
992 : Cache.PROXYTYPE_SYSTEM;
993 Cache.applicationProperties.setProperty("USE_PROXY", newProxyType);
994 Cache.setOrRemove("PROXY_SERVER", proxyServerHttpTB.getText());
995 Cache.setOrRemove("PROXY_PORT", proxyPortHttpTB.getText());
996 Cache.setOrRemove("PROXY_SERVER_HTTPS", proxyServerHttpsTB.getText());
997 Cache.setOrRemove("PROXY_PORT_HTTPS", proxyPortHttpsTB.getText());
998 Cache.setOrRemove("PROXY_AUTH",
999 Boolean.toString(proxyAuth.isSelected()));
1000 Cache.setOrRemove("PROXY_AUTH_USERNAME", proxyAuthUsernameTB.getText());
1001 Cache.proxyAuthPassword = proxyAuthPasswordPB.getPassword();
1002 Cache.setProxyPropertiesFromPreferences(previousProxyType);
1003 if (newProxyType.equals(Cache.PROXYTYPE_CUSTOM)
1004 || !newProxyType.equals(previousProxyType))
1006 // force a re-lookup of ws if proxytype is custom or has changed
1009 previousProxyType = newProxyType;
1013 * Do any necessary validation before saving settings. Return focus to the
1014 * first tab which fails validation.
1018 private boolean validateSettings()
1020 if (!validateStructure())
1022 structureTab.requestFocusInWindow();
1029 protected boolean validateStructure()
1031 return validateViewerPath();
1039 public void startupFileTextfield_mouseClicked()
1041 // TODO: JAL-3048 not needed for Jalview-JS
1042 String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
1043 JalviewFileChooser chooser = JalviewFileChooser
1044 .forRead(Cache.getProperty("LAST_DIRECTORY"), fileFormat);
1045 chooser.setFileView(new JalviewFileView());
1046 chooser.setDialogTitle(
1047 MessageManager.getString("label.select_startup_file"));
1049 int value = chooser.showOpenDialog(this);
1051 if (value == JalviewFileChooser.APPROVE_OPTION)
1053 FileFormatI format = chooser.getSelectedFormat();
1056 Cache.applicationProperties.setProperty("DEFAULT_FILE_FORMAT",
1059 startupFileTextfield
1060 .setText(chooser.getSelectedFile().getAbsolutePath());
1071 public void cancel_actionPerformed(ActionEvent e)
1075 if (!Platform.isJS())
1077 wsPrefs.updateWsMenuConfig(true);
1078 wsPrefs.refreshWs_actionPerformed(e);
1080 frame.setClosed(true);
1081 } catch (Exception ex)
1093 public void annotations_actionPerformed(ActionEvent e)
1095 conservation.setEnabled(annotations.isSelected());
1096 quality.setEnabled(annotations.isSelected());
1097 identity.setEnabled(annotations.isSelected());
1098 showOccupancy.setEnabled(annotations.isSelected());
1099 showGroupConsensus.setEnabled(annotations.isSelected());
1100 showGroupConservation.setEnabled(annotations.isSelected());
1101 showConsensHistogram.setEnabled(annotations.isSelected()
1102 && (identity.isSelected() || showGroupConsensus.isSelected()));
1103 showConsensLogo.setEnabled(annotations.isSelected()
1104 && (identity.isSelected() || showGroupConsensus.isSelected()));
1108 public void newLink_actionPerformed(ActionEvent e)
1110 GSequenceLink link = new GSequenceLink();
1111 boolean valid = false;
1114 if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
1115 MessageManager.getString("label.new_sequence_url_link"),
1116 JvOptionPane.OK_CANCEL_OPTION, -1,
1117 null) == JvOptionPane.OK_OPTION)
1119 if (link.checkValid())
1121 if (((UrlLinkTableModel) linkUrlTable.getModel())
1122 .isUniqueName(link.getName()))
1124 ((UrlLinkTableModel) linkUrlTable.getModel())
1125 .insertRow(link.getName(), link.getURL());
1130 link.notifyDuplicate();
1143 public void editLink_actionPerformed(ActionEvent e)
1145 GSequenceLink link = new GSequenceLink();
1147 int index = linkUrlTable.getSelectedRow();
1150 // button no longer enabled if row is not selected
1151 Cache.log.debug("Edit with no row selected in linkUrlTable");
1155 int nameCol = ((UrlLinkTableModel) linkUrlTable.getModel())
1157 int urlCol = ((UrlLinkTableModel) linkUrlTable.getModel())
1159 String oldName = linkUrlTable.getValueAt(index, nameCol).toString();
1160 link.setName(oldName);
1161 link.setURL(linkUrlTable.getValueAt(index, urlCol).toString());
1163 boolean valid = false;
1166 if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
1167 MessageManager.getString("label.edit_sequence_url_link"),
1168 JvOptionPane.OK_CANCEL_OPTION, -1,
1169 null) == JvOptionPane.OK_OPTION)
1171 if (link.checkValid())
1173 if ((oldName.equals(link.getName()))
1174 || (((UrlLinkTableModel) linkUrlTable.getModel())
1175 .isUniqueName(link.getName())))
1177 linkUrlTable.setValueAt(link.getName(), index, nameCol);
1178 linkUrlTable.setValueAt(link.getURL(), index, urlCol);
1183 link.notifyDuplicate();
1196 public void deleteLink_actionPerformed(ActionEvent e)
1198 int index = linkUrlTable.getSelectedRow();
1199 int modelIndex = -1;
1202 // button no longer enabled if row is not selected
1203 Cache.log.debug("Delete with no row selected in linkUrlTable");
1208 modelIndex = linkUrlTable.convertRowIndexToModel(index);
1211 // make sure we use the model index to delete, and not the table index
1212 ((UrlLinkTableModel) linkUrlTable.getModel()).removeRow(modelIndex);
1216 public void defaultBrowser_mouseClicked(MouseEvent e)
1218 // TODO: JAL-3048 not needed for j2s
1219 if (!Platform.isJS()) // BH 2019
1226 JFileChooser chooser = new JFileChooser(".");
1227 chooser.setDialogTitle(
1228 MessageManager.getString("label.select_default_browser"));
1230 int value = chooser.showOpenDialog(this);
1232 if (value == JFileChooser.APPROVE_OPTION)
1234 defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath());
1243 * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event
1247 protected void showunconserved_actionPerformed(ActionEvent e)
1249 // TODO Auto-generated method stub
1250 super.showunconserved_actionPerformed(e);
1253 public static List<String> getGroupURLLinks()
1255 return groupURLLinks;
1259 public void minColour_actionPerformed(JPanel panel)
1261 JalviewColourChooser.showColourChooser(this,
1262 MessageManager.getString("label.select_colour_minimum_value"),
1267 public void maxColour_actionPerformed(JPanel panel)
1269 JalviewColourChooser.showColourChooser(this,
1270 MessageManager.getString("label.select_colour_maximum_value"),
1275 public void gapColour_actionPerformed(JPanel gap)
1277 if (!useLegacyGap.isSelected())
1279 JalviewColourChooser.showColourChooser(this,
1280 MessageManager.getString("label.select_gap_colour"),
1286 public void hiddenColour_actionPerformed(JPanel hidden)
1288 JalviewColourChooser.showColourChooser(this,
1289 MessageManager.getString("label.select_hidden_colour"),
1294 protected void useLegacyGaps_actionPerformed(ActionEvent e)
1296 boolean enabled = useLegacyGap.isSelected();
1299 gapColour.setBackground(
1300 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_LEGACY_GAP);
1304 gapColour.setBackground(
1305 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP);
1307 gapColour.setEnabled(!enabled);
1308 gapLabel.setEnabled(!enabled);
1312 protected void resetOvDefaults_actionPerformed(ActionEvent e)
1314 useLegacyGap.setSelected(false);
1315 useLegacyGaps_actionPerformed(null);
1316 showHiddenAtStart.setSelected(false);
1317 hiddenColour.setBackground(
1318 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_HIDDEN);
1322 protected void userIdWidth_actionPerformed()
1326 String val = userIdWidth.getText().trim();
1327 if (val.length() > 0)
1329 Integer iw = Integer.parseInt(val);
1330 if (iw.intValue() < 12)
1332 throw new NumberFormatException();
1334 userIdWidth.setText(iw.toString());
1336 } catch (NumberFormatException x)
1338 userIdWidth.setText("");
1339 JvOptionPane.showInternalMessageDialog(Desktop.desktop,
1341 .getString("warn.user_defined_width_requirements"),
1342 MessageManager.getString("label.invalid_id_column_width"),
1343 JvOptionPane.WARNING_MESSAGE);
1348 protected void autoIdWidth_actionPerformed()
1350 userIdWidth.setEnabled(!autoIdWidth.isSelected());
1351 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
1355 * Returns true if structure viewer path is to a valid executable, else shows
1356 * an error dialog. Does nothing if the path is empty, as is the case for Jmol
1357 * (built in to Jalview) or when Jalview is left to try default paths.
1359 private boolean validateViewerPath()
1361 if (structureViewerPath.getText().trim().length() > 0)
1363 File f = new File(structureViewerPath.getText());
1364 if (!f.canExecute())
1366 JvOptionPane.showInternalMessageDialog(Desktop.desktop,
1367 MessageManager.getString("label.invalid_viewer_path"),
1368 MessageManager.getString("label.invalid_viewer_path"),
1369 JvOptionPane.ERROR_MESSAGE);
1377 * If Chimera or ChimeraX or Pymol is selected, check it can be found on
1378 * default or user-specified path, if not show a warning/help dialog
1381 protected void structureViewer_actionPerformed(String selectedItem)
1383 if (selectedItem.equals(ViewerType.JMOL.name()))
1385 structureViewerPath.setEnabled(false);
1386 structureViewerPathLabel.setEnabled(false);
1389 boolean found = false;
1390 structureViewerPath.setEnabled(true);
1391 structureViewerPathLabel.setEnabled(true);
1392 structureViewerPathLabel.setText(MessageManager
1393 .formatMessage("label.viewer_path", selectedItem));
1396 * Try user-specified and standard paths for structure viewer executable
1398 String viewerPath = "";
1399 List<String> paths = null;
1402 ViewerType viewerType = ViewerType.valueOf(selectedItem);
1409 viewerPath = Cache.getDefault(CHIMERA_PATH, "");
1410 paths = StructureManager.getChimeraPaths(false);
1413 viewerPath = Cache.getDefault(CHIMERAX_PATH, "");
1414 paths = StructureManager.getChimeraPaths(true);
1417 viewerPath = Cache.getDefault(PYMOL_PATH, "");
1418 paths = PymolManager.getPymolPaths();
1421 } catch (IllegalArgumentException e)
1423 // only valid entries should be in the drop-down
1425 structureViewerPath.setText(viewerPath);
1427 paths.add(0, structureViewerPath.getText());
1428 for (String path : paths)
1430 if (new File(path.trim()).canExecute())
1439 String[] options = { "OK", "Help" };
1440 int showHelp = JvOptionPane.showInternalOptionDialog(Desktop.desktop,
1441 JvSwingUtils.wrapTooltip(true,
1442 MessageManager.getString("label.viewer_missing")),
1443 "", JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE,
1444 null, options, options[0]);
1445 if (showHelp == JvOptionPane.NO_OPTION)
1449 Help.showHelpWindow(HelpId.StructureViewer);
1450 } catch (HelpSetException e)
1452 e.printStackTrace();
1458 public class OptionsParam
1460 private String name;
1462 private String code;
1464 public OptionsParam(String name, String code)
1470 public String getName()
1475 public void setName(String name)
1480 public String getCode()
1485 public void setCode(String code)
1491 public String toString()
1497 public boolean equals(Object that)
1499 if (!(that instanceof OptionsParam))
1503 return this.code.equalsIgnoreCase(((OptionsParam) that).code);
1507 public int hashCode()
1509 return name.hashCode() + code.hashCode();
1513 private class UrlListSelectionHandler implements ListSelectionListener
1517 public void valueChanged(ListSelectionEvent e)
1519 ListSelectionModel lsm = (ListSelectionModel) e.getSource();
1521 int index = lsm.getMinSelectionIndex();
1524 // no selection, so disable delete/edit buttons
1525 editLink.setEnabled(false);
1526 deleteLink.setEnabled(false);
1529 int modelIndex = linkUrlTable.convertRowIndexToModel(index);
1531 // enable/disable edit and delete link buttons
1532 if (((UrlLinkTableModel) linkUrlTable.getModel())
1533 .isRowDeletable(modelIndex))
1535 deleteLink.setEnabled(true);
1539 deleteLink.setEnabled(false);
1542 if (((UrlLinkTableModel) linkUrlTable.getModel())
1543 .isRowEditable(modelIndex))
1545 editLink.setEnabled(true);
1549 editLink.setEnabled(false);