2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
24 import jalview.bin.Cache;
25 import jalview.gui.Help.HelpId;
26 import jalview.gui.StructureViewer.ViewerType;
27 import jalview.hmmer.HmmerCommand;
28 import jalview.io.BackupFiles;
29 import jalview.io.BackupFilesPresetEntry;
30 import jalview.io.FileFormatI;
31 import jalview.io.JalviewFileChooser;
32 import jalview.io.JalviewFileView;
33 import jalview.jbgui.GPreferences;
34 import jalview.jbgui.GSequenceLink;
35 import jalview.schemes.ColourSchemeI;
36 import jalview.schemes.ColourSchemes;
37 import jalview.schemes.ResidueColourScheme;
38 import jalview.urls.UrlLinkTableModel;
39 import jalview.urls.api.UrlProviderFactoryI;
40 import jalview.urls.api.UrlProviderI;
41 import jalview.urls.desktop.DesktopUrlProviderFactory;
42 import jalview.util.FileUtils;
43 import jalview.util.MessageManager;
44 import jalview.util.Platform;
45 import jalview.util.UrlConstants;
46 import jalview.ws.sifts.SiftsSettings;
48 import java.awt.BorderLayout;
49 import java.awt.Color;
50 import java.awt.Component;
51 import java.awt.Dimension;
53 import java.awt.event.ActionEvent;
54 import java.awt.event.ActionListener;
55 import java.awt.event.FocusAdapter;
56 import java.awt.event.FocusEvent;
57 import java.awt.event.MouseEvent;
59 import java.util.ArrayList;
60 import java.util.List;
62 import javax.help.HelpSetException;
63 import javax.swing.JColorChooser;
64 import javax.swing.JFileChooser;
65 import javax.swing.JInternalFrame;
66 import javax.swing.JPanel;
67 import javax.swing.JTextField;
68 import javax.swing.ListSelectionModel;
69 import javax.swing.RowFilter;
70 import javax.swing.RowSorter;
71 import javax.swing.SortOrder;
72 import javax.swing.event.DocumentEvent;
73 import javax.swing.event.DocumentListener;
74 import javax.swing.event.ListSelectionEvent;
75 import javax.swing.event.ListSelectionListener;
76 import javax.swing.table.TableCellRenderer;
77 import javax.swing.table.TableColumn;
78 import javax.swing.table.TableModel;
79 import javax.swing.table.TableRowSorter;
81 import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
89 public class Preferences extends GPreferences
91 // suggested list delimiter character
92 public static final String COMMA = ",";
94 public static final String HMMSEARCH_SEQCOUNT = "HMMSEARCH_SEQCOUNT";
96 public static final String HMMINFO_GLOBAL_BACKGROUND = "HMMINFO_GLOBAL_BACKGROUND";
98 public static final String HMMALIGN_TRIM_TERMINI = "HMMALIGN_TRIM_TERMINI";
100 public static final String ENABLE_SPLIT_FRAME = "ENABLE_SPLIT_FRAME";
102 public static final String SCALE_PROTEIN_TO_CDNA = "SCALE_PROTEIN_TO_CDNA";
104 public static final String DEFAULT_COLOUR = "DEFAULT_COLOUR";
106 public static final String DEFAULT_COLOUR_PROT = "DEFAULT_COLOUR_PROT";
108 public static final String DEFAULT_COLOUR_NUC = "DEFAULT_COLOUR_NUC";
110 public static final String ADD_TEMPFACT_ANN = "ADD_TEMPFACT_ANN";
112 public static final String ADD_SS_ANN = "ADD_SS_ANN";
114 public static final String USE_RNAVIEW = "USE_RNAVIEW";
116 public static final String STRUCT_FROM_PDB = "STRUCT_FROM_PDB";
118 public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY";
120 public static final String CHIMERA_PATH = "CHIMERA_PATH";
122 public static final String HMMER_PATH = "HMMER_PATH";
124 public static final String CYGWIN_PATH = "CYGWIN_PATH";
126 public static final String HMMSEARCH_DBS = "HMMSEARCH_DBS";
128 public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS";
130 public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE";
132 public static final String SHOW_OCCUPANCY = "SHOW_OCCUPANCY";
134 public static final String SHOW_OV_HIDDEN_AT_START = "SHOW_OV_HIDDEN_AT_START";
136 public static final String USE_LEGACY_GAP = "USE_LEGACY_GAP";
138 public static final String GAP_COLOUR = "GAP_COLOUR";
140 public static final String HIDDEN_COLOUR = "HIDDEN_COLOUR";
142 private static final int MIN_FONT_SIZE = 1;
144 private static final int MAX_FONT_SIZE = 30;
147 * Holds name and link separated with | character. Sequence ID must be
148 * $SEQUENCE_ID$ or $SEQUENCE_ID=/.possible | chars ./=$
150 public static UrlProviderI sequenceUrlLinks;
152 public static UrlLinkTableModel dataModel;
155 * Holds name and link separated with | character. Sequence IDS and Sequences
156 * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and
157 * $SEQUENCES$ or $SEQUENCES=/.possible | chars ./=$ and separation character
158 * for first and second token specified after a pipe character at end |,|.
159 * (TODO: proper escape for using | to separate ids or sequences
162 public static List<String> groupURLLinks;
165 // get links selected to be in the menu (SEQUENCE_LINKS)
166 // and links entered by the user but not selected (STORED_LINKS)
167 String inMenuString = Cache.getDefault("SEQUENCE_LINKS", "");
168 String notInMenuString = Cache.getDefault("STORED_LINKS", "");
169 String defaultUrl = Cache.getDefault("DEFAULT_URL",
170 UrlConstants.DEFAULT_LABEL);
172 // if both links lists are empty, add the DEFAULT_URL link
173 // otherwise we assume the default link is in one of the lists
174 if (inMenuString.isEmpty() && notInMenuString.isEmpty())
176 inMenuString = UrlConstants.DEFAULT_STRING;
178 UrlProviderFactoryI factory = new DesktopUrlProviderFactory(defaultUrl,
179 inMenuString, notInMenuString);
180 sequenceUrlLinks = factory.createUrlProvider();
181 dataModel = new UrlLinkTableModel(sequenceUrlLinks);
184 * TODO: reformulate groupURL encoding so two or more can be stored in the
185 * .properties file as '|' separated strings
188 groupURLLinks = new ArrayList<>();
191 JInternalFrame frame;
193 private WsPreferences wsPrefs;
195 private SlivkaPreferences slivkaPrefs;
197 private OptionsParam promptEachTimeOpt = new OptionsParam(
198 MessageManager.getString("label.prompt_each_time"),
201 private OptionsParam lineArtOpt = new OptionsParam(
202 MessageManager.getString("label.lineart"), "Lineart");
204 private OptionsParam textOpt = new OptionsParam(
205 MessageManager.getString("action.text"), "Text");
208 * Creates a new Preferences object.
213 frame = new JInternalFrame();
214 frame.setContentPane(this);
215 wsPrefs = new WsPreferences();
216 wsTab.add(wsPrefs, BorderLayout.CENTER);
217 slivkaTab.add(slivkaPrefs = new SlivkaPreferences(),
218 BorderLayout.CENTER);
219 int width = 500, height = 450;
220 new jalview.util.Platform();
221 if (Platform.isAMac())
227 Desktop.addInternalFrame(frame,
228 MessageManager.getString("label.preferences"), width, height);
229 frame.setMinimumSize(new Dimension(width, height));
232 * Set HMMER tab defaults
234 hmmrTrimTermini.setSelected(Cache.getDefault(HMMALIGN_TRIM_TERMINI, false));
235 if (Cache.getDefault(HMMINFO_GLOBAL_BACKGROUND, false))
237 hmmerBackgroundUniprot.setSelected(true);
241 hmmerBackgroundAlignment.setSelected(true);
244 .setText(Cache.getProperty(HMMSEARCH_SEQCOUNT));
245 hmmerPath.setText(Cache.getProperty(HMMER_PATH));
246 hmmerPath.addActionListener(new ActionListener()
249 public void actionPerformed(ActionEvent e)
254 hmmerPath.addFocusListener(new FocusAdapter()
257 public void focusLost(FocusEvent e)
262 if (cygwinPath != null)
264 String path = Cache.getProperty(CYGWIN_PATH);
267 path = FileUtils.getPathTo("bash");
269 cygwinPath.setText(path);
270 cygwinPath.addActionListener(new ActionListener()
273 public void actionPerformed(ActionEvent e)
275 validateCygwinPath();
278 cygwinPath.addFocusListener(new FocusAdapter()
281 public void focusLost(FocusEvent e)
283 validateCygwinPath();
289 * Set Visual tab defaults
291 seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true));
292 rightAlign.setSelected(Cache.getDefault("RIGHT_ALIGN_IDS", false));
293 fullScreen.setSelected(Cache.getDefault("SHOW_FULLSCREEN", false));
294 annotations.setSelected(Cache.getDefault("SHOW_ANNOTATIONS", true));
296 conservation.setSelected(Cache.getDefault("SHOW_CONSERVATION", true));
297 quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));
298 identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
299 openoverv.setSelected(Cache.getDefault("SHOW_OVERVIEW", false));
301 .setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
302 showOccupancy.setSelected(Cache.getDefault(SHOW_OCCUPANCY, false));
304 .setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS", false));
305 showGroupConservation.setSelected(
306 Cache.getDefault("SHOW_GROUP_CONSERVATION", false));
307 showConsensHistogram.setSelected(
308 Cache.getDefault("SHOW_CONSENSUS_HISTOGRAM", true));
310 .setSelected(Cache.getDefault("SHOW_CONSENSUS_LOGO", false));
311 showInformationHistogram.setSelected(
312 Cache.getDefault("SHOW_INFORMATION_HISTOGRAM", true));
313 showHMMLogo.setSelected(Cache.getDefault("SHOW_HMM_LOGO", false));
315 .setSelected(Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true));
317 .setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP", true));
319 String[] fonts = java.awt.GraphicsEnvironment
320 .getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
321 for (int i = 0; i < fonts.length; i++)
323 fontNameCB.addItem(fonts[i]);
326 for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++)
328 fontSizeCB.addItem(i + "");
331 fontStyleCB.addItem("plain");
332 fontStyleCB.addItem("bold");
333 fontStyleCB.addItem("italic");
335 fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif"));
336 fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10"));
337 fontStyleCB.setSelectedItem(
338 Cache.getDefault("FONT_STYLE", Font.PLAIN + ""));
340 smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", false));
342 .setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA, false));
344 idItalics.setSelected(Cache.getDefault("ID_ITALICS", true));
346 wrap.setSelected(Cache.getDefault("WRAP_ALIGNMENT", false));
348 gapSymbolCB.addItem("-");
349 gapSymbolCB.addItem(".");
351 gapSymbolCB.setSelectedItem(Cache.getDefault("GAP_SYMBOL", "-"));
353 sortby.addItem("No sort");
354 sortby.addItem("Id");
355 sortby.addItem("Pairwise Identity");
356 sortby.setSelectedItem(Cache.getDefault("SORT_ALIGNMENT", "No sort"));
358 sortAnnBy.addItem(SequenceAnnotationOrder.NONE.toString());
360 .addItem(SequenceAnnotationOrder.SEQUENCE_AND_LABEL.toString());
362 .addItem(SequenceAnnotationOrder.LABEL_AND_SEQUENCE.toString());
363 SequenceAnnotationOrder savedSort = SequenceAnnotationOrder
364 .valueOf(Cache.getDefault(SORT_ANNOTATIONS,
365 SequenceAnnotationOrder.NONE.name()));
366 sortAnnBy.setSelectedItem(savedSort.toString());
368 sortAutocalc.addItem("Autocalculated first");
369 sortAutocalc.addItem("Autocalculated last");
370 final boolean showAbove = Cache.getDefault(SHOW_AUTOCALC_ABOVE, true);
371 sortAutocalc.setSelectedItem(showAbove ? sortAutocalc.getItemAt(0)
372 : sortAutocalc.getItemAt(1));
374 .setSelected(Cache.getDefault("SHOW_STARTUP_FILE", true));
375 startupFileTextfield.setText(Cache.getDefault("STARTUP_FILE",
376 Cache.getDefault("www.jalview.org", "http://www.jalview.org")
377 + "/examples/exampleFile_2_3.jar"));
380 * Set Colours tab defaults
382 protColour.addItem(ResidueColourScheme.NONE);
383 nucColour.addItem(ResidueColourScheme.NONE);
384 for (ColourSchemeI cs : ColourSchemes.getInstance().getColourSchemes())
386 String name = cs.getSchemeName();
387 protColour.addItem(name);
388 nucColour.addItem(name);
390 String oldProp = Cache.getDefault(DEFAULT_COLOUR,
391 ResidueColourScheme.NONE);
392 String newProp = Cache.getDefault(DEFAULT_COLOUR_PROT, null);
393 protColour.setSelectedItem(newProp != null ? newProp : oldProp);
394 newProp = Cache.getDefault(DEFAULT_COLOUR_NUC, null);
395 nucColour.setSelectedItem(newProp != null ? newProp : oldProp);
396 minColour.setBackground(
397 Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN", Color.orange));
398 maxColour.setBackground(
399 Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX", Color.red));
402 * Set overview panel defaults
404 gapColour.setBackground(
405 Cache.getDefaultColour(GAP_COLOUR,
406 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP));
407 hiddenColour.setBackground(
408 Cache.getDefaultColour(HIDDEN_COLOUR,
409 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_HIDDEN));
410 useLegacyGap.setSelected(Cache.getDefault(USE_LEGACY_GAP, false));
411 gapLabel.setEnabled(!useLegacyGap.isSelected());
412 gapColour.setEnabled(!useLegacyGap.isSelected());
414 .setSelected(Cache.getDefault(SHOW_OV_HIDDEN_AT_START, false));
417 * Set Structure tab defaults.
419 final boolean structSelected = Cache.getDefault(STRUCT_FROM_PDB, false);
420 structFromPdb.setSelected(structSelected);
421 useRnaView.setSelected(Cache.getDefault(USE_RNAVIEW, false));
422 useRnaView.setEnabled(structSelected);
423 addSecondaryStructure.setSelected(Cache.getDefault(ADD_SS_ANN, false));
424 addSecondaryStructure.setEnabled(structSelected);
425 addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, false));
426 addTempFactor.setEnabled(structSelected);
427 structViewer.setSelectedItem(
428 Cache.getDefault(STRUCTURE_DISPLAY, ViewerType.JMOL.name()));
429 chimeraPath.setText(Cache.getDefault(CHIMERA_PATH, ""));
430 chimeraPath.addActionListener(new ActionListener()
433 public void actionPerformed(ActionEvent e)
435 validateChimeraPath();
439 if (Cache.getDefault("MAP_WITH_SIFTS", false))
441 siftsMapping.setSelected(true);
445 nwMapping.setSelected(true);
449 .setMapWithSifts(Cache.getDefault("MAP_WITH_SIFTS", false));
452 * Set Connections tab defaults
456 linkUrlTable.setModel(dataModel);
457 final TableRowSorter<TableModel> sorter = new TableRowSorter<>(
458 linkUrlTable.getModel());
459 linkUrlTable.setRowSorter(sorter);
460 List<RowSorter.SortKey> sortKeys = new ArrayList<>();
462 UrlLinkTableModel m = (UrlLinkTableModel) linkUrlTable.getModel();
463 sortKeys.add(new RowSorter.SortKey(m.getPrimaryColumn(),
464 SortOrder.DESCENDING));
465 sortKeys.add(new RowSorter.SortKey(m.getSelectedColumn(),
466 SortOrder.DESCENDING));
468 new RowSorter.SortKey(m.getNameColumn(), SortOrder.ASCENDING));
470 sorter.setSortKeys(sortKeys);
474 ActionListener onReset;
475 onReset = new ActionListener()
478 public void actionPerformed(ActionEvent e)
480 filterTB.setText("");
481 sorter.setRowFilter(RowFilter.regexFilter(""));
485 doReset.addActionListener(onReset);
487 // filter to display only custom urls
488 final RowFilter<TableModel, Object> customUrlFilter = new RowFilter<>()
491 public boolean include(
492 Entry<? extends TableModel, ? extends Object> entry)
494 return ((UrlLinkTableModel) entry.getModel()).isUserEntry(entry);
498 final TableRowSorter<TableModel> customSorter = new TableRowSorter<>(
499 linkUrlTable.getModel());
500 customSorter.setRowFilter(customUrlFilter);
502 ActionListener onCustomOnly;
503 onCustomOnly = new ActionListener()
506 public void actionPerformed(ActionEvent e)
508 filterTB.setText("");
509 sorter.setRowFilter(customUrlFilter);
512 userOnly.addActionListener(onCustomOnly);
514 filterTB.getDocument().addDocumentListener(new DocumentListener()
516 String caseInsensitiveFlag = "(?i)";
519 public void changedUpdate(DocumentEvent e)
521 sorter.setRowFilter(RowFilter
522 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
526 public void removeUpdate(DocumentEvent e)
528 sorter.setRowFilter(RowFilter
529 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
533 public void insertUpdate(DocumentEvent e)
535 sorter.setRowFilter(RowFilter
536 .regexFilter(caseInsensitiveFlag + filterTB.getText()));
540 // set up list selection functionality
541 linkUrlTable.getSelectionModel()
542 .addListSelectionListener(new UrlListSelectionHandler());
544 // set up radio buttons
545 int onClickCol = ((UrlLinkTableModel) linkUrlTable.getModel())
547 String onClickName = linkUrlTable.getColumnName(onClickCol);
548 linkUrlTable.getColumn(onClickName)
549 .setCellRenderer(new RadioButtonRenderer());
550 linkUrlTable.getColumn(onClickName)
551 .setCellEditor(new RadioButtonEditor());
553 // get boolean columns and resize those to min possible
554 for (int column = 0; column < linkUrlTable.getColumnCount(); column++)
556 if (linkUrlTable.getModel().getColumnClass(column)
557 .equals(Boolean.class))
559 TableColumn tableColumn = linkUrlTable.getColumnModel()
561 int preferredWidth = tableColumn.getMinWidth();
563 TableCellRenderer cellRenderer = linkUrlTable.getCellRenderer(0,
565 Component c = linkUrlTable.prepareRenderer(cellRenderer, 0, column);
566 int cwidth = c.getPreferredSize().width
567 + linkUrlTable.getIntercellSpacing().width;
568 preferredWidth = Math.max(preferredWidth, cwidth);
570 tableColumn.setPreferredWidth(preferredWidth);
574 useProxy.setSelected(Cache.getDefault("USE_PROXY", false));
575 useProxy_actionPerformed(); // make sure useProxy is correctly initialised
576 proxyServerTB.setText(Cache.getDefault("PROXY_SERVER", ""));
577 proxyPortTB.setText(Cache.getDefault("PROXY_PORT", ""));
579 defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
581 usagestats.setSelected(Cache.getDefault("USAGESTATS", false));
582 // note antisense here: default is true
584 .setSelected(Cache.getProperty("NOQUESTIONNAIRES") == null);
585 versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true));
588 * Set Output tab defaults
590 epsRendering.addItem(promptEachTimeOpt);
591 epsRendering.addItem(lineArtOpt);
592 epsRendering.addItem(textOpt);
593 String defaultEPS = Cache.getDefault("EPS_RENDERING",
595 if (defaultEPS.equalsIgnoreCase("Text"))
597 epsRendering.setSelectedItem(textOpt);
599 else if (defaultEPS.equalsIgnoreCase("Lineart"))
601 epsRendering.setSelectedItem(lineArtOpt);
605 epsRendering.setSelectedItem(promptEachTimeOpt);
607 autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
608 userIdWidth.setEnabled(!autoIdWidth.isSelected());
609 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
610 Integer wi = Cache.getIntegerProperty("FIGURE_FIXEDIDWIDTH");
611 userIdWidth.setText(wi == null ? "" : wi.toString());
612 // TODO: refactor to use common enum via FormatAdapter and allow extension
613 // for new flat file formats
614 blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
615 clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
616 fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
617 msfjv.setSelected(Cache.getDefault("MSF_JVSUFFIX", true));
618 pfamjv.setSelected(Cache.getDefault("PFAM_JVSUFFIX", true));
619 pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true));
620 pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true));
621 modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false));
623 .setSelected(Cache.getDefault("EXPORT_EMBBED_BIOJSON", true));
626 * Set Editing tab defaults
628 autoCalculateConsCheck
629 .setSelected(Cache.getDefault("AUTO_CALC_CONSENSUS", true));
630 padGaps.setSelected(Cache.getDefault("PAD_GAPS", false));
631 sortByTree.setSelected(Cache.getDefault("SORT_BY_TREE", false));
633 annotations_actionPerformed(null); // update the display of the annotation
638 * Set Backups tab defaults
640 loadLastSavedBackupsOptions();
644 * Save user selections on the Preferences tabs to the Cache and write out to
650 public void ok_actionPerformed(ActionEvent e)
652 if (!validateSettings())
658 * Save Visual settings
660 Cache.applicationProperties.setProperty("SHOW_JVSUFFIX",
661 Boolean.toString(seqLimit.isSelected()));
662 Cache.applicationProperties.setProperty("RIGHT_ALIGN_IDS",
663 Boolean.toString(rightAlign.isSelected()));
664 Cache.applicationProperties.setProperty("SHOW_FULLSCREEN",
665 Boolean.toString(fullScreen.isSelected()));
666 Cache.applicationProperties.setProperty("SHOW_OVERVIEW",
667 Boolean.toString(openoverv.isSelected()));
668 Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
669 Boolean.toString(annotations.isSelected()));
670 Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
671 Boolean.toString(conservation.isSelected()));
672 Cache.applicationProperties.setProperty("SHOW_QUALITY",
673 Boolean.toString(quality.isSelected()));
674 Cache.applicationProperties.setProperty("SHOW_IDENTITY",
675 Boolean.toString(identity.isSelected()));
677 Cache.applicationProperties.setProperty("GAP_SYMBOL",
678 gapSymbolCB.getSelectedItem().toString());
680 Cache.applicationProperties.setProperty("FONT_NAME",
681 fontNameCB.getSelectedItem().toString());
682 Cache.applicationProperties.setProperty("FONT_STYLE",
683 fontStyleCB.getSelectedItem().toString());
684 Cache.applicationProperties.setProperty("FONT_SIZE",
685 fontSizeCB.getSelectedItem().toString());
687 Cache.applicationProperties.setProperty("ID_ITALICS",
688 Boolean.toString(idItalics.isSelected()));
689 Cache.applicationProperties.setProperty("SHOW_UNCONSERVED",
690 Boolean.toString(showUnconserved.isSelected()));
691 Cache.applicationProperties.setProperty(SHOW_OCCUPANCY,
692 Boolean.toString(showOccupancy.isSelected()));
693 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSENSUS",
694 Boolean.toString(showGroupConsensus.isSelected()));
695 Cache.applicationProperties.setProperty("SHOW_GROUP_CONSERVATION",
696 Boolean.toString(showGroupConservation.isSelected()));
697 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_HISTOGRAM",
698 Boolean.toString(showConsensHistogram.isSelected()));
699 Cache.applicationProperties.setProperty("SHOW_CONSENSUS_LOGO",
700 Boolean.toString(showConsensLogo.isSelected()));
701 Cache.applicationProperties.setProperty("SHOW_INFORMATION_HISTOGRAM",
702 Boolean.toString(showConsensHistogram.isSelected()));
703 Cache.applicationProperties.setProperty("SHOW_HMM_LOGO",
704 Boolean.toString(showHMMLogo.isSelected()));
705 Cache.applicationProperties.setProperty("ANTI_ALIAS",
706 Boolean.toString(smoothFont.isSelected()));
707 Cache.applicationProperties.setProperty(SCALE_PROTEIN_TO_CDNA,
708 Boolean.toString(scaleProteinToCdna.isSelected()));
709 Cache.applicationProperties.setProperty("SHOW_NPFEATS_TOOLTIP",
710 Boolean.toString(showNpTooltip.isSelected()));
711 Cache.applicationProperties.setProperty("SHOW_DBREFS_TOOLTIP",
712 Boolean.toString(showDbRefTooltip.isSelected()));
714 Cache.applicationProperties.setProperty("WRAP_ALIGNMENT",
715 Boolean.toString(wrap.isSelected()));
717 Cache.applicationProperties.setProperty("STARTUP_FILE",
718 startupFileTextfield.getText());
719 Cache.applicationProperties.setProperty("SHOW_STARTUP_FILE",
720 Boolean.toString(startupCheckbox.isSelected()));
722 Cache.applicationProperties.setProperty("SORT_ALIGNMENT",
723 sortby.getSelectedItem().toString());
725 // convert description of sort order to enum name for save
726 SequenceAnnotationOrder annSortOrder = SequenceAnnotationOrder
727 .forDescription(sortAnnBy.getSelectedItem().toString());
728 if (annSortOrder != null)
730 Cache.applicationProperties.setProperty(SORT_ANNOTATIONS,
731 annSortOrder.name());
734 final boolean showAutocalcFirst = sortAutocalc.getSelectedIndex() == 0;
735 Cache.applicationProperties.setProperty(SHOW_AUTOCALC_ABOVE,
736 Boolean.valueOf(showAutocalcFirst).toString());
739 * Save Colours settings
741 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_PROT,
742 protColour.getSelectedItem().toString());
743 Cache.applicationProperties.setProperty(DEFAULT_COLOUR_NUC,
744 nucColour.getSelectedItem().toString());
745 Cache.setColourProperty("ANNOTATIONCOLOUR_MIN",
746 minColour.getBackground());
747 Cache.setColourProperty("ANNOTATIONCOLOUR_MAX",
748 maxColour.getBackground());
751 * Save HMMER settings
753 Cache.applicationProperties.setProperty(HMMALIGN_TRIM_TERMINI,
754 Boolean.toString(hmmrTrimTermini.isSelected()));
755 Cache.applicationProperties.setProperty(HMMINFO_GLOBAL_BACKGROUND,
756 Boolean.toString(hmmerBackgroundUniprot.isSelected()));
757 Cache.applicationProperties.setProperty(HMMSEARCH_SEQCOUNT,
758 hmmerSequenceCount.getText());
759 Cache.setOrRemove(HMMER_PATH, hmmerPath.getText());
760 if (cygwinPath != null)
762 Cache.setOrRemove(CYGWIN_PATH, cygwinPath.getText());
764 AlignFrame[] frames = Desktop.getAlignFrames();
765 if (frames != null && frames.length > 0)
767 for (AlignFrame f : frames)
769 f.updateHMMERStatus();
773 hmmrTrimTermini.setSelected(Cache.getDefault(HMMALIGN_TRIM_TERMINI, false));
774 if (Cache.getDefault(HMMINFO_GLOBAL_BACKGROUND, false))
776 hmmerBackgroundUniprot.setSelected(true);
780 hmmerBackgroundAlignment.setSelected(true);
783 .setText(Cache.getProperty(HMMSEARCH_SEQCOUNT));
784 hmmerPath.setText(Cache.getProperty(HMMER_PATH));
787 * Save Overview settings
789 Cache.setColourProperty(GAP_COLOUR, gapColour.getBackground());
790 Cache.setColourProperty(HIDDEN_COLOUR, hiddenColour.getBackground());
791 Cache.applicationProperties.setProperty(USE_LEGACY_GAP,
792 Boolean.toString(useLegacyGap.isSelected()));
793 Cache.applicationProperties.setProperty(SHOW_OV_HIDDEN_AT_START,
794 Boolean.toString(showHiddenAtStart.isSelected()));
797 * Save Structure settings
799 Cache.applicationProperties.setProperty(ADD_TEMPFACT_ANN,
800 Boolean.toString(addTempFactor.isSelected()));
801 Cache.applicationProperties.setProperty(ADD_SS_ANN,
802 Boolean.toString(addSecondaryStructure.isSelected()));
803 Cache.applicationProperties.setProperty(USE_RNAVIEW,
804 Boolean.toString(useRnaView.isSelected()));
805 Cache.applicationProperties.setProperty(STRUCT_FROM_PDB,
806 Boolean.toString(structFromPdb.isSelected()));
807 Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY,
808 structViewer.getSelectedItem().toString());
809 Cache.setOrRemove(CHIMERA_PATH, chimeraPath.getText());
810 Cache.applicationProperties.setProperty("MAP_WITH_SIFTS",
811 Boolean.toString(siftsMapping.isSelected()));
812 SiftsSettings.setMapWithSifts(siftsMapping.isSelected());
815 * Save Output settings
817 Cache.applicationProperties.setProperty("EPS_RENDERING",
818 ((OptionsParam) epsRendering.getSelectedItem()).getCode());
821 * Save Connections settings
823 Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
825 jalview.util.BrowserLauncher.resetBrowser();
827 // save user-defined and selected links
828 String menuLinks = sequenceUrlLinks.writeUrlsAsString(true);
829 if (menuLinks.isEmpty())
831 Cache.applicationProperties.remove("SEQUENCE_LINKS");
835 Cache.applicationProperties.setProperty("SEQUENCE_LINKS",
836 menuLinks.toString());
839 String nonMenuLinks = sequenceUrlLinks.writeUrlsAsString(false);
840 if (nonMenuLinks.isEmpty())
842 Cache.applicationProperties.remove("STORED_LINKS");
846 Cache.applicationProperties.setProperty("STORED_LINKS",
847 nonMenuLinks.toString());
850 Cache.applicationProperties.setProperty("DEFAULT_URL",
851 sequenceUrlLinks.getPrimaryUrlId());
853 Cache.applicationProperties.setProperty("USE_PROXY",
854 Boolean.toString(useProxy.isSelected()));
856 Cache.setOrRemove("PROXY_SERVER", proxyServerTB.getText());
858 Cache.setOrRemove("PROXY_PORT", proxyPortTB.getText());
860 if (useProxy.isSelected())
862 System.setProperty("http.proxyHost", proxyServerTB.getText());
863 System.setProperty("http.proxyPort", proxyPortTB.getText());
867 System.setProperty("http.proxyHost", "");
868 System.setProperty("http.proxyPort", "");
870 Cache.setProperty("VERSION_CHECK",
871 Boolean.toString(versioncheck.isSelected()));
872 if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
874 // default is false - we only set this if the user has actively agreed
875 Cache.setProperty("USAGESTATS",
876 Boolean.toString(usagestats.isSelected()));
878 if (!questionnaire.isSelected())
880 Cache.setProperty("NOQUESTIONNAIRES", "true");
884 // special - made easy to edit a property file to disable questionnaires
885 // by just adding the given line
886 Cache.removeProperty("NOQUESTIONNAIRES");
890 * Save Output settings
892 Cache.applicationProperties.setProperty("BLC_JVSUFFIX",
893 Boolean.toString(blcjv.isSelected()));
894 Cache.applicationProperties.setProperty("CLUSTAL_JVSUFFIX",
895 Boolean.toString(clustaljv.isSelected()));
896 Cache.applicationProperties.setProperty("FASTA_JVSUFFIX",
897 Boolean.toString(fastajv.isSelected()));
898 Cache.applicationProperties.setProperty("MSF_JVSUFFIX",
899 Boolean.toString(msfjv.isSelected()));
900 Cache.applicationProperties.setProperty("PFAM_JVSUFFIX",
901 Boolean.toString(pfamjv.isSelected()));
902 Cache.applicationProperties.setProperty("PILEUP_JVSUFFIX",
903 Boolean.toString(pileupjv.isSelected()));
904 Cache.applicationProperties.setProperty("PIR_JVSUFFIX",
905 Boolean.toString(pirjv.isSelected()));
906 Cache.applicationProperties.setProperty("PIR_MODELLER",
907 Boolean.toString(modellerOutput.isSelected()));
908 Cache.applicationProperties.setProperty("EXPORT_EMBBED_BIOJSON",
909 Boolean.toString(embbedBioJSON.isSelected()));
910 jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
912 Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH",
913 Boolean.toString(autoIdWidth.isSelected()));
914 userIdWidth_actionPerformed();
915 Cache.applicationProperties.setProperty("FIGURE_FIXEDIDWIDTH",
916 userIdWidth.getText());
919 * Save Editing settings
921 Cache.applicationProperties.setProperty("AUTO_CALC_CONSENSUS",
922 Boolean.toString(autoCalculateConsCheck.isSelected()));
923 Cache.applicationProperties.setProperty("SORT_BY_TREE",
924 Boolean.toString(sortByTree.isSelected()));
925 Cache.applicationProperties.setProperty("PAD_GAPS",
926 Boolean.toString(padGaps.isSelected()));
928 wsPrefs.updateAndRefreshWsMenuConfig(false);
931 * Save Backups settings
933 Cache.applicationProperties.setProperty(BackupFiles.ENABLED,
934 Boolean.toString(enableBackupFiles.isSelected()));
935 int preset = getComboIntStringKey(backupfilesPresetsCombo);
936 Cache.applicationProperties.setProperty(BackupFiles.NS + "_PRESET", Integer.toString(preset));
938 if (preset == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
940 BackupFilesPresetEntry customBFPE = getBackupfilesCurrentEntry();
941 BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
942 BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM, customBFPE);
943 Cache.applicationProperties
944 .setProperty(BackupFilesPresetEntry.CUSTOMCONFIG,
945 customBFPE.toString());
948 BackupFilesPresetEntry savedBFPE = BackupFilesPresetEntry.backupfilesPresetEntriesValues
950 Cache.applicationProperties.setProperty(
951 BackupFilesPresetEntry.SAVEDCONFIG, savedBFPE.toString());
953 Cache.saveProperties();
954 Desktop.instance.doConfigureStructurePrefs();
957 frame.setClosed(true);
958 } catch (Exception ex)
964 * Do any necessary validation before saving settings. Return focus to the
965 * first tab which fails validation.
969 private boolean validateSettings()
971 if (!validateStructure())
973 structureTab.requestFocusInWindow();
980 protected boolean validateStructure()
982 return validateChimeraPath();
990 public void startupFileTextfield_mouseClicked()
992 String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
993 JalviewFileChooser chooser = JalviewFileChooser
994 .forRead(Cache.getProperty("LAST_DIRECTORY"), fileFormat);
995 chooser.setFileView(new JalviewFileView());
996 chooser.setDialogTitle(
997 MessageManager.getString("label.select_startup_file"));
999 int value = chooser.showOpenDialog(this);
1001 if (value == JalviewFileChooser.APPROVE_OPTION)
1003 FileFormatI format = chooser.getSelectedFormat();
1006 Cache.applicationProperties.setProperty("DEFAULT_FILE_FORMAT",
1009 startupFileTextfield
1010 .setText(chooser.getSelectedFile().getAbsolutePath());
1021 public void cancel_actionPerformed(ActionEvent e)
1025 wsPrefs.updateWsMenuConfig(true);
1026 wsPrefs.refreshWs_actionPerformed(e);
1027 frame.setClosed(true);
1028 } catch (Exception ex)
1040 public void annotations_actionPerformed(ActionEvent e)
1042 conservation.setEnabled(annotations.isSelected());
1043 quality.setEnabled(annotations.isSelected());
1044 identity.setEnabled(annotations.isSelected());
1045 showOccupancy.setEnabled(annotations.isSelected());
1046 showGroupConsensus.setEnabled(annotations.isSelected());
1047 showGroupConservation.setEnabled(annotations.isSelected());
1048 showConsensHistogram.setEnabled(annotations.isSelected()
1049 && (identity.isSelected() || showGroupConsensus.isSelected()));
1050 showConsensLogo.setEnabled(annotations.isSelected()
1051 && (identity.isSelected() || showGroupConsensus.isSelected()));
1052 showInformationHistogram.setEnabled(annotations.isSelected());
1053 showHMMLogo.setEnabled(annotations.isSelected());
1057 public void newLink_actionPerformed(ActionEvent e)
1059 GSequenceLink link = new GSequenceLink();
1060 boolean valid = false;
1063 if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
1064 MessageManager.getString("label.new_sequence_url_link"),
1065 JvOptionPane.OK_CANCEL_OPTION, -1,
1066 null) == JvOptionPane.OK_OPTION)
1068 if (link.checkValid())
1070 if (((UrlLinkTableModel) linkUrlTable.getModel())
1071 .isUniqueName(link.getName()))
1073 ((UrlLinkTableModel) linkUrlTable.getModel())
1074 .insertRow(link.getName(), link.getURL());
1079 link.notifyDuplicate();
1092 public void editLink_actionPerformed(ActionEvent e)
1094 GSequenceLink link = new GSequenceLink();
1096 int index = linkUrlTable.getSelectedRow();
1099 // button no longer enabled if row is not selected
1100 Cache.log.debug("Edit with no row selected in linkUrlTable");
1104 int nameCol = ((UrlLinkTableModel) linkUrlTable.getModel())
1106 int urlCol = ((UrlLinkTableModel) linkUrlTable.getModel())
1108 String oldName = linkUrlTable.getValueAt(index, nameCol).toString();
1109 link.setName(oldName);
1110 link.setURL(linkUrlTable.getValueAt(index, urlCol).toString());
1112 boolean valid = false;
1115 if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
1116 MessageManager.getString("label.edit_sequence_url_link"),
1117 JvOptionPane.OK_CANCEL_OPTION, -1,
1118 null) == JvOptionPane.OK_OPTION)
1120 if (link.checkValid())
1122 if ((oldName.equals(link.getName()))
1123 || (((UrlLinkTableModel) linkUrlTable.getModel())
1124 .isUniqueName(link.getName())))
1126 linkUrlTable.setValueAt(link.getName(), index, nameCol);
1127 linkUrlTable.setValueAt(link.getURL(), index, urlCol);
1132 link.notifyDuplicate();
1145 public void deleteLink_actionPerformed(ActionEvent e)
1147 int index = linkUrlTable.getSelectedRow();
1148 int modelIndex = -1;
1151 // button no longer enabled if row is not selected
1152 Cache.log.debug("Delete with no row selected in linkUrlTable");
1157 modelIndex = linkUrlTable.convertRowIndexToModel(index);
1160 // make sure we use the model index to delete, and not the table index
1161 ((UrlLinkTableModel) linkUrlTable.getModel()).removeRow(modelIndex);
1165 public void defaultBrowser_mouseClicked(MouseEvent e)
1167 JFileChooser chooser = new JFileChooser(".");
1168 chooser.setDialogTitle(
1169 MessageManager.getString("label.select_default_browser"));
1171 int value = chooser.showOpenDialog(this);
1173 if (value == JFileChooser.APPROVE_OPTION)
1175 defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath());
1184 * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event
1188 protected void showunconserved_actionPerformed(ActionEvent e)
1190 // TODO Auto-generated method stub
1191 super.showunconserved_actionPerformed(e);
1194 public static List<String> getGroupURLLinks()
1196 return groupURLLinks;
1200 public void minColour_actionPerformed(JPanel panel)
1202 Color col = JColorChooser.showDialog(this,
1203 MessageManager.getString("label.select_colour_minimum_value"),
1204 minColour.getBackground());
1207 panel.setBackground(col);
1213 public void maxColour_actionPerformed(JPanel panel)
1215 Color col = JColorChooser.showDialog(this,
1216 MessageManager.getString("label.select_colour_maximum_value"),
1217 maxColour.getBackground());
1220 panel.setBackground(col);
1226 public void gapColour_actionPerformed(JPanel gap)
1228 if (!useLegacyGap.isSelected())
1230 Color col = JColorChooser.showDialog(this,
1231 MessageManager.getString("label.select_gap_colour"),
1232 gapColour.getBackground());
1235 gap.setBackground(col);
1242 public void hiddenColour_actionPerformed(JPanel hidden)
1244 Color col = JColorChooser.showDialog(this,
1245 MessageManager.getString("label.select_hidden_colour"),
1246 hiddenColour.getBackground());
1249 hidden.setBackground(col);
1255 protected void useLegacyGaps_actionPerformed(ActionEvent e)
1257 boolean enabled = useLegacyGap.isSelected();
1260 gapColour.setBackground(
1261 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_LEGACY_GAP);
1265 gapColour.setBackground(
1266 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP);
1268 gapColour.setEnabled(!enabled);
1269 gapLabel.setEnabled(!enabled);
1273 protected void resetOvDefaults_actionPerformed(ActionEvent e)
1275 useLegacyGap.setSelected(false);
1276 useLegacyGaps_actionPerformed(null);
1277 showHiddenAtStart.setSelected(false);
1278 hiddenColour.setBackground(
1279 jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_HIDDEN);
1283 protected void userIdWidth_actionPerformed()
1287 String val = userIdWidth.getText().trim();
1288 if (val.length() > 0)
1290 Integer iw = Integer.parseInt(val);
1291 if (iw.intValue() < 12)
1293 throw new NumberFormatException();
1295 userIdWidth.setText(iw.toString());
1297 } catch (NumberFormatException x)
1299 JvOptionPane.showInternalMessageDialog(Desktop.desktop,
1301 .getString("warn.user_defined_width_requirements"),
1302 MessageManager.getString("label.invalid_id_column_width"),
1303 JvOptionPane.WARNING_MESSAGE);
1304 userIdWidth.setText("");
1309 protected void autoIdWidth_actionPerformed()
1311 userIdWidth.setEnabled(!autoIdWidth.isSelected());
1312 userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
1316 * Returns true if chimera path is to a valid executable, else show an error
1319 private boolean validateChimeraPath()
1321 if (chimeraPath.getText().trim().length() > 0)
1323 File f = new File(chimeraPath.getText());
1324 if (!f.canExecute())
1326 JvOptionPane.showInternalMessageDialog(Desktop.desktop,
1327 MessageManager.getString("label.invalid_chimera_path"),
1328 MessageManager.getString("label.invalid_name"),
1329 JvOptionPane.ERROR_MESSAGE);
1337 * Returns true if the given text field contains a path to a folder that
1338 * contains an executable with the given name, else false (after showing a
1339 * warning dialog). The executable name will be tried with .exe appended if not
1345 protected boolean validateExecutablePath(JTextField textField, String executable)
1347 String folder = textField.getText().trim();
1349 if (FileUtils.getExecutable(executable, folder) != null)
1353 if (folder.length() > 0)
1355 JvOptionPane.showInternalMessageDialog(Desktop.desktop,
1356 MessageManager.formatMessage("label.executable_not_found",
1358 MessageManager.getString("label.invalid_folder"),
1359 JvOptionPane.ERROR_MESSAGE);
1365 * Checks if a file can be executed
1368 * the path to the file
1371 public boolean canExecute(String path)
1373 File file = new File(path);
1374 if (!file.canExecute())
1376 file = new File(path + ".exe");
1378 if (!file.canExecute())
1388 * If Chimera is selected, check it can be found on default or user-specified
1389 * path, if not show a warning/help dialog.
1392 protected void structureViewer_actionPerformed(String selectedItem)
1394 if (!selectedItem.equals(ViewerType.CHIMERA.name()))
1398 boolean found = false;
1401 * Try user-specified and standard paths for Chimera executable.
1403 List<String> paths = StructureManager.getChimeraPaths();
1404 paths.add(0, chimeraPath.getText());
1405 for (String path : paths)
1407 if (new File(path.trim()).canExecute())
1415 String[] options = { "OK", "Help" };
1416 int showHelp = JvOptionPane.showInternalOptionDialog(Desktop.desktop,
1417 JvSwingUtils.wrapTooltip(true,
1418 MessageManager.getString("label.chimera_missing")),
1419 "", JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE,
1420 null, options, options[0]);
1421 if (showHelp == JvOptionPane.NO_OPTION)
1425 Help.showHelpWindow(HelpId.StructureViewer);
1426 } catch (HelpSetException e)
1428 e.printStackTrace();
1435 protected void validateHmmerPath()
1437 validateExecutablePath(hmmerPath, HmmerCommand.HMMBUILD);
1441 protected void validateCygwinPath()
1443 validateExecutablePath(cygwinPath, "run");
1446 public class OptionsParam
1448 private String name;
1450 private String code;
1452 public OptionsParam(String name, String code)
1458 public String getName()
1463 public void setName(String name)
1468 public String getCode()
1473 public void setCode(String code)
1479 public String toString()
1485 public boolean equals(Object that)
1487 if (!(that instanceof OptionsParam))
1491 return this.code.equalsIgnoreCase(((OptionsParam) that).code);
1495 public int hashCode()
1497 return name.hashCode() + code.hashCode();
1501 private class UrlListSelectionHandler implements ListSelectionListener
1505 public void valueChanged(ListSelectionEvent e)
1507 ListSelectionModel lsm = (ListSelectionModel) e.getSource();
1509 int index = lsm.getMinSelectionIndex();
1512 // no selection, so disable delete/edit buttons
1513 editLink.setEnabled(false);
1514 deleteLink.setEnabled(false);
1517 int modelIndex = linkUrlTable.convertRowIndexToModel(index);
1519 // enable/disable edit and delete link buttons
1520 if (((UrlLinkTableModel) linkUrlTable.getModel())
1521 .isRowDeletable(modelIndex))
1523 deleteLink.setEnabled(true);
1527 deleteLink.setEnabled(false);
1530 if (((UrlLinkTableModel) linkUrlTable.getModel())
1531 .isRowEditable(modelIndex))
1533 editLink.setEnabled(true);
1537 editLink.setEnabled(false);