Java Code Examples for org.eclipse.swt.widgets.Table#getSortColumn()
The following examples show how to use
org.eclipse.swt.widgets.Table#getSortColumn() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MergeProcessorColumnSelectionListener.java From MergeProcessor with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public void widgetSelected(SelectionEvent e) { final TableColumn column = (TableColumn) e.widget; final TableViewerColumn viewerColumn = (TableViewerColumn) column.getData(COLUMN_VIEWER_KEY); final Table table = column.getParent(); comparator.setColumn(table.indexOf(column)); if (table.getSortColumn() == column) { table.setSortDirection(table.getSortDirection() == SWT.UP ? SWT.DOWN : SWT.UP); } else { table.setSortColumn(column); table.setSortDirection(SWT.DOWN); } viewerColumn.getViewer().refresh(); configuration.setSortColumn(Column.valueForIndex(table.indexOf(column))); configuration.setSortDirection(table.getSortDirection()); }
Example 2
Source File: MonitorsViewTable.java From neoscada with Eclipse Public License 1.0 | 6 votes |
@Override public void widgetSelected ( final SelectionEvent e ) { final Table table = this.tableViewer.getTable (); final TableColumn newColumn = (TableColumn)e.widget; final TableColumn currentColumn = table.getSortColumn (); final int currentDir = table.getSortDirection (); int newDir = SWT.UP; if ( newColumn == currentColumn ) { newDir = currentDir == SWT.UP ? SWT.DOWN : SWT.UP; } else { table.setSortColumn ( newColumn ); } table.setSortDirection ( newDir ); this.tableViewer.setSorter ( new Sorter ( (Columns)newColumn.getData ( COLUMN_KEY ), newDir ) ); }
Example 3
Source File: EventViewTable.java From neoscada with Eclipse Public License 1.0 | 6 votes |
@Override public void widgetSelected ( final SelectionEvent e ) { final Table table = this.tableViewer.getTable (); final TableColumn newColumn = (TableColumn)e.widget; final TableColumn currentColumn = table.getSortColumn (); final EventTableColumn column = (EventTableColumn)newColumn.getData ( COLUMN_KEY ); if ( column == EventTableColumn.reservedColumnSourceTimestamp || column == EventTableColumn.reservedColumnEntryTimestamp ) { final int currentDir = table.getSortDirection (); int newDir = SWT.UP; if ( newColumn == currentColumn ) { newDir = currentDir == SWT.UP ? SWT.DOWN : SWT.UP; } else { table.setSortColumn ( newColumn ); } table.setSortDirection ( newDir ); this.tableViewer.setSorter ( new EventTableSorter ( column, newDir ) ); } }
Example 4
Source File: TmfSimpleTableViewer.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
@Override public void widgetSelected(SelectionEvent e) { Table table = fTableViewer.getTable(); TableColumn prevSortcolumn = table.getSortColumn(); if (prevSortcolumn == fColumn) { flipSortDirection(); } table.setSortDirection(fDirection); table.setSortColumn(fColumn); Comparator<T> comparator; if (fDirection == SWT.DOWN) { comparator = fComparator; } else { comparator = checkNotNull(Collections.reverseOrder(fComparator)); } IContentProvider contentProvider = fTableViewer.getContentProvider(); if (contentProvider instanceof DeferredContentProvider) { DeferredContentProvider deferredContentProvider = (DeferredContentProvider) contentProvider; deferredContentProvider.setSortOrder(comparator); } else if (contentProvider instanceof ISortingLazyContentProvider) { ISortingLazyContentProvider sortingLazyContentProvider = (ISortingLazyContentProvider) contentProvider; sortingLazyContentProvider.setSortOrder(comparator); } else { fTableViewer.setComparator(new ElementComparator<>(comparator)); } }
Example 5
Source File: CoverageViewerComparator.java From tlaplus with MIT License | 5 votes |
@Override public int compare(final Viewer viewer, final Object e1, final Object e2) { final ActionInformationItem a1 = (ActionInformationItem) e1; final ActionInformationItem a2 = (ActionInformationItem) e2; final Table table = (Table) viewer.getControl(); final TableColumn sortColumn = table.getSortColumn(); if (sortColumn == null) { // a) Compare by distinct states first (we want actions with zero distinct states // to appear at the top). if (Long.compare(a1.getUnseen(), a2.getUnseen()) == 0L) { // b) Compare by location return a1.getModuleLocation().compareTo(a2.getModuleLocation()); } else { return Long.compare(a1.getUnseen(), a2.getUnseen()); } } else { // User requested to sort a specific column up or down. @SuppressWarnings("unchecked") final Comparator<ActionInformationItem> comp = (Comparator<ActionInformationItem>) sortColumn .getData(CoverageLabelProvider.COVERAGE_COMPARATOR); if (table.getSortDirection() == SWT.UP) { return comp.compare(a2, a1); } else { return comp.compare(a1, a2); } } }
Example 6
Source File: NodeKindTableControl.java From depan with Apache License 2.0 | 5 votes |
private int getSortDirection(TableColumn column) { Table tableControl = (Table) kindViewer.getControl(); if (column != tableControl.getSortColumn()) { return SWT.DOWN; } // If it is unsorted (SWT.NONE), assume down sort return (SWT.DOWN == tableControl.getSortDirection()) ? SWT.UP : SWT.DOWN; }
Example 7
Source File: EdgeDisplayTableControl.java From depan with Apache License 2.0 | 5 votes |
private int getSortDirection(TableColumn column) { Table tableControl = (Table) propViewer.getControl(); if (column != tableControl.getSortColumn()) { return SWT.DOWN; } // If it is unsorted (SWT.NONE), assume down sort return (SWT.DOWN == tableControl.getSortDirection()) ? SWT.UP : SWT.DOWN; }
Example 8
Source File: RelationDisplayTableControl.java From depan with Apache License 2.0 | 5 votes |
private int getSortDirection(TableColumn column) { Table tableControl = (Table) propViewer.getControl(); if (column != tableControl.getSortColumn()) { return SWT.DOWN; } // If it is unsorted (SWT.NONE), assume down sort return (SWT.DOWN == tableControl.getSortDirection()) ? SWT.UP : SWT.DOWN; }
Example 9
Source File: RelationSetTableControl.java From depan with Apache License 2.0 | 5 votes |
private int getSortDirection(TableColumn column) { Table tableControl = (Table) relSetViewer.getControl(); if (column != tableControl.getSortColumn()) { return SWT.DOWN; } // If it is unsorted (SWT.NONE), assume down sort return (SWT.DOWN == tableControl.getSortDirection()) ? SWT.UP : SWT.DOWN; }
Example 10
Source File: NewCodewindProjectPage.java From codewind-eclipse with Eclipse Public License 2.0 | 4 votes |
public static void sortTable(Table table, TableColumn column) { TableItem[] items = table.getItems(); int rows = items.length; int dir = table.getSortDirection() == SWT.DOWN ? 1 : -1; TableColumn currentColumn = table.getSortColumn(); int columnNum = 0; for (int j = 0; j < table.getColumnCount(); j++) { if (table.getColumn(j).equals(column)) { columnNum = j; break; } } if (column.equals(currentColumn)) dir = -dir; else dir = 1; // sort an index map, then move the actual rows int[] map = new int[rows]; for (int i = 0; i < rows; i++) map[i] = i; for (int i = 0; i < rows - 1; i++) { for (int j = i + 1; j < rows; j++) { TableItem a = items[map[i]]; TableItem b = items[map[j]]; if ((a.getText(columnNum).toLowerCase().compareTo(b.getText(columnNum).toLowerCase()) * dir > 0)) { int t = map[i]; map[i] = map[j]; map[j] = t; } } } // can't move existing items or delete first, so append new items to the end and then delete existing rows for (int i = 0; i < rows; i++) { int n = map[i]; TableItem item = new TableItem(table, SWT.NONE); for (int j = 0; j < table.getColumnCount(); j++) { item.setText(j, items[n].getText(j)); } item.setData(items[n].getData()); items[n].dispose(); } table.setSortDirection(dir == 1 ? SWT.DOWN : SWT.UP); table.setSortColumn(column); }