当前位置: 首页>>代码示例>>Java>>正文


Java RowSorter.SortKey方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:ProfilerRowSorter.java

示例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;
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:31,代码来源:MultiColumnSortTableHeaderCellRenderer.java

示例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;
}
 
开发者ID:freeseawind,项目名称:littleluck,代码行数:21,代码来源:LuckTableCellHeaderRenderer.java

示例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;
}
 
开发者ID:mars-sim,项目名称:mars-sim,代码行数:25,代码来源:MultisortTableHeaderCellRenderer.java

示例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;
}
 
开发者ID:Qualtagh,项目名称:JBroTable,代码行数:18,代码来源:JBroPredefinedRowSorter.java

示例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;
}
 
开发者ID:Qualtagh,项目名称:JBroTable,代码行数:17,代码来源:JBroPredefinedRowSorter.java

示例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;
}
 
开发者ID:khuxtable,项目名称:seaglass,代码行数:24,代码来源:SeaGlassTableHeaderUI.java

示例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);
            }
        }
    }
}
 
开发者ID:sjPlot,项目名称:Zettelkasten,代码行数:25,代码来源:Settings.java

示例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);
            }
        }
    } 
}
 
开发者ID:Lightstreamer,项目名称:Lightstreamer-example-StockList-client-java,代码行数:18,代码来源:StockView.java

示例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);
}
 
开发者ID:chelu,项目名称:jdal,代码行数:20,代码来源:PageableTable.java

示例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;
}
 
开发者ID:josdem,项目名称:jmetadata,代码行数:27,代码来源:DescriptionTableHeader.java

示例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));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:ProfilerRowSorter.java

示例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());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:ProfilerRowSorter.java

示例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;
}
 
开发者ID:kddart,项目名称:kdxplore,代码行数:14,代码来源:SunSwingDefaultCellHeaderRenderer.java

示例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;
}
 
开发者ID:CA-IRIS,项目名称:ca-iris,代码行数:15,代码来源:ControllerTableModel.java


注:本文中的javax.swing.RowSorter.SortKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。