Java Code Examples for javax.swing.SortOrder#ASCENDING

The following examples show how to use javax.swing.SortOrder#ASCENDING . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultRowSorter.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 2
Source File: DefaultRowSorter.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 3
Source File: DefaultRowSorter.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 4
Source File: DefaultRowSorter.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 5
Source File: DefaultRowSorter.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 6
Source File: DefaultRowSorter.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 7
Source File: DefaultRowSorter.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 8
Source File: DefaultRowSorter.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 9
Source File: DefaultRowSorter.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
private SortKey toggle(SortKey key) {
    if (key.getSortOrder() == SortOrder.ASCENDING) {
        return new SortKey(key.getColumn(), SortOrder.DESCENDING);
    }
    return new SortKey(key.getColumn(), SortOrder.ASCENDING);
}
 
Example 10
Source File: DefaultRowSorter.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
private SortKey toggle(SortKey key) {
    if (key.getSortOrder() == SortOrder.ASCENDING) {
        return new SortKey(key.getColumn(), SortOrder.DESCENDING);
    }
    return new SortKey(key.getColumn(), SortOrder.ASCENDING);
}
 
Example 11
Source File: DefaultRowSorter.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private SortKey toggle(SortKey key) {
    if (key.getSortOrder() == SortOrder.ASCENDING) {
        return new SortKey(key.getColumn(), SortOrder.DESCENDING);
    }
    return new SortKey(key.getColumn(), SortOrder.ASCENDING);
}
 
Example 12
Source File: DefaultRowSorter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private SortKey toggle(SortKey key) {
    if (key.getSortOrder() == SortOrder.ASCENDING) {
        return new SortKey(key.getColumn(), SortOrder.DESCENDING);
    }
    return new SortKey(key.getColumn(), SortOrder.ASCENDING);
}
 
Example 13
Source File: ProfilerRowSorter.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example 14
Source File: ProfilerRowSorter.java    From netbeans with Apache License 2.0 4 votes vote down vote up
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;
}
 
Example 15
Source File: DefaultRowSorter.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private SortKey toggle(SortKey key) {
    if (key.getSortOrder() == SortOrder.ASCENDING) {
        return new SortKey(key.getColumn(), SortOrder.DESCENDING);
    }
    return new SortKey(key.getColumn(), SortOrder.ASCENDING);
}
 
Example 16
Source File: DefaultRowSorter.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private SortKey toggle(SortKey key) {
    if (key.getSortOrder() == SortOrder.ASCENDING) {
        return new SortKey(key.getColumn(), SortOrder.DESCENDING);
    }
    return new SortKey(key.getColumn(), SortOrder.ASCENDING);
}
 
Example 17
Source File: DefaultRowSorter.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private SortKey toggle(SortKey key) {
    if (key.getSortOrder() == SortOrder.ASCENDING) {
        return new SortKey(key.getColumn(), SortOrder.DESCENDING);
    }
    return new SortKey(key.getColumn(), SortOrder.ASCENDING);
}
 
Example 18
Source File: DefaultRowSorter.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
private SortKey toggle(SortKey key) {
    if (key.getSortOrder() == SortOrder.ASCENDING) {
        return new SortKey(key.getColumn(), SortOrder.DESCENDING);
    }
    return new SortKey(key.getColumn(), SortOrder.ASCENDING);
}
 
Example 19
Source File: DefaultRowSorter.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
private SortKey toggle(SortKey key) {
    if (key.getSortOrder() == SortOrder.ASCENDING) {
        return new SortKey(key.getColumn(), SortOrder.DESCENDING);
    }
    return new SortKey(key.getColumn(), SortOrder.ASCENDING);
}
 
Example 20
Source File: DefaultRowSorter.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
private SortKey toggle(SortKey key) {
    if (key.getSortOrder() == SortOrder.ASCENDING) {
        return new SortKey(key.getColumn(), SortOrder.DESCENDING);
    }
    return new SortKey(key.getColumn(), SortOrder.ASCENDING);
}