use of org.eclipse.swt.widgets.TreeItem in project dbeaver by serge-rider.
the class CustomTreeEditor method mouseUp.
@Override
public void mouseUp(MouseEvent e) {
if (e.button != 1) {
// Only on left click
return;
}
final TreeItem item = tree.getItem(new Point(e.x, e.y));
if (item != null) {
columnIndex = UIUtils.getColumnAtPos(item, e.x, e.y);
DBeaverUI.asyncExec(new Runnable() {
@Override
public void run() {
showEditor(item);
}
});
}
}
use of org.eclipse.swt.widgets.TreeItem in project dbeaver by serge-rider.
the class OracleMaintenanceDialog method getScriptListener.
@Override
protected SQLScriptProgressListener<T> getScriptListener() {
return new SQLScriptStatusDialog<T>(getShell(), getTitle() + " progress", null) {
@Override
protected void createStatusColumns(Tree objectTree) {
TreeColumn msgColumn = new TreeColumn(objectTree, SWT.NONE);
msgColumn.setText("Message");
}
@Override
public void processObjectResults(@NotNull T object, @Nullable DBCStatement statement, @Nullable DBCResultSet resultSet) throws DBCException {
}
@Override
public void endObjectProcessing(@NotNull T object, Exception error) {
super.endObjectProcessing(object, error);
TreeItem treeItem = getTreeItem(object);
if (treeItem != null) {
treeItem.setText(1, error == null ? "Done" : error.getMessage());
}
}
};
}
use of org.eclipse.swt.widgets.TreeItem in project dbeaver by serge-rider.
the class TreeLoadVisualizer method completeLoading.
@Override
public void completeLoading(Object[] children) {
final Control viewerControl = viewer.getControl();
if (viewerControl.isDisposed()) {
return;
}
try {
viewerControl.setRedraw(false);
Widget widget = viewer.testFindItem(parent);
if (widget != null && !widget.isDisposed()) {
TreeItem item = (TreeItem) viewer.testFindItem(placeHolder);
if (children == null) {
// Some error occurred. In good case children must be at least an empty array
viewer.collapseToLevel(parent, -1);
} else if (children.length != 0) {
viewer.add(parent, children);
}
if (item != null && !item.isDisposed()) {
if (item.getParentItem() != null && !item.getParentItem().isDisposed() || this.parent instanceof IWorkspaceRoot) {
viewer.remove(placeHolder);
}
}
}
} finally {
placeHolder.dispose(parent);
if (!viewerControl.isDisposed()) {
viewerControl.setRedraw(true);
}
}
}
use of org.eclipse.swt.widgets.TreeItem in project translationstudio8 by heartsome.
the class GridTreeViewer method remove.
/**
* Removes the element at the specified index of the parent. The selection is updated if required.
*
* @param parentOrTreePath the parent element, the input element, or a tree path to the parent element
* @param index child index
* @since 3.3
*/
public void remove(final Object parentOrTreePath, final int index) {
if (checkBusy())
return;
final List oldSelection = new LinkedList(Arrays.asList(((TreeSelection) getSelection()).getPaths()));
preservingSelection(new Runnable() {
public void run() {
TreePath removedPath = null;
if (internalIsInputOrEmptyPath(parentOrTreePath)) {
Tree tree = (Tree) getControl();
if (index < tree.getItemCount()) {
TreeItem item = tree.getItem(index);
if (item.getData() != null) {
removedPath = getTreePathFromItem(item);
disassociate(item);
}
item.dispose();
}
} else {
Widget[] parentItems = internalFindItems(parentOrTreePath);
for (int i = 0; i < parentItems.length; i++) {
TreeItem parentItem = (TreeItem) parentItems[i];
if (parentItem.isDisposed())
continue;
if (index < parentItem.getItemCount()) {
TreeItem item = parentItem.getItem(index);
if (item.getData() != null) {
removedPath = getTreePathFromItem(item);
disassociate(item);
}
item.dispose();
}
}
}
if (removedPath != null) {
boolean removed = false;
for (Iterator it = oldSelection.iterator(); it.hasNext(); ) {
TreePath path = (TreePath) it.next();
if (path.startsWith(removedPath, getComparer())) {
it.remove();
removed = true;
}
}
if (removed) {
setSelection(new TreeSelection((TreePath[]) oldSelection.toArray(new TreePath[oldSelection.size()]), getComparer()), false);
}
}
}
});
}
use of org.eclipse.swt.widgets.TreeItem in project translationstudio8 by heartsome.
the class ColumnChooserDialog method setGroupsSelectionIfRequired.
/**
* If all the leaves in a group are selected the group is also selected
*/
private void setGroupsSelectionIfRequired(Tree tree, List<Integer> columnEntryIndexes) {
Collection<TreeItem> allLeaves = ArrayUtil.asCollection(tree.getItems());
Collection<TreeItem> selectedLeaves = ArrayUtil.asCollection(tree.getSelection());
for (TreeItem leaf : allLeaves) {
if (isColumnGroupLeaf(leaf)) {
boolean markSelected = true;
Collection<TreeItem> nestedLeaves = ArrayUtil.asCollection(leaf.getItems());
for (TreeItem nestedLeaf : nestedLeaves) {
ColumnEntry columnEntry = getColumnEntryInLeaf(nestedLeaf);
if (!columnEntryIndexes.contains(columnEntry.getIndex())) {
markSelected = false;
}
}
if (markSelected) {
selectedLeaves.add(leaf);
}
}
}
tree.setSelection(selectedLeaves.toArray(new TreeItem[] {}));
}
Aggregations