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);
}
}
}
});
}
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());
}
}
};
}
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;
}
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);
}
}
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;
}
Aggregations