本文整理了Java中org.eclipse.swt.widgets.Table.getSortColumn()
方法的一些代码示例,展示了Table.getSortColumn()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Table.getSortColumn()
方法的具体详情如下:
包路径:org.eclipse.swt.widgets.Table
类名称:Table
方法名:getSortColumn
[英]Returns the column which shows the sort indicator for the receiver. The value may be null if no column shows the sort indicator.
[中]
代码示例来源:origin: tvrenamer/tvrenamer
@Override
public void widgetSelected(SelectionEvent e) {
final boolean sameColumn = (tcol == swtTable.getSortColumn());
if (sameColumn) {
// If the last time we sorted, it was on THIS column,
// then we reverse the direction of the previous sort.
col.sortDirection = (col.sortDirection == DOWN) ? UP : DOWN;
} else {
// If the last sort was on any other column, then we
// sort UP. We always sort UP on a "new" sort.
col.sortDirection = UP;
}
resultsTable.sortTable(col, col.sortDirection);
}
});
代码示例来源:origin: net.anwiba.eclipse/net.anwiba.eclipse.project.dependencies
private int getSortColumnIndex(final Table table) {
final TableColumn sortColumn = table.getSortColumn();
if (sortColumn == null) {
return -1;
}
return getColumnIndex(sortColumn.getText());
}
代码示例来源:origin: net.anwiba.eclipse/net.anwiba.eclipse.project.dependencies
private int getSortColumnIndex(final Table table) {
final TableColumn sortColumn = table.getSortColumn();
if (sortColumn == null) {
return -1;
}
return getColumnIndex(sortColumn.getText());
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt.q07
static String getSortDirection( final TableColumn column ) {
String result = null;
Table table = column.getParent();
if( table.getSortColumn() == column ) {
if( table.getSortDirection() == SWT.UP ) {
result = "up";
} else if( table.getSortDirection() == SWT.DOWN ) {
result = "down";
}
}
return result;
}
代码示例来源:origin: BiglySoftware/BiglyBT
@Override
public void handleEvent(Event e) {
// determine new sort column and direction
TableColumn sortColumn = subscriptionsList.getSortColumn();
TableColumn currentColumn = (TableColumn) e.widget;
int dir = subscriptionsList.getSortDirection();
if (sortColumn == currentColumn) {
dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
} else {
subscriptionsList.setSortColumn(currentColumn);
dir = SWT.DOWN;
}
subscriptionsList.setSortDirection(dir);
sortAndRefresh();
}
};
代码示例来源:origin: cbeust/testng-eclipse
@Override
public void widgetSelected(SelectionEvent e) {
if (tableSorter != null) {
tableSorter.setColumn(index);
}
int dir = table.getSortDirection();
if (table.getSortColumn() == column) {
dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
} else {
dir = SWT.DOWN;
}
table.setSortDirection(dir);
table.setSortColumn(column);
result.refresh(); }
});
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
@Override
public void run() {
renderProperty( table, PROP_TOP_ITEM_INDEX, table.getTopIndex(), ZERO );
renderProperty( table, PROP_SCROLL_LEFT, getScrollLeft( table ), ZERO );
renderProperty( table, PROP_FOCUS_ITEM, getFocusItem( table ), null );
renderProperty( table, PROP_SELECTION, getSelection( table ), DEFAULT_SELECTION );
renderProperty( table, PROP_SORT_COLUMN, table.getSortColumn(), null );
}
} );
代码示例来源:origin: org.eclipse.equinox.security/ui
public void handleEvent(Event e) {
TableColumn sortColumn = tableCert.getSortColumn();
TableColumn currentColumn = (TableColumn) e.widget;
int dir = tableCert.getSortDirection();
代码示例来源:origin: BiglySoftware/BiglyBT
final boolean nameSort = subscriptionsList.getColumn(0) == subscriptionsList.getSortColumn();
Arrays.sort(subscriptionItems,new Comparator() {
@Override
代码示例来源:origin: net.anwiba.eclipse/net.anwiba.eclipse.project.dependencies
@Override
public void widgetSelected(final SelectionEvent e) {
final Table table = this.column.getParent();
final TableColumn sortColumn = table.getSortColumn();
if (sortColumn == null || !sortColumn.equals(this.column)) {
table.setSortColumn(this.column);
table.setSortDirection(SWT.NONE);
}
switch (table.getSortDirection()) {
case SWT.NONE: {
table.setSortDirection(SWT.DOWN);
break;
}
case SWT.DOWN: {
table.setSortDirection(SWT.UP);
break;
}
case SWT.UP: {
table.setSortDirection(SWT.NONE);
break;
}
}
this.viewer.refresh();
}
}
代码示例来源:origin: net.anwiba.eclipse/net.anwiba.eclipse.project.dependencies
@Override
public void widgetSelected(final SelectionEvent e) {
final Table table = this.column.getParent();
final TableColumn sortColumn = table.getSortColumn();
if (sortColumn == null || !sortColumn.equals(this.column)) {
table.setSortColumn(this.column);
table.setSortDirection(SWT.NONE);
}
switch (table.getSortDirection()) {
case SWT.NONE: {
table.setSortDirection(SWT.DOWN);
break;
}
case SWT.DOWN: {
table.setSortDirection(SWT.UP);
break;
}
case SWT.UP: {
table.setSortDirection(SWT.NONE);
break;
}
}
this.viewer.refresh();
}
}
代码示例来源:origin: net.sf.okapi.lib/okapi-lib-verification-ui
public void handleEvent(Event event) {
// Determine new sort column and direction
TableColumn sortCol = tblIssues.getSortColumn();
TableColumn curCol = (TableColumn)event.widget;
int dir = tblIssues.getSortDirection();
if ( sortCol == curCol ) {
// Same column as before? then reverse sort direction
dir = (dir == SWT.UP ? SWT.DOWN : SWT.UP);
}
else { // Other column? the set the new column
tblIssues.setSortColumn(curCol);
dir = SWT.UP;
}
// Select the issue part to sort
int type = IssueComparator.TYPE_ENABLED;
if ( tblIssues.indexOf(curCol) == 1 ) type = IssueComparator.TYPE_SEVERITY;
else if ( tblIssues.indexOf(curCol) == 2 ) type = IssueComparator.TYPE_TU;
else if ( tblIssues.indexOf(curCol) == 3 ) type = IssueComparator.TYPE_SEG;
else if ( tblIssues.indexOf(curCol) == 4 ) type = IssueComparator.TYPE_MESSAGE;
// Perform the sort
Collections.sort(session.getIssues(),
new IssueComparator(type, dir==SWT.UP ? IssueComparator.DIR_ASC : IssueComparator.DIR_DESC));
// Set direction
tblIssues.setSortDirection(dir);
refreshTableDisplay();
}
};
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
final int getPreferredWidth () {
// Compute width from the column itself
int result = 0;
Font font = parent.getHeaderFont();
if( text.length() > 0 ) {
if( text.indexOf( '\n' ) != -1 ) {
result = TextSizeUtil.textExtent( font, text, 0 ).x;
} else {
result = TextSizeUtil.stringExtent( font, text ).x;
}
}
Image image = getImage();
if( image != null ) {
result += image.getBounds().width + SPACING;
}
if( parent.getSortColumn() == this && parent.getSortDirection() != SWT.NONE ) {
result += SORT_INDICATOR_WIDTH + SPACING;
}
BoxDimensions headerPadding = parent.getThemeAdapter().getHeaderPadding( parent );
result += headerPadding.left + headerPadding.right;
// Mimic Windows behaviour that forces first item to resolve
if( parent.getItemCount() > 0 && parent.getCachedItems().length == 0 ) {
parent.checkData( parent.getItem( 0 ), 0 );
}
// Extend computed width if there are wider items
int columnIndex = parent.indexOf( this );
int itemsPreferredWidth = parent.getItemsPreferredWidth( columnIndex );
// Add 1px for the right column border
return Math.max( result, itemsPreferredWidth ) + 1;
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ant.ui
/**
* Persist table settings into the give dialog store.
*
* @since 3.5
*/
private void saveColumnSettings() {
Table table = this.propertyTableViewer.getTable();
int columnCount = table.getColumnCount();
for (int i = 0; i < columnCount; i++) {
dialogSettings.put(PROPERTY_COLUMN_WIDTH + i, table.getColumn(i).getWidth());
}
TableColumn column = table.getSortColumn();
if (column != null) {
dialogSettings.put(PROPERTY_SORT_COLUMN, table.indexOf(column));
dialogSettings.put(PROPERTY_SORT_DIRECTION, table.getSortDirection());
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples
SelectionListener listener = widgetSelectedAdapter(e -> {
int sortDirection = SWT.DOWN;
if (e.widget == table1.getSortColumn()) {
代码示例来源:origin: org.eclipse.platform/org.eclipse.ant.ui
/**
* Persist table settings into the give dialog store, prefixed with the given key.
*
* @param settings
* dialog store
* @since 3.5
*/
public void saveColumnSettings(IDialogSettings settings) {
Table table = this.tableViewer.getTable();
int columnCount = table.getColumnCount();
for (int i = 0; i < columnCount; i++) {
settings.put(getHelpContextId() + ".columnWidth" + i, table.getColumn(i).getWidth()); //$NON-NLS-1$
}
TableColumn column = table.getSortColumn();
if (column != null) {
settings.put(getHelpContextId() + ".sortColumn", table.indexOf(column)); //$NON-NLS-1$
settings.put(getHelpContextId() + ".sortDirection", table.getSortDirection()); //$NON-NLS-1$
}
}
代码示例来源:origin: org.xworker/xworker_swt
TableColumn sortColumn = table.getSortColumn();
TableColumn currentColumn = (TableColumn) event.widget;
int dir = table.getSortDirection();
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
@Override
public void preserveValues( Table table ) {
preserveProperty( table, PROP_ITEM_COUNT, table.getItemCount() );
preserveProperty( table, PROP_ITEM_HEIGHT, table.getItemHeight() );
preserveProperty( table, PROP_ITEM_METRICS, getItemMetrics( table ) );
preserveProperty( table, PROP_COLUMN_COUNT, table.getColumnCount() );
preserveProperty( table, PROP_COLUMN_ORDER, getColumnOrder( table ) );
preserveProperty( table, PROP_FIXED_COLUMNS, getFixedColumns( table ) );
preserveProperty( table, PROP_HEADER_HEIGHT, table.getHeaderHeight() );
preserveProperty( table, PROP_HEADER_VISIBLE, table.getHeaderVisible() );
preserveProperty( table, PROP_HEADER_FOREGROUND, table.getHeaderForeground() );
preserveProperty( table, PROP_HEADER_BACKGROUND, table.getHeaderBackground() );
preserveProperty( table, PROP_LINES_VISIBLE, table.getLinesVisible() );
preserveProperty( table, PROP_TOP_ITEM_INDEX, table.getTopIndex() );
preserveProperty( table, PROP_FOCUS_ITEM, getFocusItem( table ) );
preserveProperty( table, PROP_SCROLL_LEFT, getScrollLeft( table ) );
preserveProperty( table, PROP_SELECTION, getSelection( table ) );
preserveProperty( table, PROP_SORT_DIRECTION, getSortDirection( table ) );
preserveProperty( table, PROP_SORT_COLUMN, table.getSortColumn() );
preserveProperty( table, PROP_ALWAYS_HIDE_SELECTION, hasAlwaysHideSelection( table ) );
preserveProperty( table, PROP_ENABLE_CELL_TOOLTIP, CellToolTipUtil.isEnabledFor( table ) );
preserveProperty( table, PROP_CELL_TOOLTIP_TEXT, null );
}
内容来源于网络,如有侵权,请联系作者删除!