]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/function/gpsies/GenericDownloaderFunction.java
Version 15, March 2013
[GpsPrune.git] / tim / prune / function / gpsies / GenericDownloaderFunction.java
index e9049a82b9a89705472601eefb0179c4a599729a..286ba1aae7bc677cd835e3855ea213d44e206b6d 100644 (file)
@@ -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);