@Override public void run(ProgressMonitor pm) { if (model.getRowCount() < 2) { return; } // Retrieve the index if the model have a restricted set of rows if (modelIndex == null) { //Create an array [0 1 ..rows] modelIndex = new IntegerUnion(0, model.getRowCount() - 1); } try(Connection connection = dataSource.getConnection()) { final Collection<Integer> sortedRow = ReadTable.getSortedColumnRowIndex(connection, model.getTableName(), columnSortName, sortRequest.getSortOrder() == SortOrder.ASCENDING, pm); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { try { //Update the table model on the swing thread eventSortedListeners.callListeners(new SortJobEventSorted(sortRequest, sortedRow, this)); } catch (EventException ex) { //Ignore } } }); } catch (IllegalStateException | SQLException ex) { LOGGER.error(I18N.tr("Driver error"), ex); } }