BF [ 1734327 ] Acct Viewer sorting is very very slow
http://sourceforge.net/tracker/index.php?func=detail&aid=1734327&group_id=176962&atid=879332
This commit is contained in:
parent
04105b1080
commit
12309cfd2a
|
@ -360,6 +360,16 @@ public class RModel implements Serializable
|
||||||
{
|
{
|
||||||
m_data.moveRow(from,to);
|
m_data.moveRow(from,to);
|
||||||
} // moveRow
|
} // 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<ArrayList<Object>> getRows() {
|
||||||
|
return m_data.rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
|
@ -205,8 +205,7 @@ public class ResultTable extends JTable implements MouseListener
|
||||||
* Sort Table
|
* Sort Table
|
||||||
* @param modelColumnIndex
|
* @param modelColumnIndex
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
private void sort (final int modelColumnIndex)
|
||||||
private void sort (int modelColumnIndex)
|
|
||||||
{
|
{
|
||||||
int rows = getRowCount();
|
int rows = getRowCount();
|
||||||
if (rows == 0)
|
if (rows == 0)
|
||||||
|
@ -224,37 +223,16 @@ public class ResultTable extends JTable implements MouseListener
|
||||||
ResultTableModel model = (ResultTableModel)getModel();
|
ResultTableModel model = (ResultTableModel)getModel();
|
||||||
|
|
||||||
// Prepare sorting
|
// Prepare sorting
|
||||||
MSort sort = new MSort(0, null);
|
final MSort sort = new MSort(0, null);
|
||||||
sort.setSortAsc(m_asc);
|
sort.setSortAsc(m_asc);
|
||||||
// while something to sort
|
// Sort the data list - teo_sarca [ 1734327 ]
|
||||||
sorting:
|
Collections.sort(model.getDataList(), new Comparator<Object>() {
|
||||||
while (true)
|
public int compare(Object o1, Object o2) {
|
||||||
{
|
Object item1 = ((ArrayList)o1).get(modelColumnIndex);
|
||||||
// Create sortList
|
Object item2 = ((ArrayList)o2).get(modelColumnIndex);
|
||||||
ArrayList<MSort> sortList = new ArrayList<MSort>(rows);
|
return sort.compare(item1, item2);
|
||||||
// fill with data entity
|
|
||||||
for (int i = 0; i < rows; i++)
|
|
||||||
{
|
|
||||||
Object value = model.getValueAt(i, modelColumnIndex);
|
|
||||||
sortList.add(new MSort(i, value));
|
|
||||||
}
|
}
|
||||||
// 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
|
} // sort
|
||||||
|
|
||||||
} // ResultTable
|
} // ResultTable
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.compiere.report.core;
|
package org.compiere.report.core;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import javax.swing.event.*;
|
import javax.swing.event.*;
|
||||||
import javax.swing.table.*;
|
import javax.swing.table.*;
|
||||||
|
|
||||||
|
@ -121,4 +123,13 @@ class ResultTableModel extends AbstractTableModel
|
||||||
m_model.moveRow (from, to);
|
m_model.moveRow (from, to);
|
||||||
} // moveRow
|
} // 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<ArrayList<Object>> getDataList() {
|
||||||
|
return m_model.getRows();
|
||||||
|
}
|
||||||
} // ResultTableModel
|
} // ResultTableModel
|
||||||
|
|
Loading…
Reference in New Issue