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

The following examples show how to use org.eclipse.swt.widgets.Tree#getColumn() . 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: AbstractTimeGraphView.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private void createColumnSelectionListener(Tree tree) {
    for (int i = 0; i < fColumnComparators.length; i++) {
        final int index = i;
        final Comparator<ITimeGraphEntry> comp = fColumnComparators[index];
        final TreeColumn column = tree.getColumn(i);

        if (comp != null) {
            column.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    TreeColumn prevSortcolumn = tree.getSortColumn();
                    int direction = tree.getSortDirection();
                    if (prevSortcolumn == column) {
                        direction = (direction == SWT.DOWN) ? SWT.UP : SWT.DOWN;
                    } else {
                        direction = SWT.DOWN;
                    }
                    tree.setSortColumn(column);
                    tree.setSortDirection(direction);
                    fSortDirection = direction;
                    fCurrentSortColumn = index;
                    Comparator<ITimeGraphEntry> comparator = comp;

                    if (comparator instanceof ITimeGraphEntryComparator) {
                        ((ITimeGraphEntryComparator) comparator).setDirection(direction);
                    }
                    if (direction != SWT.DOWN) {
                        comparator = checkNotNull(Collections.reverseOrder(comparator));
                    }
                    setEntryComparator(comparator);
                    fIsRevealSelection = true;
                    fTimeGraphViewer.getControl().setFocus();
                    refresh();
                }
            });
        }
    }
}
 
Example 2
Source File: AbstractTimeGraphView.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private void applyViewContext() {
    ViewContext viewContext = fViewContext.remove(fTrace);
    applyExpandedStateContext(viewContext);
    if (fColumnComparators != null) {
        final Tree tree = fTimeGraphViewer.getTree();
        final TreeColumn column = tree.getColumn(fCurrentSortColumn);
        tree.setSortDirection(fSortDirection);
        tree.setSortColumn(column);
    }
    // restore and reveal selection
    if ((viewContext != null) && (viewContext.getSelection() != null)) {
        fTimeGraphViewer.setSelection(viewContext.getSelection(), true);
    }
}
 
Example 3
Source File: AbstractPackageManager.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
public void updateTree(Tree tree, List<String[]> listed) {
    TreeColumn column = tree.getColumn(0);
    column.setText("Library (" + getPackageManagerName() + " | " + listed.size() + " found)");
    for (String[] s : listed) {
        TreeItem item = new TreeItem(tree, SWT.None);
        item.setText(s);
    }
}
 
Example 4
Source File: TreeClipboard.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private static void copyHeaders(Tree tree, int levels, StringBuilder text) {
	int cols = tree.getColumnCount();
	if (cols < 1)
		return;
	text.append(tree.getColumn(0).getText());
	for (int level = 0; level < levels; level++)
		text.append('\t');
	for (int col = 1; col < cols; col++) {
		TreeColumn column = tree.getColumn(col);
		text.append(column.getText());
		if (col != (cols - 1))
			text.append('\t');
	}
	text.append('\n');
}