X-Git-Url: https://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Ffunction%2Fgpsies%2FGenericDownloaderFunction.java;h=286ba1aae7bc677cd835e3855ea213d44e206b6d;hb=7f5ed2be62905bd37717376dc22d09e5ea7edb4d;hp=e9049a82b9a89705472601eefb0179c4a599729a;hpb=f1b92378a792131ac8fb33a869405851d5b2d1f7;p=GpsPrune.git diff --git a/tim/prune/function/gpsies/GenericDownloaderFunction.java b/tim/prune/function/gpsies/GenericDownloaderFunction.java index e9049a8..286ba1a 100644 --- a/tim/prune/function/gpsies/GenericDownloaderFunction.java +++ b/tim/prune/function/gpsies/GenericDownloaderFunction.java @@ -18,7 +18,6 @@ import javax.swing.JScrollPane; import javax.swing.JSplitPane; import javax.swing.JTable; import javax.swing.JTextArea; -import javax.swing.ListSelectionModel; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; @@ -41,6 +40,8 @@ public abstract class GenericDownloaderFunction extends GenericFunction implemen protected JTable _trackTable = null; /** Cancelled flag */ protected boolean _cancelled = false; + /** error message */ + protected String _errorMessage = null; /** Status label */ protected JLabel _statusLabel = null; /** Description box */ @@ -85,6 +86,7 @@ public abstract class GenericDownloaderFunction extends GenericFunction implemen _showButton.setEnabled(false); _cancelled = false; _descriptionBox.setText(""); + _errorMessage = null; // Start new thread to load list asynchronously new Thread(this).start(); @@ -112,21 +114,20 @@ public abstract class GenericDownloaderFunction extends GenericFunction implemen public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { - if (_trackTable.getSelectedRow() >= 0 - && _trackTable.getSelectedRow() < _trackListModel.getRowCount()) + final int numSelected = _trackTable.getSelectedRowCount(); + if (numSelected > 0) { - _loadButton.setEnabled(true); - _showButton.setEnabled(true); setDescription(_trackListModel.getTrack(_trackTable.getSelectedRow()).getDescription()); _descriptionBox.setCaretPosition(0); } else { _descriptionBox.setText(""); } + _loadButton.setEnabled(numSelected > 0); + _showButton.setEnabled(numSelected == 1); } } }); - _trackTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // only allow one to be selected _trackTable.getColumnModel().getColumn(0).setPreferredWidth(300); if (_trackListModel.getColumnCount() > 1) { _trackTable.getColumnModel().getColumn(1).setPreferredWidth(70);