Search in sources :

Example 6 with TreeEvent

use of org.eclipse.swt.events.TreeEvent in project tdq-studio-se by Talend.

the class TwoPartCheckSelectionDialog method create.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.window.Window#create()
     */
@Override
public void create() {
    BusyIndicator.showWhile(null, new Runnable() {

        public void run() {
            parentCreate();
            fViewer.setCheckedElements(getInitialElementSelections().toArray());
            fViewer.getTree().addTreeListener(new TreeAdapter() {

                @Override
                public void treeExpanded(TreeEvent e) {
                    TreeItem item = (TreeItem) e.item;
                    handleTreeExpanded(item);
                    super.treeExpanded(e);
                }
            });
            updateOKStatus();
        }
    });
}
Also used : TreeEvent(org.eclipse.swt.events.TreeEvent) TreeItem(org.eclipse.swt.widgets.TreeItem) TreeAdapter(org.eclipse.swt.events.TreeAdapter)

Example 7 with TreeEvent

use of org.eclipse.swt.events.TreeEvent in project tdq-studio-se by Talend.

the class TwoPartCheckSelectionDialog method createFirstPart.

/**
 * Creates the tree viewer.
 *
 * @param parent the parent composite
 * @return the tree viewer
 */
protected CheckboxTreeViewer createFirstPart(Composite parent) {
    if (fContainerMode) {
        if (DIALOG_TYPE_TABLE == this.getDialogType()) {
            fViewer = new TableSelectionViewer(parent, SWT.BORDER);
        } else if (!this.addConnFilter) {
            fViewer = new MatchColumnSelectionViewer(parent, SWT.BORDER);
        } else {
            fViewer = new ColumnSelectionViewer(parent, SWT.BORDER);
        }
    // {
    // 
    // protected void handleTreeExpand(TreeEvent event) {
    // super.handleTreeExpand(event);
    // checkElementChecked();
    // }
    // };
    } else {
        fViewer = new CheckboxTreeViewer(parent, SWT.BORDER) {

            @Override
            protected void handleTreeExpand(TreeEvent event) {
                super.handleTreeExpand(event);
            // checkElementChecked();
            }
        };
    }
    fViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
    applyDialogFont(fViewer.getTree());
    fViewer.setContentProvider(fContentProvider);
    // mod gdbu 2011-7-25 bug 23220
    ((ResourceViewContentProvider) fContentProvider).setTreeViewer(fViewer);
    // ~23220
    fViewer.setLabelProvider(fLabelProvider);
    fViewer.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            updateOKStatus();
        }
    });
    fViewer.setComparator(fComparator);
    if (fFilters != null) {
        for (int i = 0; i != fFilters.size(); i++) {
            fViewer.addFilter(fFilters.get(i));
        }
    }
    fViewer.setInput(fInput);
    // fViewer.
    fViewer.addSelectionChangedListener(this);
    return fViewer;
}
Also used : CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) TreeEvent(org.eclipse.swt.events.TreeEvent) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) GridData(org.eclipse.swt.layout.GridData) ResourceViewContentProvider(org.talend.dataprofiler.core.ui.views.provider.ResourceViewContentProvider) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Example 8 with TreeEvent

use of org.eclipse.swt.events.TreeEvent in project BiglyBT by BiglySoftware.

the class SideBarEntrySWT method setTreeItem.

public void setTreeItem(TreeItem treeItem) {
    if (swtItem != null && treeItem != null) {
        Debug.out("Warning: Sidebar " + id + " already has a treeitem");
        return;
    }
    this.swtItem = treeItem;
    if (treeItem != null) {
        setDisposed(false);
        ImageLoader imageLoader = ImageLoader.getInstance();
        imgClose = imageLoader.getImage("image.sidebar.closeitem");
        imgCloseSelected = imageLoader.getImage("image.sidebar.closeitem-selected");
        treeItem.addDisposeListener(this);
        treeItem.getParent().addTreeListener(new TreeListener() {

            @Override
            public void treeExpanded(TreeEvent e) {
                if (e.item == swtItem) {
                    SideBarEntrySWT.super.setExpanded(true);
                }
            }

            @Override
            public void treeCollapsed(TreeEvent e) {
                if (e.item == swtItem) {
                    SideBarEntrySWT.super.setExpanded(false);
                }
            }
        });
        // Some/All OSes will auto-set treeitem's expanded flag to false if there
        // is no children.  To workaround, we store expanded state internally and
        // set parent to expanded when a child is added
        TreeItem parentItem = treeItem.getParentItem();
        if (parentItem != null) {
            MdiEntry parentEntry = (MdiEntry) parentItem.getData("MdiEntry");
            if (parentEntry.isExpanded()) {
                parentItem.setExpanded(true);
            }
        }
        setExpanded(isExpanded());
    }
    if (buildonSWTItemSet) {
        build();
    }
    if (showonSWTItemSet) {
        show();
    }
}
Also used : TreeListener(org.eclipse.swt.events.TreeListener) TreeEvent(org.eclipse.swt.events.TreeEvent) BaseMdiEntry(com.biglybt.ui.swt.mdi.BaseMdiEntry) MdiEntry(com.biglybt.ui.mdi.MdiEntry) ImageLoader(com.biglybt.ui.swt.imageloader.ImageLoader)

Example 9 with TreeEvent

use of org.eclipse.swt.events.TreeEvent in project netxms by netxms.

the class ObjectTree method enableStatusIndicator.

/**
 * @param enabled
 */
public void enableStatusIndicator(boolean enabled) {
    if (statusIndicatorEnabled == enabled)
        return;
    statusIndicatorEnabled = enabled;
    if (enabled) {
        statusIndicator = new ObjectStatusIndicator(this, SWT.NONE);
        FormData fd = new FormData();
        fd.left = new FormAttachment(0, 0);
        fd.top = filterEnabled ? new FormAttachment(filterText) : new FormAttachment(0, 0);
        fd.bottom = new FormAttachment(100, 0);
        statusIndicator.setLayoutData(fd);
        fd = (FormData) objectTree.getTree().getLayoutData();
        fd.left = new FormAttachment(statusIndicator);
        statusIndicatorSelectionListener = new SelectionListener() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                updateStatusIndicator();
            }

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
                updateStatusIndicator();
            }
        };
        objectTree.getTree().getVerticalBar().addSelectionListener(statusIndicatorSelectionListener);
        statusIndicatorTreeListener = new TreeListener() {

            @Override
            public void treeCollapsed(TreeEvent e) {
                updateStatusIndicator();
            }

            @Override
            public void treeExpanded(TreeEvent e) {
                updateStatusIndicator();
            }
        };
        objectTree.getTree().addTreeListener(statusIndicatorTreeListener);
        updateStatusIndicator();
    } else {
        objectTree.getTree().getVerticalBar().removeSelectionListener(statusIndicatorSelectionListener);
        objectTree.getTree().removeTreeListener(statusIndicatorTreeListener);
        statusIndicator.dispose();
        statusIndicator = null;
        statusIndicatorSelectionListener = null;
        statusIndicatorTreeListener = null;
        FormData fd = (FormData) objectTree.getTree().getLayoutData();
        fd.left = new FormAttachment(0, 0);
    }
    layout(true, true);
}
Also used : FormData(org.eclipse.swt.layout.FormData) TreeListener(org.eclipse.swt.events.TreeListener) TreeEvent(org.eclipse.swt.events.TreeEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 10 with TreeEvent

use of org.eclipse.swt.events.TreeEvent in project pentaho-kettle by pentaho.

the class TreeMemory method addTreeListener.

/**
 * This method creates, adds and returns a tree listener that will keep track of the expanded/collapsed state of the
 * TreeItems. This state will then be stored in the TreeMemory singleton.
 *
 * @param tree
 *          The tree to add the listener to
 * @return The created/added TreeListener
 */
public static final TreeListener addTreeListener(final Tree tree, final String treeName) {
    TreeListener treeListener = new TreeListener() {

        public void treeExpanded(TreeEvent e) {
            TreeItem treeItem = (TreeItem) e.item;
            String[] path = ConstUI.getTreeStrings(treeItem);
            TreeMemory treeMemory = TreeMemory.getInstance();
            treeMemory.storeExpanded(treeName, path, true);
        }

        public void treeCollapsed(TreeEvent e) {
            TreeItem treeItem = (TreeItem) e.item;
            String[] path = ConstUI.getTreeStrings(treeItem);
            TreeMemory treeMemory = TreeMemory.getInstance();
            treeMemory.storeExpanded(treeName, path, false);
        }
    };
    tree.addTreeListener(treeListener);
    return treeListener;
}
Also used : TreeListener(org.eclipse.swt.events.TreeListener) TreeEvent(org.eclipse.swt.events.TreeEvent) TreeItem(org.eclipse.swt.widgets.TreeItem)

Aggregations

TreeEvent (org.eclipse.swt.events.TreeEvent)18 SelectionEvent (org.eclipse.swt.events.SelectionEvent)12 TreeItem (org.eclipse.swt.widgets.TreeItem)11 TreeListener (org.eclipse.swt.events.TreeListener)9 Tree (org.eclipse.swt.widgets.Tree)9 MouseEvent (org.eclipse.swt.events.MouseEvent)8 GridData (org.eclipse.swt.layout.GridData)8 SelectionListener (org.eclipse.swt.events.SelectionListener)7 GridLayout (org.eclipse.swt.layout.GridLayout)7 Composite (org.eclipse.swt.widgets.Composite)7 TreeAdapter (org.eclipse.swt.events.TreeAdapter)6 KeyEvent (org.eclipse.swt.events.KeyEvent)5 MouseAdapter (org.eclipse.swt.events.MouseAdapter)5 Button (org.eclipse.swt.widgets.Button)5 Point (org.eclipse.swt.graphics.Point)4 DropTargetEvent (org.eclipse.swt.dnd.DropTargetEvent)3 FocusEvent (org.eclipse.swt.events.FocusEvent)3 KeyAdapter (org.eclipse.swt.events.KeyAdapter)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 Event (org.eclipse.swt.widgets.Event)3