* [1688435] Sort indicator wrong after refresh
This commit is contained in:
parent
c154d96901
commit
64823b5c33
|
@ -65,6 +65,8 @@ public class CTable extends JTable
|
||||||
private final int MAXSIZE = 250;
|
private final int MAXSIZE = 250;
|
||||||
/** Model Index of Key Column */
|
/** Model Index of Key Column */
|
||||||
protected int p_keyColumnIndex = -1;
|
protected int p_keyColumnIndex = -1;
|
||||||
|
/** state variable to indicate sorting in progress **/
|
||||||
|
protected boolean sorting;
|
||||||
|
|
||||||
/** Logger */
|
/** Logger */
|
||||||
private static Logger log = Logger.getLogger(CTable.class.getName());
|
private static Logger log = Logger.getLogger(CTable.class.getName());
|
||||||
|
@ -207,6 +209,9 @@ public class CTable extends JTable
|
||||||
int rows = getRowCount();
|
int rows = getRowCount();
|
||||||
if (rows == 0)
|
if (rows == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
sorting = true;
|
||||||
|
|
||||||
// other column
|
// other column
|
||||||
if (modelColumnIndex != p_lastSortIndex)
|
if (modelColumnIndex != p_lastSortIndex)
|
||||||
p_asc = true;
|
p_asc = true;
|
||||||
|
@ -281,8 +286,36 @@ public class CTable extends JTable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // selected != null
|
} // selected != null
|
||||||
|
|
||||||
|
sorting = false;
|
||||||
} // sort
|
} // sort
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tableChanged(TableModelEvent e) {
|
||||||
|
if (e != null && e.getFirstRow() == 0 && e.getLastRow() == Integer.MAX_VALUE &&
|
||||||
|
e.getColumn() == TableModelEvent.ALL_COLUMNS && e.getType() == TableModelEvent.UPDATE)
|
||||||
|
{
|
||||||
|
if (!sorting)
|
||||||
|
{
|
||||||
|
//reset sort state after refresh
|
||||||
|
p_asc = true;
|
||||||
|
p_lastSortIndex = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (getRowCount() == 0)
|
||||||
|
{
|
||||||
|
//reset sort state after clear
|
||||||
|
p_asc = true;
|
||||||
|
p_lastSortIndex = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
super.tableChanged(e);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* String Representation
|
* String Representation
|
||||||
* @return info
|
* @return info
|
||||||
|
|
Loading…
Reference in New Issue