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