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

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

本文整理了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

  1. private static String getSortDirection( Table table ) {
  2. String result = "none";
  3. if( table.getSortDirection() == SWT.UP ) {
  4. result = "up";
  5. } else if( table.getSortDirection() == SWT.DOWN ) {
  6. result = "down";
  7. }
  8. return result;
  9. }

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

  1. static String getSortDirection( final TableColumn column ) {
  2. String result = null;
  3. Table table = column.getParent();
  4. if( table.getSortColumn() == column ) {
  5. if( table.getSortDirection() == SWT.UP ) {
  6. result = "up";
  7. } else if( table.getSortDirection() == SWT.DOWN ) {
  8. result = "down";
  9. }
  10. }
  11. return result;
  12. }

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

  1. @Override
  2. public void handleEvent(Event e) {
  3. // determine new sort column and direction
  4. TableColumn sortColumn = subscriptionsList.getSortColumn();
  5. TableColumn currentColumn = (TableColumn) e.widget;
  6. int dir = subscriptionsList.getSortDirection();
  7. if (sortColumn == currentColumn) {
  8. dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
  9. } else {
  10. subscriptionsList.setSortColumn(currentColumn);
  11. dir = SWT.DOWN;
  12. }
  13. subscriptionsList.setSortDirection(dir);
  14. sortAndRefresh();
  15. }
  16. };

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

  1. @Override
  2. public int compare(final Viewer viewer, final Object object, final Object other) {
  3. final TableViewer tableViewer = (TableViewer) viewer;
  4. final Table table = tableViewer.getTable();
  5. final int sortDirection = table.getSortDirection();
  6. if (sortDirection == SWT.NONE) {
  7. return 1;
  8. }
  9. if (object == null && other == null) {
  10. return 0;
  11. }
  12. if (object == null) {
  13. return -1;
  14. }
  15. if (other == null) {
  16. return 1;
  17. }
  18. final int columnIndex = getSortColumnIndex(table);
  19. final IDependencyRelation description = (IDependencyRelation) object;
  20. final IDependencyRelation otherDescription = (IDependencyRelation) other;
  21. final int compare = compare(columnIndex, description, otherDescription);
  22. if (sortDirection == SWT.UP) {
  23. return compare * -1;
  24. }
  25. return compare;
  26. }

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

  1. @Override
  2. public int compare(final Viewer viewer, final Object object, final Object other) {
  3. final TableViewer tableViewer = (TableViewer) viewer;
  4. final Table table = tableViewer.getTable();
  5. final int sortDirection = table.getSortDirection();
  6. if (sortDirection == SWT.NONE) {
  7. return 1;
  8. }
  9. if (object == null && other == null) {
  10. return 0;
  11. }
  12. if (object == null) {
  13. return -1;
  14. }
  15. if (other == null) {
  16. return 1;
  17. }
  18. final int columnIndex = getSortColumnIndex(table);
  19. final IType type = (IType) object;
  20. final IType otherType = (IType) other;
  21. final int compare = compare(columnIndex, type, otherType);
  22. if (sortDirection == SWT.UP) {
  23. return compare * -1;
  24. }
  25. return compare;
  26. }

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

  1. @Override
  2. public void widgetSelected(SelectionEvent e) {
  3. if (ColumnSorter.this.cviewer.getComparator() != ColumnSorter.this) {
  4. setDirection(SWT.DOWN);
  5. } else {
  6. int tdirection = ColumnSorter.this.column.getParent().getSortDirection();
  7. if (tdirection == SWT.NONE) {
  8. setDirection(SWT.DOWN);
  9. } else {
  10. setDirection(tdirection == SWT.UP ? SWT.DOWN : SWT.UP);
  11. }
  12. }
  13. }
  14. });

代码示例来源:origin: cbeust/testng-eclipse

  1. @Override
  2. public void widgetSelected(SelectionEvent e) {
  3. if (tableSorter != null) {
  4. tableSorter.setColumn(index);
  5. }
  6. int dir = table.getSortDirection();
  7. if (table.getSortColumn() == column) {
  8. dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
  9. } else {
  10. dir = SWT.DOWN;
  11. }
  12. table.setSortDirection(dir);
  13. table.setSortColumn(column);
  14. result.refresh(); }
  15. });

代码示例来源:origin: org.eclipse.scout.sdk.s2e/org.eclipse.scout.sdk.s2e.nls

  1. private void updateSortIcon() {
  2. int index = m_tableModel.getSortIndex();
  3. if (index < 0) {
  4. index = NlsTable.INDEX_COLUMN_KEYS;
  5. m_tableModel.setSortIndex(index);
  6. }
  7. TableColumn col = m_table.getColumn(index);
  8. if (col == null) {
  9. return;
  10. }
  11. else if (col.equals(m_sortColumn)) {
  12. int sortDir = SWT.UP;
  13. if (m_table.getSortDirection() == SWT.UP) {
  14. sortDir = SWT.DOWN;
  15. }
  16. m_table.setSortDirection(sortDir);
  17. }
  18. else {
  19. m_sortColumn = col;
  20. m_table.setSortColumn(m_sortColumn);
  21. m_table.setSortDirection(SWT.UP);
  22. }
  23. }

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

  1. int dir = tableCert.getSortDirection();

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

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

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

  1. @Override
  2. public void widgetSelected(final SelectionEvent e) {
  3. final Table table = this.column.getParent();
  4. final TableColumn sortColumn = table.getSortColumn();
  5. if (sortColumn == null || !sortColumn.equals(this.column)) {
  6. table.setSortColumn(this.column);
  7. table.setSortDirection(SWT.NONE);
  8. }
  9. switch (table.getSortDirection()) {
  10. case SWT.NONE: {
  11. table.setSortDirection(SWT.DOWN);
  12. break;
  13. }
  14. case SWT.DOWN: {
  15. table.setSortDirection(SWT.UP);
  16. break;
  17. }
  18. case SWT.UP: {
  19. table.setSortDirection(SWT.NONE);
  20. break;
  21. }
  22. }
  23. this.viewer.refresh();
  24. }
  25. }

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

  1. @Override
  2. public void widgetSelected(final SelectionEvent e) {
  3. final Table table = this.column.getParent();
  4. final TableColumn sortColumn = table.getSortColumn();
  5. if (sortColumn == null || !sortColumn.equals(this.column)) {
  6. table.setSortColumn(this.column);
  7. table.setSortDirection(SWT.NONE);
  8. }
  9. switch (table.getSortDirection()) {
  10. case SWT.NONE: {
  11. table.setSortDirection(SWT.DOWN);
  12. break;
  13. }
  14. case SWT.DOWN: {
  15. table.setSortDirection(SWT.UP);
  16. break;
  17. }
  18. case SWT.UP: {
  19. table.setSortDirection(SWT.NONE);
  20. break;
  21. }
  22. }
  23. this.viewer.refresh();
  24. }
  25. }

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

  1. final int getPreferredWidth () {
  2. // Compute width from the column itself
  3. int result = 0;
  4. Font font = parent.getHeaderFont();
  5. if( text.length() > 0 ) {
  6. if( text.indexOf( '\n' ) != -1 ) {
  7. result = TextSizeUtil.textExtent( font, text, 0 ).x;
  8. } else {
  9. result = TextSizeUtil.stringExtent( font, text ).x;
  10. }
  11. }
  12. Image image = getImage();
  13. if( image != null ) {
  14. result += image.getBounds().width + SPACING;
  15. }
  16. if( parent.getSortColumn() == this && parent.getSortDirection() != SWT.NONE ) {
  17. result += SORT_INDICATOR_WIDTH + SPACING;
  18. }
  19. BoxDimensions headerPadding = parent.getThemeAdapter().getHeaderPadding( parent );
  20. result += headerPadding.left + headerPadding.right;
  21. // Mimic Windows behaviour that forces first item to resolve
  22. if( parent.getItemCount() > 0 && parent.getCachedItems().length == 0 ) {
  23. parent.checkData( parent.getItem( 0 ), 0 );
  24. }
  25. // Extend computed width if there are wider items
  26. int columnIndex = parent.indexOf( this );
  27. int itemsPreferredWidth = parent.getItemsPreferredWidth( columnIndex );
  28. // Add 1px for the right column border
  29. return Math.max( result, itemsPreferredWidth ) + 1;
  30. }

代码示例来源:origin: net.sf.okapi.lib/okapi-lib-verification-ui

  1. public void handleEvent(Event event) {
  2. // Determine new sort column and direction
  3. TableColumn sortCol = tblIssues.getSortColumn();
  4. TableColumn curCol = (TableColumn)event.widget;
  5. int dir = tblIssues.getSortDirection();
  6. if ( sortCol == curCol ) {
  7. // Same column as before? then reverse sort direction
  8. dir = (dir == SWT.UP ? SWT.DOWN : SWT.UP);
  9. }
  10. else { // Other column? the set the new column
  11. tblIssues.setSortColumn(curCol);
  12. dir = SWT.UP;
  13. }
  14. // Select the issue part to sort
  15. int type = IssueComparator.TYPE_ENABLED;
  16. if ( tblIssues.indexOf(curCol) == 1 ) type = IssueComparator.TYPE_SEVERITY;
  17. else if ( tblIssues.indexOf(curCol) == 2 ) type = IssueComparator.TYPE_TU;
  18. else if ( tblIssues.indexOf(curCol) == 3 ) type = IssueComparator.TYPE_SEG;
  19. else if ( tblIssues.indexOf(curCol) == 4 ) type = IssueComparator.TYPE_MESSAGE;
  20. // Perform the sort
  21. Collections.sort(session.getIssues(),
  22. new IssueComparator(type, dir==SWT.UP ? IssueComparator.DIR_ASC : IssueComparator.DIR_DESC));
  23. // Set direction
  24. tblIssues.setSortDirection(dir);
  25. refreshTableDisplay();
  26. }
  27. };

代码示例来源:origin: org.springframework.extensions.surf/spring-surf-commons-ui

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

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

  1. /**
  2. * Persist table settings into the give dialog store.
  3. *
  4. * @since 3.5
  5. */
  6. private void saveColumnSettings() {
  7. Table table = this.propertyTableViewer.getTable();
  8. int columnCount = table.getColumnCount();
  9. for (int i = 0; i < columnCount; i++) {
  10. dialogSettings.put(PROPERTY_COLUMN_WIDTH + i, table.getColumn(i).getWidth());
  11. }
  12. TableColumn column = table.getSortColumn();
  13. if (column != null) {
  14. dialogSettings.put(PROPERTY_SORT_COLUMN, table.indexOf(column));
  15. dialogSettings.put(PROPERTY_SORT_DIRECTION, table.getSortDirection());
  16. }
  17. }

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples

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

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

  1. /**
  2. * Persist table settings into the give dialog store, prefixed with the given key.
  3. *
  4. * @param settings
  5. * dialog store
  6. * @since 3.5
  7. */
  8. public void saveColumnSettings(IDialogSettings settings) {
  9. Table table = this.tableViewer.getTable();
  10. int columnCount = table.getColumnCount();
  11. for (int i = 0; i < columnCount; i++) {
  12. settings.put(getHelpContextId() + ".columnWidth" + i, table.getColumn(i).getWidth()); //$NON-NLS-1$
  13. }
  14. TableColumn column = table.getSortColumn();
  15. if (column != null) {
  16. settings.put(getHelpContextId() + ".sortColumn", table.indexOf(column)); //$NON-NLS-1$
  17. settings.put(getHelpContextId() + ".sortDirection", table.getSortDirection()); //$NON-NLS-1$
  18. }
  19. }

代码示例来源:origin: org.xworker/xworker_swt

  1. TableColumn sortColumn = table.getSortColumn();
  2. TableColumn currentColumn = (TableColumn) event.widget;
  3. int dir = table.getSortDirection();
  4. if (sortColumn == currentColumn) {
  5. dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;

相关文章

Table类方法