本文整理汇总了Java中javax.swing.RowSorter.SortKey方法的典型用法代码示例。如果您正苦于以下问题:Java RowSorter.SortKey方法的具体用法?Java RowSorter.SortKey怎么用?Java RowSorter.SortKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.RowSorter
的用法示例。
在下文中一共展示了RowSorter.SortKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setSortKeys
import javax.swing.RowSorter; //导入方法依赖的package包/类
public void setSortKeys(List newKeys) {
if (newKeys == null) {
setSortKeysImpl(newKeys);
return;
}
RowSorter.SortKey oldKey = getSortKey();
RowSorter.SortKey newKey = (RowSorter.SortKey)newKeys.get(0);
if (oldKey == null || oldKey.getColumn() != newKey.getColumn()) {
// Use defined initial SortOrder for a newly sorted column
setSortColumn(newKey.getColumn());
} else {
setSortKeysImpl(newKeys);
}
}
示例2: getIcon
import javax.swing.RowSorter; //导入方法依赖的package包/类
/**
* Overridden to return an icon suitable to a sorted column, or null if the
* column is unsorted. The icon for the primary sorted column is fully
* opaque, and the opacity is reduced by a factor of
* <code>alpha</code> for each subsequent sort index.
*
* @param table the <code>JTable</code>.
* @param column the column index.
* @return the sort icon with appropriate opacity, or null if the column is
* unsorted.
*/
@Override
public Icon getIcon(JTable table, int column) {
float computedAlpha = 1.0F;
for (RowSorter.SortKey sortKey : table.getRowSorter().getSortKeys()) {
if (table.convertColumnIndexToView(sortKey.getColumn()) == column) {
switch (sortKey.getSortOrder()) {
case ASCENDING:
return new AlphaIcon(UIManager.getIcon("Table.ascendingSortIcon"), computedAlpha);
case DESCENDING:
return new AlphaIcon(UIManager.getIcon("Table.descendingSortIcon"), computedAlpha);
default:
// Just to remove unmatched case warning
}
}
computedAlpha *= alpha;
}
return null;
}
示例3: getColumnSortOrder
import javax.swing.RowSorter; //导入方法依赖的package包/类
public static SortOrder getColumnSortOrder(JTable table, int column)
{
SortOrder rv = null;
if (table == null || table.getRowSorter() == null)
{
return rv;
}
java.util.List<? extends RowSorter.SortKey> sortKeys = table
.getRowSorter().getSortKeys();
if (sortKeys.size() > 0 && sortKeys.get(0).getColumn() == table
.convertColumnIndexToModel(column))
{
rv = sortKeys.get(0).getSortOrder();
}
return rv;
}
示例4: getIcon
import javax.swing.RowSorter; //导入方法依赖的package包/类
/**
* Overridden to return an icon suitable to a sorted column, or null if the column is unsorted.
* The icon for the primary sorted column is fully opaque, and the opacity is reduced by a
* factor of <code>alpha</code> for each subsequent sort index.
*
* @param table the <code>JTable</code>.
* @param column the column index.
* @return the sort icon with appropriate opacity, or null if the column is unsorted.
*/
public Icon getIcon(JTable table, int column) {
float computedAlpha = 1.0F;
for (RowSorter.SortKey sortKey : table.getRowSorter().getSortKeys()) {
if (table.convertColumnIndexToView(sortKey.getColumn()) == column) {
switch (sortKey.getSortOrder()) {
case ASCENDING:
return new AlphaIcon(UIManager.getIcon("Table.ascendingSortIcon"), computedAlpha);
case DESCENDING:
return new AlphaIcon(UIManager.getIcon("Table.descendingSortIcon"), computedAlpha);
}
}
computedAlpha *= alpha;
}
return null;
}
示例5: toNumericKeys
import javax.swing.RowSorter; //导入方法依赖的package包/类
private RowSorter.SortKey[] toNumericKeys( SortKey... modelColumns ) {
if ( modelColumns != null && modelColumns.length != 0 ) {
JBroTable table = getTable();
ModelData data = table.getData();
RowSorter.SortKey keys[] = new RowSorter.SortKey[ modelColumns.length ];
for ( int i = 0; i < modelColumns.length; i++ ) {
SortKey modelColumn = modelColumns[ i ];
int col = data.getIndexOfModelField( modelColumn.getColumn() );
if ( col < 0 )
throw new IllegalArgumentException( "Field \"" + modelColumn.getColumn() + "\" not found" );
RowSorter.SortKey key = new RowSorter.SortKey( col, modelColumn.getSortOrder() );
keys[ i ] = key;
}
return keys;
}
return null;
}
示例6: toStringKeys
import javax.swing.RowSorter; //导入方法依赖的package包/类
private SortKey[] toStringKeys( RowSorter.SortKey... modelColumns ) {
if ( modelColumns != null && modelColumns.length != 0 ) {
JBroTable table = getTable();
ModelData data = table.getData();
ModelField fields[] = data.getFields();
SortKey keys[] = new SortKey[ modelColumns.length ];
for ( int i = 0; i < modelColumns.length; i++ ) {
RowSorter.SortKey modelColumn = modelColumns[ i ];
ModelField col = fields[ modelColumn.getColumn() ];
SortKey key = new SortKey( col.getIdentifier(), modelColumn.getSortOrder() );
keys[ i ] = key;
}
return keys;
}
return EMPTY_ARRAY;
}
示例7: getColumnSortOrder
import javax.swing.RowSorter; //导入方法依赖的package包/类
/**
* DOCUMENT ME!
*
* @param table DOCUMENT ME!
* @param column DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public static SortOrder getColumnSortOrder(JTable table, int column) {
SortOrder rv = null;
if (table == null || table.getRowSorter() == null) {
return rv;
}
java.util.List<? extends RowSorter.SortKey> sortKeys = table.getRowSorter().getSortKeys();
if (sortKeys.size() > 0 && sortKeys.get(0).getColumn() == table.convertColumnIndexToModel(column)) {
rv = sortKeys.get(0).getSortOrder();
}
return rv;
}
示例8: setTableSorting
import javax.swing.RowSorter; //导入方法依赖的package包/类
public void setTableSorting(javax.swing.JTable[] tables) {
Element el = settingsFile.getRootElement().getChild(SETTING_TABLEROWSORTING);
if (null == el) {
el = new Element(SETTING_TABLEROWSORTING);
settingsFile.getRootElement().addContent(el);
}
// iterate all tables
for (javax.swing.JTable t : tables) {
// check if table is valid
if (t != null) {
// get sorter for each table
javax.swing.DefaultRowSorter sorter = (javax.swing.DefaultRowSorter) t.getRowSorter();
// get sort keys (column, sort order)
List<RowSorter.SortKey> sk = sorter.getSortKeys();
if (sk != null && sk.size() > 0) {
// get first element
RowSorter.SortKey ssk = sk.get(0);
// set sortcolumn and sort order
String value = String.valueOf(ssk.getColumn()) + "," + ssk.getSortOrder().toString();
el.setAttribute(t.getName(), value);
}
}
}
}
示例9: sorterChanged
import javax.swing.RowSorter; //导入方法依赖的package包/类
@Override
public synchronized void sorterChanged(RowSorterEvent e) {
//the sort listener waits for changes on the sorted columns
//if the first sort key is the stock_name or the open_price column
//(that are fields that never change) it disable the dynamic sort
if (e.getType().equals(RowSorterEvent.Type.SORT_ORDER_CHANGED)) {
List<RowSorter.SortKey> keys = e.getSource().getSortKeys();
if(!keys.isEmpty()) {
int y = keys.get(0).getColumn();
if (y != 0 && y != 11) {
enableDynamicSort(true);
} else {
enableDynamicSort(false);
}
}
}
}
示例10: configurePage
import javax.swing.RowSorter; //导入方法依赖的package包/类
/**
* Configure sort and order in page from sorter
*/
private void configurePage() {
Page.Order order = Page.Order.ASC;
String sortPropertyName = null;
List<? extends SortKey> keys = sorter.getSortKeys();
// If sorting, get values to set in page
if (keys.size() > 0) {
RowSorter.SortKey key = sorter.getSortKeys().get(0);
if (tableModel.isPropertyColumn(key.getColumn())) {
sortPropertyName = tableModel.getSortPropertyName(key.getColumn());
order = converSortOrder(key);
}
}
page.setSortName(sortPropertyName);
page.setOrder(order);
}
示例11: getIcon
import javax.swing.RowSorter; //导入方法依赖的package包/类
private Icon getIcon(JTable table, int column) {
// DescriptionTable dTable = (DescriptionTable) table;
if (table == null || table.getRowSorter() == null) {
return UIManager.getIcon("Table.naturalSortIcon");
}
Icon sortIcon = null;
List<? extends RowSorter.SortKey> sortKeys = table.getRowSorter().getSortKeys();
if (sortKeys.size() > 0 && sortKeys.get(0).getColumn() == table.convertColumnIndexToModel(column)) {
switch (sortKeys.get(0).getSortOrder()) {
case ASCENDING:
sortIcon = SynthIcons.SORT_ASCENDING_ICON;
break;
case DESCENDING:
sortIcon = SynthIcons.SORT_DESCENDING_ICON;
break;
case UNSORTED:
sortIcon = SynthIcons.SORT_NATURAL_ICON;
break;
default:
throw new AssertionError("Cannot happen");
}
}
return sortIcon;
}
示例12: setSortKey
import javax.swing.RowSorter; //导入方法依赖的package包/类
void setSortKey(RowSorter.SortKey key) {
RowSorter.SortKey secondaryKey = secondarySortColumn == key.getColumn() ?
null : new RowSorter.SortKey(secondarySortColumn,
getDefaultSortOrder(secondarySortColumn));
setSortKeysImpl(secondaryKey == null ? Arrays.asList(key) :
Arrays.asList(key, secondaryKey));
}
示例13: saveToStorage
import javax.swing.RowSorter; //导入方法依赖的package包/类
void saveToStorage(Properties properties, ProfilerTable table) {
RowSorter.SortKey key = getSortKey();
if (key == null) {
properties.remove(SORT_COLUMN_KEY);
properties.remove(SORT_ORDER_KEY);
} else {
int column = key.getColumn();
SortOrder order = key.getSortOrder();
properties.setProperty(SORT_COLUMN_KEY, Integer.toString(column));
properties.setProperty(SORT_ORDER_KEY, order.toString());
}
}
示例14: getColumnSortOrder
import javax.swing.RowSorter; //导入方法依赖的package包/类
public static SortOrder getColumnSortOrder(JTable table, int column) {
SortOrder rv = null;
if (table == null || table.getRowSorter() == null) {
return rv;
}
java.util.List<? extends RowSorter.SortKey> sortKeys =
table.getRowSorter().getSortKeys();
if (sortKeys.size() > 0 && sortKeys.get(0).getColumn() ==
table.convertColumnIndexToModel(column)) {
rv = sortKeys.get(0).getSortOrder();
}
return rv;
}
示例15: createSorter
import javax.swing.RowSorter; //导入方法依赖的package包/类
/** Get a table row sorter */
@Override
public RowSorter<ProxyTableModel<Controller>> createSorter() {
TableRowSorter<ProxyTableModel<Controller>> sorter =
new TableRowSorter<ProxyTableModel<Controller>>(this);
sorter.setSortsOnUpdates(true);
LinkedList<RowSorter.SortKey> keys =
new LinkedList<RowSorter.SortKey>();
keys.add(new RowSorter.SortKey(0, SortOrder.ASCENDING));
sorter.setSortKeys(keys);
if (isFiltered())
sorter.setRowFilter(createFilter());
return sorter;
}