Search in sources :

Example 11 with TreeItem

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);
            }
        });
    }
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) Point(org.eclipse.swt.graphics.Point)

Example 12 with TreeItem

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());
            }
        }
    };
}
Also used : SWT(org.eclipse.swt.SWT) TreeItem(org.eclipse.swt.widgets.TreeItem) TreeColumn(org.eclipse.swt.widgets.TreeColumn) Tree(org.eclipse.swt.widgets.Tree) DBCResultSet(org.jkiss.dbeaver.model.exec.DBCResultSet) NotNull(org.jkiss.code.NotNull) DBCStatement(org.jkiss.dbeaver.model.exec.DBCStatement) SQLScriptStatusDialog(org.jkiss.dbeaver.ui.dialogs.sql.SQLScriptStatusDialog) Nullable(org.jkiss.code.Nullable) DBCException(org.jkiss.dbeaver.model.exec.DBCException)

Example 13 with TreeItem

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);
        }
    }
}
Also used : Control(org.eclipse.swt.widgets.Control) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) TreeItem(org.eclipse.swt.widgets.TreeItem) Widget(org.eclipse.swt.widgets.Widget)

Example 14 with TreeItem

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);
                }
            }
        }
    });
}
Also used : TreePath(org.eclipse.jface.viewers.TreePath) TreeItem(org.eclipse.swt.widgets.TreeItem) TreeSelection(org.eclipse.jface.viewers.TreeSelection) Iterator(java.util.Iterator) Tree(org.eclipse.swt.widgets.Tree) List(java.util.List) LinkedList(java.util.LinkedList) LinkedList(java.util.LinkedList)

Example 15 with TreeItem

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[] {}));
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) ColumnEntry(net.sourceforge.nattable.columnChooser.ColumnEntry)

Aggregations

TreeItem (org.eclipse.swt.widgets.TreeItem)150 Tree (org.eclipse.swt.widgets.Tree)36 SelectionEvent (org.eclipse.swt.events.SelectionEvent)23 GridData (org.eclipse.swt.layout.GridData)23 Point (org.eclipse.swt.graphics.Point)21 ArrayList (java.util.ArrayList)20 TreeColumn (org.eclipse.swt.widgets.TreeColumn)18 GridLayout (org.eclipse.swt.layout.GridLayout)17 TreeViewer (org.eclipse.jface.viewers.TreeViewer)16 Composite (org.eclipse.swt.widgets.Composite)14 TableItem (org.eclipse.swt.widgets.TableItem)14 SelectionListener (org.eclipse.swt.events.SelectionListener)13 Group (org.eclipse.swt.widgets.Group)13 Button (org.eclipse.swt.widgets.Button)12 Table (org.eclipse.swt.widgets.Table)12 Event (org.eclipse.swt.widgets.Event)11 List (java.util.List)10 Label (org.eclipse.swt.widgets.Label)10 CubridGroupNode (com.cubrid.common.ui.spi.model.CubridGroupNode)9 AUndertaking (edu.cmu.cs.hcii.cogtool.model.AUndertaking)9