Java Code Examples for org.eclipse.swt.widgets.Tree.getColumnOrder()

The following are Jave code examples for showing how to use getColumnOrder() of the org.eclipse.swt.widgets.Tree class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: mytourbook   File: ColumnManager.java   Source Code and License Vote up 5 votes
/**
 * Read the column order from a table/tree.
 * 
 * @return Returns <code>null</code> when table/tree cannot be accessed.
 */
private String[] getColumns_FromViewer_Ids() {

	final ArrayList<String> orderedColumnIds = new ArrayList<String>();

	int[] columnOrder = null;

	if (_columnViewer instanceof TableViewer) {

		final Table table = ((TableViewer) _columnViewer).getTable();
		if (table.isDisposed()) {
			return null;
		}
		columnOrder = table.getColumnOrder();

	} else if (_columnViewer instanceof TreeViewer) {

		final Tree tree = ((TreeViewer) _columnViewer).getTree();
		if (tree.isDisposed()) {
			return null;
		}
		columnOrder = tree.getColumnOrder();
	}

	if (columnOrder == null) {
		return null;
	}

	// create columns in the correct sort order
	for (final int createIndex : columnOrder) {

		final ColumnDefinition colDef = getColDef_ByCreateIndex(createIndex);

		if (colDef != null) {
			orderedColumnIds.add(colDef.getColumnId());
		}
	}

	return orderedColumnIds.toArray(new String[orderedColumnIds.size()]);
}
 
Example 2
Project: mytourbook   File: ColumnManager.java   Source Code and License Vote up 3 votes
private ColumnWrapper getHeaderColumn(final Tree tree, final Point mousePosition, final boolean isTreeHeaderHit) {

		if (isTreeHeaderHit) {

			int columnWidths = 0;

			final TreeColumn[] columns = tree.getColumns();
			final int[] columnOrder = tree.getColumnOrder();

			for (final int creationIndex : columnOrder) {

				final TreeColumn tc = columns[creationIndex];

				final int columnWidth = tc.getWidth();

				if (columnWidths < mousePosition.x && mousePosition.x < columnWidths + columnWidth) {

					final int columnLeftBorder = columnWidths;
					final int columnRightBorder = columnWidths + columnWidth;

					// column found
					return new ColumnWrapper(tc, columnLeftBorder, columnRightBorder);
				}

				columnWidths += columnWidth;
			}
		}

		return null;
	}