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


Java SortOrder.ASCENDING属性代码示例

本文整理汇总了Java中javax.swing.SortOrder.ASCENDING属性的典型用法代码示例。如果您正苦于以下问题:Java SortOrder.ASCENDING属性的具体用法?Java SortOrder.ASCENDING怎么用?Java SortOrder.ASCENDING使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.swing.SortOrder的用法示例。


在下文中一共展示了SortOrder.ASCENDING属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setColumnSortOrder

protected final void setColumnSortOrder(final int modelColumnIndex, final SortOrder sortOrder)
{
	sortIndexes2Direction.remove(modelColumnIndex);
	if (sortOrder == SortOrder.ASCENDING)
	{
		sortIndexes2Direction.put(modelColumnIndex, true);
	}
	else if (sortOrder == SortOrder.DESCENDING)
	{
		sortIndexes2Direction.put(modelColumnIndex, false);
	}
	else if (sortOrder == SortOrder.UNSORTED)
	{
		// just removed it's fine
	}
	else
	{
		// shall not happen
	}
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:20,代码来源:CTableModelRowSorter.java

示例2: getSortAscendingFlagOfSortOrder

private static final Boolean getSortAscendingFlagOfSortOrder(final SortOrder sortOrder)
{
	if (sortOrder == null)
	{
		return null;
	}
	else if (sortOrder == SortOrder.ASCENDING)
	{
		return true;
	}
	else if (sortOrder == SortOrder.DESCENDING)
	{
		return false;
	}
	else if (sortOrder == SortOrder.UNSORTED)
	{
		return null;
	}
	else
	{
		throw new IllegalArgumentException("Unknown sortOrder: " + sortOrder);
	}
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:23,代码来源:CTableModelRowSorter.java

示例3: getColumnSortIcon

/** @return column sort icon or null */
private final Icon getColumnSortIcon(final JTable table, final int viewColumnIndex)
{
	if (table instanceof CTable)
	{
		final CTable cTable = (CTable)table;
		final int modelColumnIndex = table.convertColumnIndexToModel(viewColumnIndex);
		final SortOrder sortOrder = cTable.getSortOrder(modelColumnIndex);
		if (sortOrder == SortOrder.ASCENDING)
		{
			return Images.getImageIcon2("uparrow");
		}
		else if (sortOrder == SortOrder.DESCENDING)
		{
			return Images.getImageIcon2("downarrow");
		}
		else
		{
			return null;
		}
	}
	else
	{
		return null;
	}
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:26,代码来源:VHeaderRenderer.java

示例4: sorterChanged

@Override
    public void sorterChanged(RowSorterEvent e) {
    	if (e.getType() == Type.SORT_ORDER_CHANGED) {
@SuppressWarnings("unchecked")
List<? extends SortKey> sortKeys = e.getSource().getSortKeys();
    		Object[] keys = new Object[sortKeys.size()];
    		boolean[] directions = new boolean[sortKeys.size()];
    		int index = 0;
    		for (SortKey s : sortKeys) {
    			keys[index] = SwingTable.this.keys[s.getColumn()];
    			directions[index] = s.getSortOrder() == SortOrder.ASCENDING;
    			index++;
    		}
    		if (list instanceof Sortable) {
    			((Sortable) list).sort(keys, directions);
    		}
    		setOffset(0);
    	}
    }
 
开发者ID:BrunoEberhard,项目名称:minimal-j,代码行数:19,代码来源:SwingTable.java

示例5: toggleSortOrder

/**
 * 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);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:46,代码来源:DefaultRowSorter.java

示例6: columnComparator

@Override
protected Comparator<HeaderDetailViewToModel<Transaction>> columnComparator(SortKey sortKey) {
    if (isDateColumn(sortKey)) {
        return sortKey.getSortOrder() == SortOrder.ASCENDING ? beanIndexOrdering.compound(modelIndexComparator)
                : beanIndexOrdering.reverse().compound(modelIndexComparator);
    }
    return super.columnComparator(sortKey);
}
 
开发者ID:jonestimd,项目名称:finances,代码行数:8,代码来源:TransactionTableRowSorter.java

示例7: toggleSortOrder

@Override
public void toggleSortOrder(final int column) {
  checkColumn(column);
  if (isSortable(column)) {
    List<SortKey> keys = new ArrayList<>(getSortKeys());
    SortKey sortKey;
    int sortIndex;
    for (sortIndex = keys.size() - 1; sortIndex >= 0; sortIndex--) {
      if (keys.get(sortIndex).getColumn() == column) {
        break;
      }
    }
    if (sortIndex == -1) {
      sortKey = new SortKey(column, SortOrder.ASCENDING);
      keys.add(0, sortKey);
    } else if (sortIndex == 0) {
      keys.set(0, toggle(keys.get(0)));
    } else {
      keys.remove(sortIndex);
      keys.add(0, new SortKey(column, SortOrder.ASCENDING));
    }
    if (keys.size() > getMaxSortKeys()) {
      keys = keys.subList(0, getMaxSortKeys());
    }
    setSortKeys(keys);
    checkSortState();
  }
}
 
开发者ID:AndreasWBartels,项目名称:libraries,代码行数:28,代码来源:ObjectTableRowSorter.java

示例8: toggle

private SortKey toggle(final SortKey key) {
  switch (key.getSortOrder()) {
    case ASCENDING: {
      return new SortKey(key.getColumn(), SortOrder.DESCENDING);
    }
    case DESCENDING: {
      return new SortKey(key.getColumn(), SortOrder.UNSORTED);
    }
    case UNSORTED: {
      return new SortKey(key.getColumn(), SortOrder.ASCENDING);
    }
  }
  throw new UnreachableCodeReachedException();
}
 
开发者ID:AndreasWBartels,项目名称:libraries,代码行数:14,代码来源:ObjectTableRowSorter.java

示例9: getHeaderValue

/**
 * @inherited <p>
 */
@Override
public Object getHeaderValue() {
    Object header = super.getHeaderValue();
    Object sortOrder = getClientProperty(SORT_ORDER_KEY);
    if (SortOrder.ASCENDING == sortOrder) {
        header = header + ASCENDING_CHAR;
    } else if (SortOrder.DESCENDING == sortOrder){
        header = header + DESCENDING_CHAR;
    }
    return header;
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:14,代码来源:JXTableVisualCheck.java

示例10: getSortingFromTable

/**
 * Returns the current sort keys of the given table encoded in a String.
 * 
 * <p>This is intended to be used together with
 * {@link setSortingForTable(JTable, String)}.</p>
 *
 * @param table
 * @return 
 */
public static String getSortingFromTable(JTable table) {
    List<? extends RowSorter.SortKey> keys = table.getRowSorter().getSortKeys();
    String result = "";
    for (RowSorter.SortKey key : keys) {
        int order = 0;
        if (key.getSortOrder() == SortOrder.ASCENDING) {
            order = 1;
        } else if (key.getSortOrder() == SortOrder.DESCENDING) {
            order = 2;
        }
        result += String.format("%s:%s;", key.getColumn(), order);
    }
    return result;
}
 
开发者ID:chatty,项目名称:chatty,代码行数:23,代码来源:GuiUtil.java

示例11: getSortOrderOfBooleanAscendingFlag

private static final SortOrder getSortOrderOfBooleanAscendingFlag(final Boolean isSortAscending)
{
	if (isSortAscending == null)
	{
		return SortOrder.UNSORTED;
	}
	else if (isSortAscending)
	{
		return SortOrder.ASCENDING;
	}
	else
	{
		return SortOrder.DESCENDING;
	}
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:15,代码来源:CTableModelRowSorter.java

示例12: getSortOrder

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

示例13: toggle

private SortKey toggle(SortKey key) {
    if (key.getSortOrder() == SortOrder.ASCENDING) {
        return new SortKey(key.getColumn(), SortOrder.DESCENDING);
    }
    return new SortKey(key.getColumn(), SortOrder.ASCENDING);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:6,代码来源:DefaultRowSorter.java

示例14: defaultSortKey

private SortKey defaultSortKey() {
    return new SortKey(getColumn(TransactionColumnAdapter.DATE_ADAPTER).getModelIndex(), SortOrder.ASCENDING);
}
 
开发者ID:jonestimd,项目名称:finances,代码行数:3,代码来源:TransactionTable.java

示例15: toggleSortOrder

public void toggleSortOrder(int col)
{
	TableModel m = table.getModel();
	if(m instanceof ZTableModelCommon)
	{
		//ZColumnInfo tc = ((ZTableModelCommon)m).getColumnInfo(col);
		//if(tc.sortable)
		{
			List<SortKey> keys = new CList<SortKey>(getSortKeys());
			SortKey sortKey;
			int sortIndex;
			for(sortIndex = keys.size() - 1; sortIndex >= 0; sortIndex--)
			{
				if(keys.get(sortIndex).getColumn() == col)
				{
					break;
				}
			}

			if(sortIndex == -1)
			{
				// key doesn't exist
				sortKey = new SortKey(col, SortOrder.ASCENDING);
				keys.add(0, sortKey);
			}
			else if(sortIndex == 0)
			{
				// it's the primary sorting key, toggle it: none -> ASCENDING -> DESCENDING -> none
				SortKey key = keys.get(0);
				switch(key.getSortOrder())
				{
				case ASCENDING:
					keys.set(0, new SortKey(key.getColumn(), SortOrder.DESCENDING));
					break;
				default:
					keys.remove(0);
					break;
				}
			}
			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(col, SortOrder.ASCENDING));
			}

			if(keys.size() > getMaxSortKeys())
			{
				keys = keys.subList(0, getMaxSortKeys());
			}

			setSortKeys(keys);

			// scroll to rect if single line is selected
			int row = table.getSelectedRow();
			if(row >= 0)
			{
				Rectangle r = table.getCellRect(row, col, true);
				table.scrollRectToVisible(r);
			}
		}
	}
}
 
开发者ID:andy-goryachev,项目名称:PasswordSafe,代码行数:63,代码来源:ZTableRowSorter.java


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