diff --git a/base/src/org/compiere/report/core/RModel.java b/base/src/org/compiere/report/core/RModel.java index 0a1b725e49..08269eb043 100644 --- a/base/src/org/compiere/report/core/RModel.java +++ b/base/src/org/compiere/report/core/RModel.java @@ -360,6 +360,16 @@ public class RModel implements Serializable { m_data.moveRow(from,to); } // moveRow + + /** + * Returns the ArrayList of ArrayLists that contains the table's data values. + * The ArrayLists contained in the outer vector are each a single row of values. + * @return the ArrayList of ArrayLists containing the tables data values + * @author Teo Sarca [ 1734327 ] + */ + protected ArrayList> getRows() { + return m_data.rows; + } /*************************************************************************/ diff --git a/base/src/org/compiere/report/core/ResultTable.java b/base/src/org/compiere/report/core/ResultTable.java index 8f7debd6ec..1c45daaac5 100644 --- a/base/src/org/compiere/report/core/ResultTable.java +++ b/base/src/org/compiere/report/core/ResultTable.java @@ -205,8 +205,7 @@ public class ResultTable extends JTable implements MouseListener * Sort Table * @param modelColumnIndex */ - @SuppressWarnings("unchecked") - private void sort (int modelColumnIndex) + private void sort (final int modelColumnIndex) { int rows = getRowCount(); if (rows == 0) @@ -224,37 +223,16 @@ public class ResultTable extends JTable implements MouseListener ResultTableModel model = (ResultTableModel)getModel(); // Prepare sorting - MSort sort = new MSort(0, null); + final MSort sort = new MSort(0, null); sort.setSortAsc(m_asc); - // while something to sort - sorting: - while (true) - { - // Create sortList - ArrayList sortList = new ArrayList(rows); - // fill with data entity - for (int i = 0; i < rows; i++) - { - Object value = model.getValueAt(i, modelColumnIndex); - sortList.add(new MSort(i, value)); + // Sort the data list - teo_sarca [ 1734327 ] + Collections.sort(model.getDataList(), new Comparator() { + public int compare(Object o1, Object o2) { + Object item1 = ((ArrayList)o1).get(modelColumnIndex); + Object item2 = ((ArrayList)o2).get(modelColumnIndex); + return sort.compare(item1, item2); } - // sort list it - Collections.sort(sortList, sort); - // move out of sequence row - for (int i = 0; i < rows; i++) - { - int index = ((MSort)sortList.get(i)).index; - if (i != index) - { - // log.config( "move " + i + " to " + index); - model.moveRow (i, index); - continue sorting; - } - } - // we are done - // log.config( "done"); - break; - } // while something to sort + }); } // sort } // ResultTable diff --git a/base/src/org/compiere/report/core/ResultTableModel.java b/base/src/org/compiere/report/core/ResultTableModel.java index f437ae3cfd..cfeedcb25f 100644 --- a/base/src/org/compiere/report/core/ResultTableModel.java +++ b/base/src/org/compiere/report/core/ResultTableModel.java @@ -16,6 +16,8 @@ *****************************************************************************/ package org.compiere.report.core; +import java.util.ArrayList; + import javax.swing.event.*; import javax.swing.table.*; @@ -121,4 +123,13 @@ class ResultTableModel extends AbstractTableModel m_model.moveRow (from, to); } // moveRow + /** + * Returns the ArrayList of ArrayLists that contains the table's data values. + * The ArrayLists contained in the outer vector are each a single row of values. + * @return the ArrayList of ArrayLists containing the tables data values + * @author Teo Sarca [ 1734327 ] + */ + protected ArrayList> getDataList() { + return m_model.getRows(); + } } // ResultTableModel