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;
84 public class Preferences extends GPreferences
86 public static final String ENABLE_SPLIT_FRAME = "ENABLE_SPLIT_FRAME";
88 public static final String SCALE_PROTEIN_TO_CDNA = "SCALE_PROTEIN_TO_CDNA";
90 public static final String DEFAULT_COLOUR = "DEFAULT_COLOUR";
92 public static final String DEFAULT_COLOUR_PROT = "DEFAULT_COLOUR_PROT";
94 public static final String DEFAULT_COLOUR_NUC = "DEFAULT_COLOUR_NUC";
96 public static final String ADD_TEMPFACT_ANN = "ADD_TEMPFACT_ANN";
98 public static final String ADD_SS_ANN = "ADD_SS_ANN";
100 public static final String USE_RNAVIEW = "USE_RNAVIEW";
102 public static final String STRUCT_FROM_PDB = "STRUCT_FROM_PDB";
104 public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY";
106 public static final String CHIMERA_PATH = "CHIMERA_PATH";
108 public static final String CHIMERAX_PATH = "CHIMERAX_PATH";
110 public static final String PYMOL_PATH = "PYMOL_PATH";
112 public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS";
114 public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE";
116 public static final String SHOW_OCCUPANCY = "SHOW_OCCUPANCY";
118 public static final String SHOW_OV_HIDDEN_AT_START = "SHOW_OV_HIDDEN_AT_START";
120 public static final String USE_LEGACY_GAP = "USE_LEGACY_GAP";
122 public static final String GAP_COLOUR = "GAP_COLOUR";
124 public static final String HIDDEN_COLOUR = "HIDDEN_COLOUR";
126 private static final int MIN_FONT_SIZE = 1;
128 private static final int MAX_FONT_SIZE = 30;
130 private String previousProxyType;
133 * Holds name and link separated with | character. Sequence ID must be
134 * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$
136 public static UrlProviderI sequenceUrlLinks;
138 public static UrlLinkTableModel dataModel;
141 * Holds name and link separated with | character. Sequence IDS and Sequences
142 * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and
143 * $SEQUENCES$ or $SEQUENCES=/.possible | chars ./=$ and separation character
144 * for first and second token specified after a pipe character at end |,|.
145 * (TODO: proper escape for using | to separate ids or sequences
148 public static List<String> groupURLLinks;
151 // get links selected to be in the menu (SEQUENCE_LINKS)
152 // and links entered by the user but not selected (STORED_LINKS)
153 String inMenuString = Cache.getDefault("SEQUENCE_LINKS", "");
154 String notInMenuString = Cache.getDefault("STORED_LINKS", "");
155 String defaultUrl = Cache.getDefault("DEFAULT_URL",
156 UrlConstants.DEFAULT_LABEL);
158 // if both links lists are empty, add the DEFAULT_URL link
159 // otherwise we assume the default link is in one of the lists
160 if (inMenuString.isEmpty() && notInMenuString.isEmpty())
162 inMenuString = UrlConstants.DEFAULT_STRING;
164 UrlProviderFactoryI factory = new DesktopUrlProviderFactory(defaultUrl,
165 inMenuString, notInMenuString);
166 sequenceUrlLinks = factory.createUrlProvider();
167 dataModel = new UrlLinkTableModel(sequenceUrlLinks);
170 * TODO: reformulate groupURL encoding so two or more can be stored in the
171 * .properties file as '|' separated strings
174 groupURLLinks = new ArrayList<>();
177 JInternalFrame frame;
179 private WsPreferences wsPrefs;
181 private OptionsParam promptEachTimeOpt = new OptionsParam(
182 MessageManager.getString("label.prompt_each_time"),
185 private OptionsParam lineArtOpt = new OptionsParam(
186 MessageManager.getString("label.lineart"), "Lineart");
188 private OptionsParam textOpt = new OptionsParam(
189 MessageManager.getString("action.text"), "Text");
192 * Creates a new Preferences object.
199 public Preferences(int selectTab)
201 new Preferences(selectTab, null);
204 public Preferences(int selectTab, String message)
206 super(selectTab, message);
207 frame = new JInternalFrame();
208 frame.setContentPane(this);
209 if (!Platform.isJS())
216 wsPrefs = new WsPreferences();
217 wsTab.add(wsPrefs, BorderLayout.CENTER);
219 int width = 500, height = 450;
220 if (Platform.isAMacAndNotJS())
226 Desktop.addInternalFrame(frame,
227 MessageManager.getString("label.preferences"), width, height);
228 frame.setMinimumSize(new Dimension(width, height));
231 * Set Visual tab defaults
233 seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true));
234 rightAlign.setSelected(Cache.getDefault("RIGHT_ALIGN_IDS", false));
235 fullScreen.setSelected(Cache.getDefault("SHOW_FULLSCREEN", false));
236 annotations.setSelected(Cache.getDefault("SHOW_ANNOTATIONS", true));
238 conservation.setSelected(Cache.getDefault("SHOW_CONSERVATION", true));
239 quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));
240 identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
241 openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false));
243 .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
244 showOccupancy.setSelected(Cache.getDefault(SHOW_OCCUPANCY, false));
246 .setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS", false));
247 showGroupConservation.setSelected(
248 Cache.getDefault("SHOW_GROUP_CONSERVATION", false));
249 showConsensHistogram.setSelected(
250 Cache.getDefault("SHOW_CONSENSUS_HISTOGRAM", true));
252 .setSelected(Cache.getDefault("SHOW_CONSENSUS_LOGO", false));
254 .setSelected(Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true));
256 .setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP", true));
258 String[] fonts = java.awt.GraphicsEnvironment
259 .getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
260 for (int i = 0; i < fonts.length; i++)
262 fontNameCB.addItem(fonts[i]);
265 for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++)
267 fontSizeCB.addItem(i + "");
270 fontStyleCB.addItem("plain");
271 fontStyleCB.addItem("bold");
272 fontStyleCB.addItem("italic");
274 fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif"));
275 fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10"));
276 fontStyleCB.setSelectedItem(
277 Cache.getDefault("FONT_STYLE", Font.PLAIN + ""));
279 smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", true));
281 .setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA, false));
283 idItalics.setSelected(Cache.getDefault("ID_ITALICS", true));
285 wrap.setSelected(Cache.getDefault("WRAP_ALIGNMENT", false));
287 gapSymbolCB.addItem("-");
288 gapSymbolCB.addItem(".");
290 gapSymbolCB.setSelectedItem(Cache.getDefault("GAP_SYMBOL", "-"));
292 sortby.addItem("No sort");
293 sortby.addItem("Id");
294 sortby.addItem("Pairwise Identity");
295 sortby.setSelectedItem(Cache.getDefault("SORT_ALIGNMENT", "No sort"));
297 sortAnnBy.addItem(SequenceAnnotationOrder.NONE.toString());
299 .addItem(SequenceAnnotationOrder.SEQUENCE_AND_LABEL.toString());
301 .addItem(SequenceAnnotationOrder.LABEL_AND_SEQUENCE.toString());
302 SequenceAnnotationOrder savedSort = SequenceAnnotationOrder
303 .valueOf(Cache.getDefault(SORT_ANNOTATIONS,
304 SequenceAnnotationOrder.NONE.name()));
305 sortAnnBy.setSelectedItem(savedSort.toString());
307 sortAutocalc.addItem("Autocalculated first");
308 sortAutocalc.addItem("Autocalculated last");
309 final boolean showAbove = Cache.getDefault(SHOW_AUTOCALC_ABOVE, true);
310 sortAutocalc.setSelectedItem(showAbove ? sortAutocalc.getItemAt(0)
311 : sortAutocalc.getItemAt(1));
313 .setSelected(Cache.getDefault("SHOW_STARTUP_FILE", true));
314 startupFileTextfield.setText(Cache.getDefault("STARTUP_FILE",
315 Cache.getDefault("www.jalview.org", "http://www.jalview.org")
316 + "/examples/exampleFile_2_3.jar"));
319 * Set Colours tab defaults
321 protColour.addItem(ResidueColourScheme.NONE);
322 nucColour.addItem(ResidueColourScheme.NONE);
323 for (ColourSchemeI cs : ColourSchemes.getInstance().getColourSchemes())
325 String name = cs.getSchemeName();
326 protColour.addItem(name);
327 nucColour.addItem(name);
329 String oldProp = Cache.getDefault(DEFAULT_COLOUR,
330 ResidueColourScheme.NONE);
331 String newProp = Cache.getDefault(DEFAULT_COLOUR_PROT, null);
332 protColour.setSelectedItem(newProp != null ? newProp : oldProp);
333 newProp = Cache.getDefault(DEFAULT_COLOUR_NUC, null);
334 nucColour.setSelectedItem(newProp != null ? newProp : oldProp);
335 minColour.setBackground(
336 Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN", Color.orange));
337 maxColour.setBackground(
338 Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX", Color.red));
341 * Set overview panel defaults
343 gapColour.setBackground(
344 Cache.getDefaultColour(GAP_COLOUR,
345 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP));
346 hiddenColour.setBackground(
347 Cache.getDefaultColour(HIDDEN_COLOUR,
348 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_HIDDEN));
349 useLegacyGap.setSelected(Cache.getDefault(USE_LEGACY_GAP, false));
350 gapLabel.setEnabled(!useLegacyGap.isSelected());
351 gapColour.setEnabled(!useLegacyGap.isSelected());
353 .setSelected(Cache.getDefault(SHOW_OV_HIDDEN_AT_START, false));
356 * Set Structure tab defaults
358 final boolean structSelected = Cache.getDefault(STRUCT_FROM_PDB, false);
359 structFromPdb.setSelected(structSelected);
360 useRnaView.setSelected(Cache.getDefault(USE_RNAVIEW, false));
361 useRnaView.setEnabled(structSelected);
362 addSecondaryStructure.setSelected(Cache.getDefault(ADD_SS_ANN, false));
363 addSecondaryStructure.setEnabled(structSelected);
364 addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, false));
365 addTempFactor.setEnabled(structSelected);
368 * set choice of structure viewer, and path if saved as a preference;
369 * default to Jmol (first choice) if an unexpected value is found
371 String viewerType = Cache.getDefault(STRUCTURE_DISPLAY, ViewerType.JMOL.name());
372 structViewer.setSelectedItem(viewerType);
373 String viewerPath = "";
374 ViewerType type = null;
377 type = ViewerType.valueOf(viewerType);
383 viewerPath = Cache.getDefault(CHIMERA_PATH, "");
386 viewerPath = Cache.getDefault(CHIMERAX_PATH, "");
389 viewerPath = Cache.getDefault(PYMOL_PATH, "");
392 } catch (IllegalArgumentException e)
394 Cache.log.error("Unknown structure viewer type: " + viewerType
395 + ", defaulting to Jmol");
396 type = ViewerType.JMOL;
398 structureViewerPath.setText(viewerPath);
400 structureViewerPath.addActionListener(new ActionListener()
403 public void actionPerformed(ActionEvent e)
405 if (validateViewerPath())
407 Cache.setProperty(structViewer.getSelectedItem()
408 .equals(ViewerType.CHIMERAX.name())
410 : CHIMERA_PATH, structureViewerPath.getText());
415 if (Cache.getDefault("MAP_WITH_SIFTS", false))
417 siftsMapping.setSelected(true);
421 nwMapping.setSelected(true);
425 .setMapWithSifts(Cache.getDefault("MAP_WITH_SIFTS", false));
428 * Set Connections tab defaults
432 linkUrlTable.setModel(dataModel);
433 final TableRowSorter<TableModel> sorter = new TableRowSorter<>(
434 linkUrlTable.getModel());
435 linkUrlTable.setRowSorter(sorter);
436 List<RowSorter.SortKey> sortKeys = new ArrayList<>();
438 UrlLinkTableModel m = (UrlLinkTableModel) linkUrlTable.getModel();
439 sortKeys.add(new RowSorter.SortKey(m.getPrimaryColumn(),
440 SortOrder.DESCENDING));
441 sortKeys.add(new RowSorter.SortKey(m.getSelectedColumn(),
442 SortOrder.DESCENDING));
444 new RowSorter.SortKey(m.getNameColumn(), SortOrder.ASCENDING));
446 sorter.setSortKeys(sortKeys);
447 // BH 2018 setSortKeys will do the sort
451 ActionListener onReset;
452 onReset = new ActionListener()
455 public void actionPerformed(ActionEvent e)
457 filterTB.setText("");
458 sorter.setRowFilter(RowFilter.regexFilter(""));
462 doReset.addActionListener(onReset);
464 // filter to display only custom urls
465 final RowFilter<TableModel, Object> customUrlFilter = new RowFilter<TableModel, Object>()
468 public boolean include(
469 Entry<? extends TableModel, ? extends Object> entry)
471 return ((UrlLinkTableModel) entry.getModel()).isUserEntry(entry);
475 final TableRowSorter<TableModel> customSorter = new TableRowSorter<>(
476 linkUrlTable.getModel());
477 customSorter.setRowFilter(customUrlFilter);
479 ActionListener onCustomOnly;
480 onCustomOnly = new ActionListener()
483 public void actionPerformed(ActionEvent e)
485 filterTB.setText("");
486 sorter.setRowFilter(customUrlFilter);
489 userOnly.addActionListener(onCustomOnly);
491 filterTB.getDocument().addDocumentListener(new DocumentListener()
493 String caseInsensitiveFlag = "(?i)";
496 public void changedUpdate(DocumentEvent e)
498 sorter.setRowFilter(RowFilter
499 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
503 public void removeUpdate(DocumentEvent e)
505 sorter.setRowFilter(RowFilter
506 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
510 public void insertUpdate(DocumentEvent e)
512 sorter.setRowFilter(RowFilter
513 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
517 // set up list selection functionality
518 linkUrlTable.getSelectionModel()
519 .addListSelectionListener(new UrlListSelectionHandler());
521 // set up radio buttons
522 int onClickCol = ((UrlLinkTableModel) linkUrlTable.getModel())
524 String onClickName = linkUrlTable.getColumnName(onClickCol);
525 linkUrlTable.getColumn(onClickName)
526 .setCellRenderer(new RadioButtonRenderer());
527 linkUrlTable.getColumn(onClickName)
528 .setCellEditor(new RadioButtonEditor());
530 // get boolean columns and resize those to min possible
531 for (int column = 0; column < linkUrlTable.getColumnCount(); column++)
533 if (linkUrlTable.getModel().getColumnClass(column)
534 .equals(Boolean.class))
536 TableColumn tableColumn = linkUrlTable.getColumnModel()
538 int preferredWidth = tableColumn.getMinWidth();
540 TableCellRenderer cellRenderer = linkUrlTable.getCellRenderer(0,
542 Component c = linkUrlTable.prepareRenderer(cellRenderer, 0, column);
543 int cwidth = c.getPreferredSize().width
544 + linkUrlTable.getIntercellSpacing().width;
545 preferredWidth = Math.max(preferredWidth, cwidth);
547 tableColumn.setPreferredWidth(preferredWidth);
551 String proxyTypeString = Cache.getDefault("USE_PROXY", "false");
552 previousProxyType = proxyTypeString;
553 switch (proxyTypeString)
555 case Cache.PROXYTYPE_NONE:
556 proxyType.setSelected(noProxy.getModel(), true);
558 case Cache.PROXYTYPE_SYSTEM:
559 proxyType.setSelected(systemProxy.getModel(), true);
561 case Cache.PROXYTYPE_CUSTOM:
562 proxyType.setSelected(customProxy.getModel(), true);
566 "Incorrect PROXY_TYPE - should be 'none' (clear proxy properties), 'false' (system settings), 'true' (custom settings): "
569 proxyServerHttpTB.setText(Cache.getDefault("PROXY_SERVER", ""));
570 proxyPortHttpTB.setText(Cache.getDefault("PROXY_PORT", ""));
571 proxyServerHttpsTB.setText(Cache.getDefault("PROXY_SERVER_HTTPS", ""));
572 proxyPortHttpsTB.setText(Cache.getDefault("PROXY_PORT_HTTPS", ""));
573 proxyAuth.setSelected(Cache.getDefault("PROXY_AUTH", false));
575 .setText(Cache.getDefault("PROXY_AUTH_USERNAME", ""));
576 // we are not storing or retrieving proxy password from .jalview_properties
577 proxyAuthPasswordTB.setText(Cache.proxyAuthPassword == null ? ""
578 : new String(Cache.proxyAuthPassword));
579 setCustomProxyEnabled();
581 defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
583 usagestats.setSelected(Cache.getDefault("USAGESTATS", false));
584 // note antisense here: default is true
586 .setSelected(Cache.getProperty("NOQUESTIONNAIRES") == null);
587 versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true));
590 * Set Output tab defaults
592 setupOutputCombo(epsRendering, "EPS_RENDERING");
593 setupOutputCombo(htmlRendering, "HTML_RENDERING");
594 setupOutputCombo(svgRendering, "SVG_RENDERING");
595 autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
596 userIdWidth.setEnabled(!autoIdWidth.isSelected());
597 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
598 Integer wi = Cache.getIntegerProperty("FIGURE_FIXEDIDWIDTH");
599 userIdWidth.setText(wi == null ? "" : wi.toString());
600 // TODO: refactor to use common enum via FormatAdapter and allow extension
601 // for new flat file formats
602 blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
603 clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
604 fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
605 msfjv.setSelected(Cache.getDefault("MSF_JVSUFFIX", true));
606 pfamjv.setSelected(Cache.getDefault("PFAM_JVSUFFIX", true));
607 pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true));
608 pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true));
609 modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false));
611 .setSelected(Cache.getDefault("EXPORT_EMBBED_BIOJSON", true));
614 * Set Editing tab defaults
616 autoCalculateConsCheck
617 .setSelected(Cache.getDefault("AUTO_CALC_CONSENSUS", true));
618 padGaps.setSelected(Cache.getDefault("PAD_GAPS", false));
619 sortByTree.setSelected(Cache.getDefault("SORT_BY_TREE", false));
621 annotations_actionPerformed(null); // update the display of the annotation
626 * Set Backups tab defaults
628 loadLastSavedBackupsOptions();
632 * A helper method that sets the items and initial selection in a character
633 * rendering option list (Prompt each time/Lineart/Text)
638 protected void setupOutputCombo(JComboBox<Object> comboBox,
641 comboBox.addItem(promptEachTimeOpt);
642 comboBox.addItem(lineArtOpt);
643 comboBox.addItem(textOpt);
646 * JalviewJS doesn't support Lineart so force it to Text
648 String defaultOption = Platform.isJS() ? "Text"
649 : Cache.getDefault(propertyKey, "Prompt each time");
650 if (defaultOption.equalsIgnoreCase("Text"))
652 comboBox.setSelectedItem(textOpt);
654 else if (defaultOption.equalsIgnoreCase("Lineart"))
656 comboBox.setSelectedItem(lineArtOpt);
660 comboBox.setSelectedItem(promptEachTimeOpt);
665 * Save user selections on the Preferences tabs to the Cache and write out to
671 public void ok_actionPerformed(ActionEvent e)
673 if (!validateSettings())
679 * Save Visual settings
681 Cache.applicationProperties.setProperty("SHOW_JVSUFFIX",
682 Boolean.toString(seqLimit.isSelected()));
683 Cache.applicationProperties.setProperty("RIGHT_ALIGN_IDS",
684 Boolean.toString(rightAlign.isSelected()));
685 Cache.applicationProperties.setProperty("SHOW_FULLSCREEN",
686 Boolean.toString(fullScreen.isSelected()));
687 Cache.applicationProperties.setProperty("SHOW_OVERVIEW",
688 Boolean.toString(openoverv.isSelected()));
689 Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
690 Boolean.toString(annotations.isSelected()));
691 Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
692 Boolean.toString(conservation.isSelected()));
693 Cache.applicationProperties.setProperty("SHOW_QUALITY",
694 Boolean.toString(quality.isSelected()));
695 Cache.applicationProperties.setProperty("SHOW_IDENTITY",
696 Boolean.toString(identity.isSelected()));
698 Cache.applicationProperties.setProperty("GAP_SYMBOL",
699 gapSymbolCB.getSelectedItem().toString());
701 Cache.applicationProperties.setProperty("FONT_NAME",
702 fontNameCB.getSelectedItem().toString());
703 Cache.applicationProperties.setProperty("FONT_STYLE",
704 fontStyleCB.getSelectedItem().toString());
705 Cache.applicationProperties.setProperty("FONT_SIZE",
706 fontSizeCB.getSelectedItem().toString());
708 Cache.applicationProperties.setProperty("ID_ITALICS",
709 Boolean.toString(idItalics.isSelected()));
710 Cache.applicationProperties.setProperty("SHOW_UNCONSERVED",
711 Boolean.toString(showUnconserved.isSelected()));
712 Cache.applicationProperties.setProperty(SHOW_OCCUPANCY,
713 Boolean.toString(showOccupancy.isSelected()));
714 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSENSUS",
715 Boolean.toString(showGroupConsensus.isSelected()));
716 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSERVATION",
717 Boolean.toString(showGroupConservation.isSelected()));
718 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_HISTOGRAM",
719 Boolean.toString(showConsensHistogram.isSelected()));
720 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_LOGO",
721 Boolean.toString(showConsensLogo.isSelected()));
722 Cache.applicationProperties.setProperty("ANTI_ALIAS",
723 Boolean.toString(smoothFont.isSelected()));
724 Cache.applicationProperties.setProperty(SCALE_PROTEIN_TO_CDNA,
725 Boolean.toString(scaleProteinToCdna.isSelected()));
726 Cache.applicationProperties.setProperty("SHOW_NPFEATS_TOOLTIP",
727 Boolean.toString(showNpTooltip.isSelected()));
728 Cache.applicationProperties.setProperty("SHOW_DBREFS_TOOLTIP",
729 Boolean.toString(showDbRefTooltip.isSelected()));
731 Cache.applicationProperties.setProperty("WRAP_ALIGNMENT",
732 Boolean.toString(wrap.isSelected()));
734 Cache.applicationProperties.setProperty("STARTUP_FILE",
735 startupFileTextfield.getText());
736 Cache.applicationProperties.setProperty("SHOW_STARTUP_FILE",
737 Boolean.toString(startupCheckbox.isSelected()));
739 Cache.applicationProperties.setProperty("SORT_ALIGNMENT",
740 sortby.getSelectedItem().toString());
742 // convert description of sort order to enum name for save
743 SequenceAnnotationOrder annSortOrder = SequenceAnnotationOrder
744 .forDescription(sortAnnBy.getSelectedItem().toString());
745 if (annSortOrder != null)
747 Cache.applicationProperties.setProperty(SORT_ANNOTATIONS,
748 annSortOrder.name());
751 final boolean showAutocalcFirst = sortAutocalc.getSelectedIndex() == 0;
752 Cache.applicationProperties.setProperty(SHOW_AUTOCALC_ABOVE,
753 Boolean.valueOf(showAutocalcFirst).toString());
756 * Save Colours settings
758 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_PROT,
759 protColour.getSelectedItem().toString());
760 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_NUC,
761 nucColour.getSelectedItem().toString());
762 Cache.setColourProperty("ANNOTATIONCOLOUR_MIN",
763 minColour.getBackground());
764 Cache.setColourProperty("ANNOTATIONCOLOUR_MAX",
765 maxColour.getBackground());
768 * Save Overview settings
770 Cache.setColourProperty(GAP_COLOUR, gapColour.getBackground());
771 Cache.setColourProperty(HIDDEN_COLOUR, hiddenColour.getBackground());
772 Cache.applicationProperties.setProperty(USE_LEGACY_GAP,
773 Boolean.toString(useLegacyGap.isSelected()));
774 Cache.applicationProperties.setProperty(SHOW_OV_HIDDEN_AT_START,
775 Boolean.toString(showHiddenAtStart.isSelected()));
778 * Save Structure settings
780 Cache.applicationProperties.setProperty(ADD_TEMPFACT_ANN,
781 Boolean.toString(addTempFactor.isSelected()));
782 Cache.applicationProperties.setProperty(ADD_SS_ANN,
783 Boolean.toString(addSecondaryStructure.isSelected()));
784 Cache.applicationProperties.setProperty(USE_RNAVIEW,
785 Boolean.toString(useRnaView.isSelected()));
786 Cache.applicationProperties.setProperty(STRUCT_FROM_PDB,
787 Boolean.toString(structFromPdb.isSelected()));
788 String viewer = structViewer.getSelectedItem().toString();
789 String viewerPath = structureViewerPath.getText();
790 Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY,
792 if (viewer.equals(ViewerType.CHIMERA.name()))
794 Cache.setOrRemove(CHIMERA_PATH, viewerPath);
796 else if (viewer.equals(ViewerType.CHIMERAX.name()))
798 Cache.setOrRemove(CHIMERAX_PATH, viewerPath);
800 else if (viewer.equals(ViewerType.PYMOL.name()))
802 Cache.setOrRemove(PYMOL_PATH, viewerPath);
804 Cache.applicationProperties.setProperty("MAP_WITH_SIFTS",
805 Boolean.toString(siftsMapping.isSelected()));
806 SiftsSettings.setMapWithSifts(siftsMapping.isSelected());
809 * Save Output settings
811 Cache.applicationProperties.setProperty("EPS_RENDERING",
812 ((OptionsParam) epsRendering.getSelectedItem()).getCode());
813 Cache.applicationProperties.setProperty("HTML_RENDERING",
814 ((OptionsParam) htmlRendering.getSelectedItem()).getCode());
815 Cache.applicationProperties.setProperty("SVG_RENDERING",
816 ((OptionsParam) svgRendering.getSelectedItem()).getCode());
819 * Save Connections settings
821 Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
823 jalview.util.BrowserLauncher.resetBrowser();
825 // save user-defined and selected links
826 String menuLinks = sequenceUrlLinks.writeUrlsAsString(true);
827 if (menuLinks.isEmpty())
829 Cache.applicationProperties.remove("SEQUENCE_LINKS");
833 Cache.applicationProperties.setProperty("SEQUENCE_LINKS",
834 menuLinks.toString());
837 String nonMenuLinks = sequenceUrlLinks.writeUrlsAsString(false);
838 if (nonMenuLinks.isEmpty())
840 Cache.applicationProperties.remove("STORED_LINKS");
844 Cache.applicationProperties.setProperty("STORED_LINKS",
845 nonMenuLinks.toString());
848 Cache.applicationProperties.setProperty("DEFAULT_URL",
849 sequenceUrlLinks.getPrimaryUrlId());
854 Cache.setProperty("VERSION_CHECK",
855 Boolean.toString(versioncheck.isSelected()));
856 if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
858 // default is false - we only set this if the user has actively agreed
859 Cache.setProperty("USAGESTATS",
860 Boolean.toString(usagestats.isSelected()));
862 if (!questionnaire.isSelected())
864 Cache.setProperty("NOQUESTIONNAIRES", "true");
868 // special - made easy to edit a property file to disable questionnaires
869 // by just adding the given line
870 Cache.removeProperty("NOQUESTIONNAIRES");
874 * Save Output settings
876 Cache.applicationProperties.setProperty("BLC_JVSUFFIX",
877 Boolean.toString(blcjv.isSelected()));
878 Cache.applicationProperties.setProperty("CLUSTAL_JVSUFFIX",
879 Boolean.toString(clustaljv.isSelected()));
880 Cache.applicationProperties.setProperty("FASTA_JVSUFFIX",
881 Boolean.toString(fastajv.isSelected()));
882 Cache.applicationProperties.setProperty("MSF_JVSUFFIX",
883 Boolean.toString(msfjv.isSelected()));
884 Cache.applicationProperties.setProperty("PFAM_JVSUFFIX",
885 Boolean.toString(pfamjv.isSelected()));
886 Cache.applicationProperties.setProperty("PILEUP_JVSUFFIX",
887 Boolean.toString(pileupjv.isSelected()));
888 Cache.applicationProperties.setProperty("PIR_JVSUFFIX",
889 Boolean.toString(pirjv.isSelected()));
890 Cache.applicationProperties.setProperty("PIR_MODELLER",
891 Boolean.toString(modellerOutput.isSelected()));
892 Cache.applicationProperties.setProperty("EXPORT_EMBBED_BIOJSON",
893 Boolean.toString(embbedBioJSON.isSelected()));
894 jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
896 Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH",
897 Boolean.toString(autoIdWidth.isSelected()));
898 userIdWidth_actionPerformed();
899 Cache.applicationProperties.setProperty("FIGURE_FIXEDIDWIDTH",
900 userIdWidth.getText());
903 * Save Editing settings
905 Cache.applicationProperties.setProperty("AUTO_CALC_CONSENSUS",
906 Boolean.toString(autoCalculateConsCheck.isSelected()));
907 Cache.applicationProperties.setProperty("SORT_BY_TREE",
908 Boolean.toString(sortByTree.isSelected()));
909 Cache.applicationProperties.setProperty("PAD_GAPS",
910 Boolean.toString(padGaps.isSelected()));
912 if (!Platform.isJS())
914 wsPrefs.updateAndRefreshWsMenuConfig(false);
918 * Save Backups settings
920 Cache.applicationProperties.setProperty(BackupFiles.ENABLED,
921 Boolean.toString(enableBackupFiles.isSelected()));
922 int preset = getComboIntStringKey(backupfilesPresetsCombo);
923 Cache.applicationProperties.setProperty(BackupFiles.NS + "_PRESET", Integer.toString(preset));
925 if (preset == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
927 BackupFilesPresetEntry customBFPE = getBackupfilesCurrentEntry();
928 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
929 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM, customBFPE);
930 Cache.applicationProperties
931 .setProperty(BackupFilesPresetEntry.CUSTOMCONFIG,
932 customBFPE.toString());
935 BackupFilesPresetEntry savedBFPE = BackupFilesPresetEntry.backupfilesPresetEntriesValues
937 Cache.applicationProperties.setProperty(
938 BackupFilesPresetEntry.SAVEDCONFIG, savedBFPE.toString());
940 Cache.saveProperties();
941 Desktop.instance.doConfigureStructurePrefs();
944 frame.setClosed(true);
945 } catch (Exception ex)
950 public void saveProxySettings()
952 Cache.applicationProperties.setProperty("USE_PROXY",
953 customProxy.isSelected() ? Cache.PROXYTYPE_CUSTOM
954 : noProxy.isSelected() ? Cache.PROXYTYPE_NONE
955 : Cache.PROXYTYPE_SYSTEM);
956 Cache.setOrRemove("PROXY_SERVER", proxyServerHttpTB.getText());
957 Cache.setOrRemove("PROXY_PORT", proxyPortHttpTB.getText());
958 Cache.setOrRemove("PROXY_SERVER_HTTPS", proxyServerHttpsTB.getText());
959 Cache.setOrRemove("PROXY_PORT_HTTPS", proxyPortHttpsTB.getText());
960 Cache.setOrRemove("PROXY_AUTH",
961 Boolean.toString(proxyAuth.isSelected()));
962 Cache.setOrRemove("PROXY_AUTH_USERNAME", proxyAuthUsernameTB.getText());
963 Cache.proxyAuthPassword = proxyAuthPasswordTB.getPassword();
964 Cache.setProxyPropertiesFromPreferences(previousProxyType);
968 * Do any necessary validation before saving settings. Return focus to the
969 * first tab which fails validation.
973 private boolean validateSettings()
975 if (!validateStructure())
977 structureTab.requestFocusInWindow();
984 protected boolean validateStructure()
986 return validateViewerPath();
994 public void startupFileTextfield_mouseClicked()
996 // TODO: JAL-3048 not needed for Jalview-JS
997 String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
998 JalviewFileChooser chooser = JalviewFileChooser
999 .forRead(Cache.getProperty("LAST_DIRECTORY"), fileFormat);
1000 chooser.setFileView(new JalviewFileView());
1001 chooser.setDialogTitle(
1002 MessageManager.getString("label.select_startup_file"));
1004 int value = chooser.showOpenDialog(this);
1006 if (value == JalviewFileChooser.APPROVE_OPTION)
1008 FileFormatI format = chooser.getSelectedFormat();
1011 Cache.applicationProperties.setProperty("DEFAULT_FILE_FORMAT",
1014 startupFileTextfield
1015 .setText(chooser.getSelectedFile().getAbsolutePath());
1026 public void cancel_actionPerformed(ActionEvent e)
1030 if (!Platform.isJS())
1032 wsPrefs.updateWsMenuConfig(true);
1033 wsPrefs.refreshWs_actionPerformed(e);
1035 frame.setClosed(true);
1036 } catch (Exception ex)
1048 public void annotations_actionPerformed(ActionEvent e)
1050 conservation.setEnabled(annotations.isSelected());
1051 quality.setEnabled(annotations.isSelected());
1052 identity.setEnabled(annotations.isSelected());
1053 showOccupancy.setEnabled(annotations.isSelected());
1054 showGroupConsensus.setEnabled(annotations.isSelected());
1055 showGroupConservation.setEnabled(annotations.isSelected());
1056 showConsensHistogram.setEnabled(annotations.isSelected()
1057 && (identity.isSelected() || showGroupConsensus.isSelected()));
1058 showConsensLogo.setEnabled(annotations.isSelected()
1059 && (identity.isSelected() || showGroupConsensus.isSelected()));
1063 public void newLink_actionPerformed(ActionEvent e)
1065 GSequenceLink link = new GSequenceLink();
1066 boolean valid = false;
1069 if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
1070 MessageManager.getString("label.new_sequence_url_link"),
1071 JvOptionPane.OK_CANCEL_OPTION, -1,
1072 null) == JvOptionPane.OK_OPTION)
1074 if (link.checkValid())
1076 if (((UrlLinkTableModel) linkUrlTable.getModel())
1077 .isUniqueName(link.getName()))
1079 ((UrlLinkTableModel) linkUrlTable.getModel())
1080 .insertRow(link.getName(), link.getURL());
1085 link.notifyDuplicate();
1098 public void editLink_actionPerformed(ActionEvent e)
1100 GSequenceLink link = new GSequenceLink();
1102 int index = linkUrlTable.getSelectedRow();
1105 // button no longer enabled if row is not selected
1106 Cache.log.debug("Edit with no row selected in linkUrlTable");
1110 int nameCol = ((UrlLinkTableModel) linkUrlTable.getModel())
1112 int urlCol = ((UrlLinkTableModel) linkUrlTable.getModel())
1114 String oldName = linkUrlTable.getValueAt(index, nameCol).toString();
1115 link.setName(oldName);
1116 link.setURL(linkUrlTable.getValueAt(index, urlCol).toString());
1118 boolean valid = false;
1121 if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
1122 MessageManager.getString("label.edit_sequence_url_link"),
1123 JvOptionPane.OK_CANCEL_OPTION, -1,
1124 null) == JvOptionPane.OK_OPTION)
1126 if (link.checkValid())
1128 if ((oldName.equals(link.getName()))
1129 || (((UrlLinkTableModel) linkUrlTable.getModel())
1130 .isUniqueName(link.getName())))
1132 linkUrlTable.setValueAt(link.getName(), index, nameCol);
1133 linkUrlTable.setValueAt(link.getURL(), index, urlCol);
1138 link.notifyDuplicate();
1151 public void deleteLink_actionPerformed(ActionEvent e)
1153 int index = linkUrlTable.getSelectedRow();
1154 int modelIndex = -1;
1157 // button no longer enabled if row is not selected
1158 Cache.log.debug("Delete with no row selected in linkUrlTable");
1163 modelIndex = linkUrlTable.convertRowIndexToModel(index);
1166 // make sure we use the model index to delete, and not the table index
1167 ((UrlLinkTableModel) linkUrlTable.getModel()).removeRow(modelIndex);
1171 public void defaultBrowser_mouseClicked(MouseEvent e)
1173 // TODO: JAL-3048 not needed for j2s
1174 if (!Platform.isJS()) // BH 2019
1181 JFileChooser chooser = new JFileChooser(".");
1182 chooser.setDialogTitle(
1183 MessageManager.getString("label.select_default_browser"));
1185 int value = chooser.showOpenDialog(this);
1187 if (value == JFileChooser.APPROVE_OPTION)
1189 defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath());
1198 * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event
1202 protected void showunconserved_actionPerformed(ActionEvent e)
1204 // TODO Auto-generated method stub
1205 super.showunconserved_actionPerformed(e);
1208 public static List<String> getGroupURLLinks()
1210 return groupURLLinks;
1214 public void minColour_actionPerformed(JPanel panel)
1216 JalviewColourChooser.showColourChooser(this,
1217 MessageManager.getString("label.select_colour_minimum_value"),
1222 public void maxColour_actionPerformed(JPanel panel)
1224 JalviewColourChooser.showColourChooser(this,
1225 MessageManager.getString("label.select_colour_maximum_value"),
1230 public void gapColour_actionPerformed(JPanel gap)
1232 if (!useLegacyGap.isSelected())
1234 JalviewColourChooser.showColourChooser(this,
1235 MessageManager.getString("label.select_gap_colour"),
1241 public void hiddenColour_actionPerformed(JPanel hidden)
1243 JalviewColourChooser.showColourChooser(this,
1244 MessageManager.getString("label.select_hidden_colour"),
1249 protected void useLegacyGaps_actionPerformed(ActionEvent e)
1251 boolean enabled = useLegacyGap.isSelected();
1254 gapColour.setBackground(
1255 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_LEGACY_GAP);
1259 gapColour.setBackground(
1260 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP);
1262 gapColour.setEnabled(!enabled);
1263 gapLabel.setEnabled(!enabled);
1267 protected void resetOvDefaults_actionPerformed(ActionEvent e)
1269 useLegacyGap.setSelected(false);
1270 useLegacyGaps_actionPerformed(null);
1271 showHiddenAtStart.setSelected(false);
1272 hiddenColour.setBackground(
1273 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_HIDDEN);
1277 protected void userIdWidth_actionPerformed()
1281 String val = userIdWidth.getText().trim();
1282 if (val.length() > 0)
1284 Integer iw = Integer.parseInt(val);
1285 if (iw.intValue() < 12)
1287 throw new NumberFormatException();
1289 userIdWidth.setText(iw.toString());
1291 } catch (NumberFormatException x)
1293 userIdWidth.setText("");
1294 JvOptionPane.showInternalMessageDialog(Desktop.desktop,
1296 .getString("warn.user_defined_width_requirements"),
1297 MessageManager.getString("label.invalid_id_column_width"),
1298 JvOptionPane.WARNING_MESSAGE);
1303 protected void autoIdWidth_actionPerformed()
1305 userIdWidth.setEnabled(!autoIdWidth.isSelected());
1306 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
1310 * Returns true if structure viewer path is to a valid executable, else shows
1311 * an error dialog. Does nothing if the path is empty, as is the case for Jmol
1312 * (built in to Jalview) or when Jalview is left to try default paths.
1314 private boolean validateViewerPath()
1316 if (structureViewerPath.getText().trim().length() > 0)
1318 File f = new File(structureViewerPath.getText());
1319 if (!f.canExecute())
1321 JvOptionPane.showInternalMessageDialog(Desktop.desktop,
1322 MessageManager.getString("label.invalid_viewer_path"),
1323 MessageManager.getString("label.invalid_viewer_path"),
1324 JvOptionPane.ERROR_MESSAGE);
1332 * If Chimera or ChimeraX or Pymol is selected, check it can be found on
1333 * default or user-specified path, if not show a warning/help dialog
1336 protected void structureViewer_actionPerformed(String selectedItem)
1338 if (selectedItem.equals(ViewerType.JMOL.name()))
1340 structureViewerPath.setEnabled(false);
1341 structureViewerPathLabel.setEnabled(false);
1344 boolean found = false;
1345 structureViewerPath.setEnabled(true);
1346 structureViewerPathLabel.setEnabled(true);
1347 structureViewerPathLabel.setText(MessageManager
1348 .formatMessage("label.viewer_path", selectedItem));
1351 * Try user-specified and standard paths for structure viewer executable
1353 String viewerPath = "";
1354 List<String> paths = null;
1357 ViewerType viewerType = ViewerType.valueOf(selectedItem);
1364 viewerPath = Cache.getDefault(CHIMERA_PATH, "");
1365 paths = StructureManager.getChimeraPaths(false);
1368 viewerPath = Cache.getDefault(CHIMERAX_PATH, "");
1369 paths = StructureManager.getChimeraPaths(true);
1372 viewerPath = Cache.getDefault(PYMOL_PATH, "");
1373 paths = PymolManager.getPymolPaths();
1376 } catch (IllegalArgumentException e)
1378 // only valid entries should be in the drop-down
1380 structureViewerPath.setText(viewerPath);
1382 paths.add(0, structureViewerPath.getText());
1383 for (String path : paths)
1385 if (new File(path.trim()).canExecute())
1394 String[] options = { "OK", "Help" };
1395 int showHelp = JvOptionPane.showInternalOptionDialog(Desktop.desktop,
1396 JvSwingUtils.wrapTooltip(true,
1397 MessageManager.getString("label.viewer_missing")),
1398 "", JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE,
1399 null, options, options[0]);
1400 if (showHelp == JvOptionPane.NO_OPTION)
1404 Help.showHelpWindow(HelpId.StructureViewer);
1405 } catch (HelpSetException e)
1407 e.printStackTrace();
1413 public class OptionsParam
1415 private String name;
1417 private String code;
1419 public OptionsParam(String name, String code)
1425 public String getName()
1430 public void setName(String name)
1435 public String getCode()
1440 public void setCode(String code)
1446 public String toString()
1452 public boolean equals(Object that)
1454 if (!(that instanceof OptionsParam))
1458 return this.code.equalsIgnoreCase(((OptionsParam) that).code);
1462 public int hashCode()
1464 return name.hashCode() + code.hashCode();
1468 private class UrlListSelectionHandler implements ListSelectionListener
1472 public void valueChanged(ListSelectionEvent e)
1474 ListSelectionModel lsm = (ListSelectionModel) e.getSource();
1476 int index = lsm.getMinSelectionIndex();
1479 // no selection, so disable delete/edit buttons
1480 editLink.setEnabled(false);
1481 deleteLink.setEnabled(false);
1484 int modelIndex = linkUrlTable.convertRowIndexToModel(index);
1486 // enable/disable edit and delete link buttons
1487 if (((UrlLinkTableModel) linkUrlTable.getModel())
1488 .isRowDeletable(modelIndex))
1490 deleteLink.setEnabled(true);
1494 deleteLink.setEnabled(false);
1497 if (((UrlLinkTableModel) linkUrlTable.getModel())
1498 .isRowEditable(modelIndex))
1500 editLink.setEnabled(true);
1504 editLink.setEnabled(false);