當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。