Search in sources :

Example 91 with TreeColumn

use of org.eclipse.swt.widgets.TreeColumn in project dbeaver by serge-rider.

the class DriverTreeViewer method initDrivers.

public void initDrivers(List<DBPDataSourceProviderDescriptor> providers, boolean expandRecent) {
    getTree().setHeaderVisible(true);
    this.providers = providers;
    if (this.providers == null) {
        this.providers = DataSourceProviderRegistry.getInstance().getEnabledDataSourceProviders();
    }
    TreeColumn nameColumn = new TreeColumn(getTree(), SWT.LEFT);
    nameColumn.setText("Name");
    nameColumn.addListener(SWT.Selection, new DriversSortListener(nameColumn, true));
    TreeColumn usersColumn = new TreeColumn(getTree(), SWT.LEFT);
    usersColumn.setText("#");
    usersColumn.addListener(SWT.Selection, new DriversSortListener(usersColumn, false));
    this.setContentProvider(new ViewContentProvider());
    this.setLabelProvider(new ViewLabelProvider());
    this.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
    Collection<Object> drivers = collectDrivers();
    this.setInput(drivers);
    UIUtils.expandAll(this);
    UIUtils.packColumns(getTree(), true, new float[] { 0.9f, 0.1f });
    if (expandRecent) {
        // Expand used driver categories
        for (Object driver : drivers) {
            if (driver instanceof DriverCategory && getConnectionCount(driver) > 0) {
                expandToLevel(driver, ALL_LEVELS);
            } else {
                collapseToLevel(driver, ALL_LEVELS);
            }
        }
    } else {
        this.collapseAll();
    }
    addDoubleClickListener(event -> {
        IStructuredSelection selection = (IStructuredSelection) event.getSelection();
        if (!selection.isEmpty()) {
            Object element = selection.getFirstElement();
            if (element instanceof DriverCategory || element instanceof DataSourceProviderDescriptor) {
                if (Boolean.TRUE.equals(getExpandedState(element))) {
                    super.collapseToLevel(element, 1);
                } else {
                    super.expandToLevel(element, 1);
                }
            }
        }
    });
}
Also used : TreeColumn(org.eclipse.swt.widgets.TreeColumn) GridData(org.eclipse.swt.layout.GridData) DBPDataSourceProviderDescriptor(org.jkiss.dbeaver.model.connection.DBPDataSourceProviderDescriptor) DataSourceProviderDescriptor(org.jkiss.dbeaver.registry.DataSourceProviderDescriptor)

Example 92 with TreeColumn

use of org.eclipse.swt.widgets.TreeColumn in project dbeaver by serge-rider.

the class ExasolBaseTableToolDialog method getScriptListener.

@Override
protected SQLScriptProgressListener<ExasolTableBase> getScriptListener() {
    final int nbExtraColumns = getNumberExtraResultingColumns();
    return new SQLScriptStatusDialog<ExasolTableBase>(getTitle() + " " + ExasolMessages.dialog_table_tools_progress, null) {

        @Override
        protected void createStatusColumns(Tree objectTree) {
            TreeColumn msgColumn = new TreeColumn(objectTree, SWT.NONE);
            msgColumn.setText(ExasolMessages.dialog_table_tools_result);
            for (int i = 0; i < nbExtraColumns; i++) {
                new TreeColumn(objectTree, SWT.NONE);
            }
        }

        // DF: This method is for tools that return resultsets
        @Override
        public void processObjectResults(@NotNull ExasolTableBase exasolTable, @Nullable DBCStatement statement, @Nullable DBCResultSet resultSet) throws DBCException {
            if (resultSet == null) {
                return;
            }
            // Retrieve column names
            DBCResultSetMetaData rsMetaData = resultSet.getMeta();
            try {
                TreeItem treeItem = getTreeItem(exasolTable);
                Font f = UIUtils.makeBoldFont(treeItem.getFont());
                if (treeItem != null) {
                    // Display the column names
                    TreeItem subItem = null;
                    subItem = new TreeItem(treeItem, SWT.NONE);
                    subItem.setFont(f);
                    for (DBCAttributeMetaData column : rsMetaData.getAttributes()) {
                        subItem.setText(column.getOrdinalPosition(), column.getName());
                        subItem.setGrayed(true);
                    }
                    // Display the data for each row
                    while (resultSet.nextRow()) {
                        subItem = new TreeItem(treeItem, SWT.NONE);
                        for (int i = 0; i < rsMetaData.getAttributes().size(); i++) {
                            subItem.setText(i, CommonUtils.toString(resultSet.getAttributeValue(i)));
                            i++;
                        }
                    }
                    treeItem.setExpanded(true);
                }
            } catch (Exception e) {
                throw new DBCException(e.getMessage());
            }
        }
    };
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) ExasolTableBase(org.jkiss.dbeaver.ext.exasol.model.ExasolTableBase) NotNull(org.jkiss.code.NotNull) SQLScriptStatusDialog(org.jkiss.dbeaver.ui.editors.sql.dialogs.SQLScriptStatusDialog) Font(org.eclipse.swt.graphics.Font) TreeColumn(org.eclipse.swt.widgets.TreeColumn) Tree(org.eclipse.swt.widgets.Tree) Nullable(org.jkiss.code.Nullable)

Example 93 with TreeColumn

use of org.eclipse.swt.widgets.TreeColumn in project GT by Tencent.

the class CopyAllFromTreeViewAction method getContents.

/**
 * 获取treeview控件的所有数据
 * @return
 */
private StringBuffer getContents() {
    StringBuffer sb = new StringBuffer();
    int columnCount = viewer.getTree().getColumnCount();
    // 表头
    for (TreeColumn column : viewer.getTree().getColumns()) {
        sb.append(column.getText());
        sb.append(SourceDataItem.SPLIT);
    }
    sb.deleteCharAt(sb.length() - 1);
    sb.append("\r\n");
    for (TreeItem tableItem : viewer.getTree().getItems()) {
        parseTree(tableItem, columnCount, sb);
    }
    return sb;
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) TreeColumn(org.eclipse.swt.widgets.TreeColumn)

Example 94 with TreeColumn

use of org.eclipse.swt.widgets.TreeColumn in project cogtool by cogtool.

the class SWTTreeProjectSelectionState method deselectColumns.

protected void deselectColumns() {
    Iterator<TreeColumn> selCols = selectedColumns.iterator();
    while (selCols.hasNext()) {
        TreeColumn column = selCols.next();
        selCols.remove();
        deselectColumn(column);
    }
}
Also used : TreeColumn(org.eclipse.swt.widgets.TreeColumn)

Example 95 with TreeColumn

use of org.eclipse.swt.widgets.TreeColumn in project cogtool by cogtool.

the class ProjectUIModel method addTreeColumn.

protected TreeColumn addTreeColumn(Design design) {
    TreeColumn newColumn = new TreeColumn(tree, SWT.RIGHT);
    installTreeColumn(newColumn, design);
    return newColumn;
}
Also used : TreeColumn(org.eclipse.swt.widgets.TreeColumn)

Aggregations

TreeColumn (org.eclipse.swt.widgets.TreeColumn)189 Tree (org.eclipse.swt.widgets.Tree)99 TreeViewer (org.eclipse.jface.viewers.TreeViewer)55 Composite (org.eclipse.swt.widgets.Composite)52 TreeItem (org.eclipse.swt.widgets.TreeItem)45 FillLayout (org.eclipse.swt.layout.FillLayout)40 Point (org.eclipse.swt.graphics.Point)39 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)28 Viewer (org.eclipse.jface.viewers.Viewer)28 GridData (org.eclipse.swt.layout.GridData)28 ControlEvent (org.eclipse.swt.events.ControlEvent)27 ControlAdapter (org.eclipse.swt.events.ControlAdapter)25 SelectionEvent (org.eclipse.swt.events.SelectionEvent)25 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)24 TableColumn (org.eclipse.swt.widgets.TableColumn)24 TableLayout (org.eclipse.jface.viewers.TableLayout)23 Table (org.eclipse.swt.widgets.Table)23 GridLayout (org.eclipse.swt.layout.GridLayout)22 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)21 ViewerPane (org.eclipse.emf.common.ui.ViewerPane)19