Java Code Examples for org.eclipse.swt.widgets.TableColumn#getParent()
The following examples show how to use
org.eclipse.swt.widgets.TableColumn#getParent() .
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: EnhancedTableViewer.java From eclipse-cs with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void widgetSelected(SelectionEvent e) { if (e.getSource() instanceof TableColumn) { TableColumn col = (TableColumn) e.getSource(); Table table = col.getParent(); int colIndex = table.indexOf(col); if (colIndex == mSortedColumnIndex) { mSortDirection = mSortDirection * DIRECTION_REVERSE; } else { mSortedColumnIndex = colIndex; mSortDirection = DIRECTION_FORWARD; } resort(); saveState(); } }
Example 3
Source File: TmfEventsTable.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
/** * Returns true if the column is expanded to take extra available space. * This is the last non-zero-width visible column in the column order on * Linux. This column's width should not be persisted. * * @param column * the column * @return true if the column is expanded. */ private static boolean isExpanded(TableColumn column) { if (IS_LINUX) { Table table = column.getParent(); int[] order = table.getColumnOrder(); for (int i = order.length - 1; i >= 0; i--) { TableColumn col = table.getColumn(order[i]); if (col == column) { return true; } if (col.getWidth() > 0) { return false; } } } return false; }
Example 4
Source File: SortTableColumnSelectionListener.java From nebula with Eclipse Public License 2.0 | 5 votes |
@Override protected Table getParent(SelectionEvent e) { // 1) Get table column which fire this selection event TableColumn tableColumn = (TableColumn) e.getSource(); // 2) Get the owner table return tableColumn.getParent(); }
Example 5
Source File: SortTableColumnSelectionListener.java From nebula with Eclipse Public License 2.0 | 5 votes |
@Override protected void sort(SelectionEvent e) { // 1) Get table column which fire this selection event TableColumn tableColumn = (TableColumn) e.getSource(); // 2) Get the owner table Table table = tableColumn.getParent(); // 3) Modify the SWT Table sort table.setSortColumn(tableColumn); table.setSortDirection(getSortDirection()); }
Example 6
Source File: TableSorter.java From Flashtool with GNU General Public License v3.0 | 5 votes |
private void tableColumnClicked(TableColumn column) { Table table = column.getParent(); if (column.equals(table.getSortColumn())) { table.setSortDirection(table.getSortDirection() == SWT.UP ? SWT.DOWN : SWT.UP); } else { table.setSortColumn(column); table.setSortDirection(SWT.UP); } tableViewer.refresh(); }
Example 7
Source File: TableViewerSorter.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
private void tableColumnClicked(TableColumn column){ Table table = column.getParent(); if (column.equals(table.getSortColumn())) { table.setSortDirection(table.getSortDirection() == SWT.UP ? SWT.DOWN : SWT.UP); } else { table.setSortColumn(column); table.setSortDirection(SWT.UP); } tableViewer.refresh(); }
Example 8
Source File: ColumnsResizer.java From hop with Apache License 2.0 | 4 votes |
private Listener getColumnResizeListener( final int colIndex ) { return new Listener() { private int colIdx = colIndex; @Override public void handleEvent( Event event ) { if ( resizing ) { return; } TableColumn column = (TableColumn) event.widget; Table table = column.getParent(); TableColumn[] columns = table.getColumns(); int firstWidth = 0, restWidth = 0; int len = Math.min( weights.length, columns.length ); for ( int i = 0; i <= colIdx; i++ ) { firstWidth += columns[ i ].getWidth(); } float restWeightsBefore = 0; for ( int i = colIdx + 1; i < len; i++ ) { restWeightsBefore += weights[ i ]; restWidth += columns[ i ].getWidth(); } int tableWidth = getTableWidth( table ); final int minWeight = 4; for ( int i = 0; i <= colIdx; i++ ) { if ( weights[ i ] > 0 ) { weights[ i ] = columns[ i ].getWidth(); } } int columnsWidth = firstWidth + restWidth; int shortening = columnsWidth - tableWidth; float newRestWidth = restWidth - shortening; for ( int i = colIdx + 1; i < len; i++ ) { if ( weights[ i ] > 0 ) { float w = weights[ i ]; w = w / restWeightsBefore * newRestWidth; weights[ i ] = Math.max( Math.round( w ), minWeight ); } } applyWeigths( table ); } }; }
Example 9
Source File: HeaderLayout.java From nebula with Eclipse Public License 2.0 | 4 votes |
private void adjustWeights(AbstractNativeHeader header, TableColumn resizedColumn) { int totalAvailableWidth = getAvailableWidth(header); int resizedColumnNumber = 0; int newTotalWidth = 0; TableColumn[] columns = resizedColumn.getParent().getColumns(); for (int i = 0; i < columns.length; i++) { newTotalWidth += columns[i].getWidth(); if (columns[i] == resizedColumn) { resizedColumnNumber = i; } } Table table = resizedColumn.getParent(); int[] columnOrder = table.getColumnOrder(); int resizedColumnPosition = 0; for (int i = 0; i < columnOrder.length; i++) { if (columnOrder[i] == resizedColumnNumber) { resizedColumnPosition = i; break; } } if (resizedColumnIsNotTheLastColumn(resizedColumnPosition, resizedColumn.getParent())) { // Compute resized column width change and make sure the resized // column's width is sane int resizedColumnWidth = resizedColumn.getWidth(); // int columnWidthChange = lastWidths[resizedColumnPosition] - resizedColumnWidth; int columnWidthChange = lastWidths[columnOrder[resizedColumnPosition]] - resizedColumnWidth; int columnWidthChangeTooFar = MINIMUM_COL_WIDTH - resizedColumnWidth; if (columnWidthChangeTooFar > 0) { columnWidthChange -= columnWidthChangeTooFar; resizedColumnWidth = MINIMUM_COL_WIDTH; resizedColumn.setWidth(resizedColumnWidth); } // Fix the width of the column to the right of the resized column int columnToTheRightOfResizedColumnWidth = lastWidths[columnOrder[resizedColumnPosition+1]] + columnWidthChange; // int columnToTheRightOfResizedColumnWidth = // lastWidths[resizedColumnPosition+1] + columnWidthChange; columnWidthChangeTooFar = MINIMUM_COL_WIDTH - columnToTheRightOfResizedColumnWidth; if (columnWidthChangeTooFar > 0) { columnWidthChange += columnWidthChangeTooFar; resizedColumnWidth -= columnWidthChangeTooFar; resizedColumn.setWidth(resizedColumnWidth); columnToTheRightOfResizedColumnWidth = MINIMUM_COL_WIDTH; } TableColumn columnToTheRightOfResizedColumn = columns[columnOrder[resizedColumnPosition+1]]; columnToTheRightOfResizedColumn.setWidth(columnToTheRightOfResizedColumnWidth); if (isFittingHorizontally()) { adjustWeightedHeader(header, resizedColumnPosition, resizedColumn, columnToTheRightOfResizedColumn, totalAvailableWidth, newTotalWidth); } else { // Fix the weights based on if the column sizes are being scaled if (isWidthWiderThanAllColumns(header)) { adjustScaledAbsoluteWidthWeights(resizedColumnPosition, resizedColumnWidth, columnToTheRightOfResizedColumnWidth, header.getSize().x); } else { adjustNonScaledAbsoluteWidthWeights(resizedColumnPosition, resizedColumnWidth, columnToTheRightOfResizedColumnWidth); } } fireColumnResizedEvent(resizedColumnPosition, resizedColumnWidth, columnToTheRightOfResizedColumnWidth); } else { // Re-layout; the rightmost column can't be resized layout(header, true); } }
Example 10
Source File: ColumnsResizer.java From pentaho-kettle with Apache License 2.0 | 4 votes |
private Listener getColumnResizeListener( final int colIndex ) { return new Listener() { private int colIdx = colIndex; @Override public void handleEvent( Event event ) { if ( resizing ) { return; } TableColumn column = (TableColumn) event.widget; Table table = column.getParent(); TableColumn[] columns = table.getColumns(); int firstWidth = 0, restWidth = 0; int len = Math.min( weights.length, columns.length ); for ( int i = 0; i <= colIdx; i++ ) { firstWidth += columns[i].getWidth(); } float restWeightsBefore = 0; for ( int i = colIdx + 1; i < len; i++ ) { restWeightsBefore += weights[i]; restWidth += columns[i].getWidth(); } int tableWidth = getTableWidth( table ); final int minWeight = 4; for ( int i = 0; i <= colIdx; i++ ) { if ( weights[i] > 0 ) { weights[i] = columns[i].getWidth(); } } int columnsWidth = firstWidth + restWidth; int shortening = columnsWidth - tableWidth; float newRestWidth = restWidth - shortening; for ( int i = colIdx + 1; i < len; i++ ) { if ( weights[i] > 0 ) { float w = weights[i]; w = w / restWeightsBefore * newRestWidth; weights[i] = Math.max( Math.round( w ), minWeight ); } } applyWeigths( table ); } }; }