org.eclipse.swt.widgets.Table.getSortDirection()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(167)

本文整理了Java中org.eclipse.swt.widgets.Table.getSortDirection()方法的一些代码示例,展示了Table.getSortDirection()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Table.getSortDirection()方法的具体详情如下:
包路径:org.eclipse.swt.widgets.Table
类名称:Table
方法名:getSortDirection

Table.getSortDirection介绍

[英]Returns the direction of the sort indicator for the receiver. The value will be one of UP, DOWN or NONE.
[中]返回接收器排序指示器的方向。该值将是UPDOWNNONE中的一个。

代码示例

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt

private static String getSortDirection( Table table ) {
 String result = "none";
 if( table.getSortDirection() == SWT.UP ) {
  result = "up";
 } else if( table.getSortDirection() == SWT.DOWN ) {
  result = "down";
 }
 return result;
}

代码示例来源: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: net.anwiba.eclipse/net.anwiba.eclipse.project.dependencies

@Override
public int compare(final Viewer viewer, final Object object, final Object other) {
 final TableViewer tableViewer = (TableViewer) viewer;
 final Table table = tableViewer.getTable();
 final int sortDirection = table.getSortDirection();
 if (sortDirection == SWT.NONE) {
  return 1;
 }
 if (object == null && other == null) {
  return 0;
 }
 if (object == null) {
  return -1;
 }
 if (other == null) {
  return 1;
 }
 final int columnIndex = getSortColumnIndex(table);
 final IDependencyRelation description = (IDependencyRelation) object;
 final IDependencyRelation otherDescription = (IDependencyRelation) other;
 final int compare = compare(columnIndex, description, otherDescription);
 if (sortDirection == SWT.UP) {
  return compare * -1;
 }
 return compare;
}

代码示例来源:origin: net.anwiba.eclipse/net.anwiba.eclipse.project.dependencies

@Override
public int compare(final Viewer viewer, final Object object, final Object other) {
 final TableViewer tableViewer = (TableViewer) viewer;
 final Table table = tableViewer.getTable();
 final int sortDirection = table.getSortDirection();
 if (sortDirection == SWT.NONE) {
  return 1;
 }
 if (object == null && other == null) {
  return 0;
 }
 if (object == null) {
  return -1;
 }
 if (other == null) {
  return 1;
 }
 final int columnIndex = getSortColumnIndex(table);
 final IType type = (IType) object;
 final IType otherType = (IType) other;
 final int compare = compare(columnIndex, type, otherType);
 if (sortDirection == SWT.UP) {
  return compare * -1;
 }
 return compare;
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.ant.ui

@Override
  public void widgetSelected(SelectionEvent e) {
    if (ColumnSorter.this.cviewer.getComparator() != ColumnSorter.this) {
      setDirection(SWT.DOWN);
    } else {
      int tdirection = ColumnSorter.this.column.getParent().getSortDirection();
      if (tdirection == SWT.NONE) {
        setDirection(SWT.DOWN);
      } else {
        setDirection(tdirection == SWT.UP ? SWT.DOWN : SWT.UP);
      }
    }
  }
});

代码示例来源: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.scout.sdk.s2e/org.eclipse.scout.sdk.s2e.nls

private void updateSortIcon() {
 int index = m_tableModel.getSortIndex();
 if (index < 0) {
  index = NlsTable.INDEX_COLUMN_KEYS;
  m_tableModel.setSortIndex(index);
 }
 TableColumn col = m_table.getColumn(index);
 if (col == null) {
  return;
 }
 else if (col.equals(m_sortColumn)) {
  int sortDir = SWT.UP;
  if (m_table.getSortDirection() == SWT.UP) {
   sortDir = SWT.DOWN;
  }
  m_table.setSortDirection(sortDir);
 }
 else {
  m_sortColumn = col;
  m_table.setSortColumn(m_sortColumn);
  m_table.setSortDirection(SWT.UP);
 }
}

代码示例来源:origin: org.eclipse.equinox.security/ui

int dir = tableCert.getSortDirection();

代码示例来源:origin: BiglySoftware/BiglyBT

final int dir = subscriptionsList.getSortDirection() == SWT.DOWN ? 1 : -1;
final boolean nameSort = subscriptionsList.getColumn(0) == subscriptionsList.getSortColumn();
Arrays.sort(subscriptionItems,new Comparator() {

代码示例来源: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: 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: 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.springframework.extensions.surf/spring-surf-commons-ui

public void handleEvent(Event e) 
  if (table.getSortDirection() == SWT.UP)

代码示例来源: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

if (e.widget == table1.getSortColumn()) {
  switch (table1.getSortDirection ()) {
  case SWT.DOWN: sortDirection = SWT.UP; break;
  case SWT.UP: sortDirection = SWT.NONE; break;

代码示例来源: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();
if (sortColumn == currentColumn) {
  dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;

相关文章

Table类方法