javax.swing.SortOrder#ASCENDING源码实例Demo

下面列出了javax.swing.SortOrder#ASCENDING 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jdk1.8-source-analysis   文件: DefaultRowSorter.java
/**
 * 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);
    }
}
 
源代码2 项目: dragonwell8_jdk   文件: DefaultRowSorter.java
/**
 * 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);
    }
}
 
源代码3 项目: jdk8u_jdk   文件: DefaultRowSorter.java
/**
 * 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);
    }
}
 
源代码4 项目: JDKSourceCode1.8   文件: DefaultRowSorter.java
/**
 * 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);
    }
}
 
源代码5 项目: openjdk-8-source   文件: DefaultRowSorter.java
/**
 * 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 项目: openjdk-jdk8u   文件: DefaultRowSorter.java
/**
 * 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);
    }
}
 
源代码7 项目: jdk8u-jdk   文件: DefaultRowSorter.java
/**
 * 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);
    }
}
 
源代码8 项目: Java8CN   文件: DefaultRowSorter.java
/**
 * 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);
    }
}
 
源代码9 项目: jdk1.8-source-analysis   文件: DefaultRowSorter.java
private SortKey toggle(SortKey key) {
    if (key.getSortOrder() == SortOrder.ASCENDING) {
        return new SortKey(key.getColumn(), SortOrder.DESCENDING);
    }
    return new SortKey(key.getColumn(), SortOrder.ASCENDING);
}
 
源代码10 项目: dragonwell8_jdk   文件: DefaultRowSorter.java
private SortKey toggle(SortKey key) {
    if (key.getSortOrder() == SortOrder.ASCENDING) {
        return new SortKey(key.getColumn(), SortOrder.DESCENDING);
    }
    return new SortKey(key.getColumn(), SortOrder.ASCENDING);
}
 
源代码11 项目: hottub   文件: DefaultRowSorter.java
private SortKey toggle(SortKey key) {
    if (key.getSortOrder() == SortOrder.ASCENDING) {
        return new SortKey(key.getColumn(), SortOrder.DESCENDING);
    }
    return new SortKey(key.getColumn(), SortOrder.ASCENDING);
}
 
源代码12 项目: TencentKona-8   文件: DefaultRowSorter.java
private SortKey toggle(SortKey key) {
    if (key.getSortOrder() == SortOrder.ASCENDING) {
        return new SortKey(key.getColumn(), SortOrder.DESCENDING);
    }
    return new SortKey(key.getColumn(), SortOrder.ASCENDING);
}
 
源代码13 项目: openjdk-8   文件: DefaultRowSorter.java
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 项目: openjdk-jdk8u   文件: DefaultRowSorter.java
private SortKey toggle(SortKey key) {
    if (key.getSortOrder() == SortOrder.ASCENDING) {
        return new SortKey(key.getColumn(), SortOrder.DESCENDING);
    }
    return new SortKey(key.getColumn(), SortOrder.ASCENDING);
}
 
源代码15 项目: netbeans   文件: ProfilerRowSorter.java
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;
}
 
源代码16 项目: visualvm   文件: ProfilerRowSorter.java
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;
}
 
源代码17 项目: openjdk-jdk8u-backup   文件: DefaultRowSorter.java
private SortKey toggle(SortKey key) {
    if (key.getSortOrder() == SortOrder.ASCENDING) {
        return new SortKey(key.getColumn(), SortOrder.DESCENDING);
    }
    return new SortKey(key.getColumn(), SortOrder.ASCENDING);
}
 
源代码18 项目: jdk8u-jdk   文件: DefaultRowSorter.java
private SortKey toggle(SortKey key) {
    if (key.getSortOrder() == SortOrder.ASCENDING) {
        return new SortKey(key.getColumn(), SortOrder.DESCENDING);
    }
    return new SortKey(key.getColumn(), SortOrder.ASCENDING);
}
 
源代码19 项目: Java8CN   文件: DefaultRowSorter.java
private SortKey toggle(SortKey key) {
    if (key.getSortOrder() == SortOrder.ASCENDING) {
        return new SortKey(key.getColumn(), SortOrder.DESCENDING);
    }
    return new SortKey(key.getColumn(), SortOrder.ASCENDING);
}
 
源代码20 项目: jdk8u_jdk   文件: DefaultRowSorter.java
private SortKey toggle(SortKey key) {
    if (key.getSortOrder() == SortOrder.ASCENDING) {
        return new SortKey(key.getColumn(), SortOrder.DESCENDING);
    }
    return new SortKey(key.getColumn(), SortOrder.ASCENDING);
}
 
 方法所在类