本文整理匯總了Java中javax.swing.SortOrder.ASCENDING屬性的典型用法代碼示例。如果您正苦於以下問題:Java SortOrder.ASCENDING屬性的具體用法?Java SortOrder.ASCENDING怎麽用?Java SortOrder.ASCENDING使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類javax.swing.SortOrder
的用法示例。
在下文中一共展示了SortOrder.ASCENDING屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setColumnSortOrder
protected final void setColumnSortOrder(final int modelColumnIndex, final SortOrder sortOrder)
{
sortIndexes2Direction.remove(modelColumnIndex);
if (sortOrder == SortOrder.ASCENDING)
{
sortIndexes2Direction.put(modelColumnIndex, true);
}
else if (sortOrder == SortOrder.DESCENDING)
{
sortIndexes2Direction.put(modelColumnIndex, false);
}
else if (sortOrder == SortOrder.UNSORTED)
{
// just removed it's fine
}
else
{
// shall not happen
}
}
示例2: getSortAscendingFlagOfSortOrder
private static final Boolean getSortAscendingFlagOfSortOrder(final SortOrder sortOrder)
{
if (sortOrder == null)
{
return null;
}
else if (sortOrder == SortOrder.ASCENDING)
{
return true;
}
else if (sortOrder == SortOrder.DESCENDING)
{
return false;
}
else if (sortOrder == SortOrder.UNSORTED)
{
return null;
}
else
{
throw new IllegalArgumentException("Unknown sortOrder: " + sortOrder);
}
}
示例3: getColumnSortIcon
/** @return column sort icon or null */
private final Icon getColumnSortIcon(final JTable table, final int viewColumnIndex)
{
if (table instanceof CTable)
{
final CTable cTable = (CTable)table;
final int modelColumnIndex = table.convertColumnIndexToModel(viewColumnIndex);
final SortOrder sortOrder = cTable.getSortOrder(modelColumnIndex);
if (sortOrder == SortOrder.ASCENDING)
{
return Images.getImageIcon2("uparrow");
}
else if (sortOrder == SortOrder.DESCENDING)
{
return Images.getImageIcon2("downarrow");
}
else
{
return null;
}
}
else
{
return null;
}
}
示例4: sorterChanged
@Override
public void sorterChanged(RowSorterEvent e) {
if (e.getType() == Type.SORT_ORDER_CHANGED) {
@SuppressWarnings("unchecked")
List<? extends SortKey> sortKeys = e.getSource().getSortKeys();
Object[] keys = new Object[sortKeys.size()];
boolean[] directions = new boolean[sortKeys.size()];
int index = 0;
for (SortKey s : sortKeys) {
keys[index] = SwingTable.this.keys[s.getColumn()];
directions[index] = s.getSortOrder() == SortOrder.ASCENDING;
index++;
}
if (list instanceof Sortable) {
((Sortable) list).sort(keys, directions);
}
setOffset(0);
}
}
示例5: toggleSortOrder
/**
* Reverses the sort order from ascending to descending (or
* descending to ascending) if the specified column is already the
* primary sorted column; otherwise, makes the specified column
* the primary sorted column, with an ascending sort order. If
* the specified column is not sortable, this method has no
* effect.
*
* @param column index of the column to make the primary sorted column,
* in terms of the underlying model
* @throws IndexOutOfBoundsException {@inheritDoc}
* @see #setSortable(int,boolean)
* @see #setMaxSortKeys(int)
*/
public void toggleSortOrder(int column) {
checkColumn(column);
if (isSortable(column)) {
List<SortKey> keys = new ArrayList<SortKey>(getSortKeys());
SortKey sortKey;
int sortIndex;
for (sortIndex = keys.size() - 1; sortIndex >= 0; sortIndex--) {
if (keys.get(sortIndex).getColumn() == column) {
break;
}
}
if (sortIndex == -1) {
// Key doesn't exist
sortKey = new SortKey(column, SortOrder.ASCENDING);
keys.add(0, sortKey);
}
else if (sortIndex == 0) {
// It's the primary sorting key, toggle it
keys.set(0, toggle(keys.get(0)));
}
else {
// It's not the first, but was sorted on, remove old
// entry, insert as first with ascending.
keys.remove(sortIndex);
keys.add(0, new SortKey(column, SortOrder.ASCENDING));
}
if (keys.size() > getMaxSortKeys()) {
keys = keys.subList(0, getMaxSortKeys());
}
setSortKeys(keys);
}
}
示例6: columnComparator
@Override
protected Comparator<HeaderDetailViewToModel<Transaction>> columnComparator(SortKey sortKey) {
if (isDateColumn(sortKey)) {
return sortKey.getSortOrder() == SortOrder.ASCENDING ? beanIndexOrdering.compound(modelIndexComparator)
: beanIndexOrdering.reverse().compound(modelIndexComparator);
}
return super.columnComparator(sortKey);
}
示例7: toggleSortOrder
@Override
public void toggleSortOrder(final int column) {
checkColumn(column);
if (isSortable(column)) {
List<SortKey> keys = new ArrayList<>(getSortKeys());
SortKey sortKey;
int sortIndex;
for (sortIndex = keys.size() - 1; sortIndex >= 0; sortIndex--) {
if (keys.get(sortIndex).getColumn() == column) {
break;
}
}
if (sortIndex == -1) {
sortKey = new SortKey(column, SortOrder.ASCENDING);
keys.add(0, sortKey);
} else if (sortIndex == 0) {
keys.set(0, toggle(keys.get(0)));
} else {
keys.remove(sortIndex);
keys.add(0, new SortKey(column, SortOrder.ASCENDING));
}
if (keys.size() > getMaxSortKeys()) {
keys = keys.subList(0, getMaxSortKeys());
}
setSortKeys(keys);
checkSortState();
}
}
示例8: toggle
private SortKey toggle(final SortKey key) {
switch (key.getSortOrder()) {
case ASCENDING: {
return new SortKey(key.getColumn(), SortOrder.DESCENDING);
}
case DESCENDING: {
return new SortKey(key.getColumn(), SortOrder.UNSORTED);
}
case UNSORTED: {
return new SortKey(key.getColumn(), SortOrder.ASCENDING);
}
}
throw new UnreachableCodeReachedException();
}
示例9: getHeaderValue
/**
* @inherited <p>
*/
@Override
public Object getHeaderValue() {
Object header = super.getHeaderValue();
Object sortOrder = getClientProperty(SORT_ORDER_KEY);
if (SortOrder.ASCENDING == sortOrder) {
header = header + ASCENDING_CHAR;
} else if (SortOrder.DESCENDING == sortOrder){
header = header + DESCENDING_CHAR;
}
return header;
}
示例10: getSortingFromTable
/**
* Returns the current sort keys of the given table encoded in a String.
*
* <p>This is intended to be used together with
* {@link setSortingForTable(JTable, String)}.</p>
*
* @param table
* @return
*/
public static String getSortingFromTable(JTable table) {
List<? extends RowSorter.SortKey> keys = table.getRowSorter().getSortKeys();
String result = "";
for (RowSorter.SortKey key : keys) {
int order = 0;
if (key.getSortOrder() == SortOrder.ASCENDING) {
order = 1;
} else if (key.getSortOrder() == SortOrder.DESCENDING) {
order = 2;
}
result += String.format("%s:%s;", key.getColumn(), order);
}
return result;
}
示例11: getSortOrderOfBooleanAscendingFlag
private static final SortOrder getSortOrderOfBooleanAscendingFlag(final Boolean isSortAscending)
{
if (isSortAscending == null)
{
return SortOrder.UNSORTED;
}
else if (isSortAscending)
{
return SortOrder.ASCENDING;
}
else
{
return SortOrder.DESCENDING;
}
}
示例12: getSortOrder
private SortOrder getSortOrder(String sortOrder) {
if (SortOrder.ASCENDING.toString().equals(sortOrder)) return SortOrder.ASCENDING;
else if (SortOrder.DESCENDING.toString().equals(sortOrder)) return SortOrder.DESCENDING;
else return SortOrder.UNSORTED;
}
示例13: toggle
private SortKey toggle(SortKey key) {
if (key.getSortOrder() == SortOrder.ASCENDING) {
return new SortKey(key.getColumn(), SortOrder.DESCENDING);
}
return new SortKey(key.getColumn(), SortOrder.ASCENDING);
}
示例14: defaultSortKey
private SortKey defaultSortKey() {
return new SortKey(getColumn(TransactionColumnAdapter.DATE_ADAPTER).getModelIndex(), SortOrder.ASCENDING);
}
示例15: toggleSortOrder
public void toggleSortOrder(int col)
{
TableModel m = table.getModel();
if(m instanceof ZTableModelCommon)
{
//ZColumnInfo tc = ((ZTableModelCommon)m).getColumnInfo(col);
//if(tc.sortable)
{
List<SortKey> keys = new CList<SortKey>(getSortKeys());
SortKey sortKey;
int sortIndex;
for(sortIndex = keys.size() - 1; sortIndex >= 0; sortIndex--)
{
if(keys.get(sortIndex).getColumn() == col)
{
break;
}
}
if(sortIndex == -1)
{
// key doesn't exist
sortKey = new SortKey(col, SortOrder.ASCENDING);
keys.add(0, sortKey);
}
else if(sortIndex == 0)
{
// it's the primary sorting key, toggle it: none -> ASCENDING -> DESCENDING -> none
SortKey key = keys.get(0);
switch(key.getSortOrder())
{
case ASCENDING:
keys.set(0, new SortKey(key.getColumn(), SortOrder.DESCENDING));
break;
default:
keys.remove(0);
break;
}
}
else
{
// it's not the first, but was sorted on, remove old entry, insert as first with ascending.
keys.remove(sortIndex);
keys.add(0, new SortKey(col, SortOrder.ASCENDING));
}
if(keys.size() > getMaxSortKeys())
{
keys = keys.subList(0, getMaxSortKeys());
}
setSortKeys(keys);
// scroll to rect if single line is selected
int row = table.getSelectedRow();
if(row >= 0)
{
Rectangle r = table.getCellRect(row, col, true);
table.scrollRectToVisible(r);
}
}
}
}