Search in sources :

Example 1 with DataAndImageTreeNodeContentProvider

use of org.python.pydev.shared_ui.quick_outline.DataAndImageTreeNodeContentProvider in project Pydev by fabioz.

the class HierarchyViewer method createPartControl.

public void createPartControl(Composite parent) {
    this.fParent = parent;
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    layout.verticalSpacing = 2;
    layout.marginWidth = 0;
    layout.marginHeight = 2;
    parent.setLayout(layout);
    sash = new SashForm(parent, SWT.VERTICAL);
    GridData layoutData = new GridData();
    layoutData.grabExcessHorizontalSpace = true;
    layoutData.grabExcessVerticalSpace = true;
    layoutData.horizontalAlignment = GridData.FILL;
    layoutData.verticalAlignment = GridData.FILL;
    sash.setLayoutData(layoutData);
    parent = sash;
    treeClassesViewer = new TreeViewer(parent);
    treeClassesViewer.setContentProvider(new DataAndImageTreeNodeContentProvider());
    treeClassesViewer.setLabelProvider(createLabelProvider());
    treeClassesViewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            ISelection selection = event.getSelection();
            handleSelection(selection, 2);
        }
    });
    treeClassesViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            handleSelection(selection, 1);
        }
    });
    treeMembers = new Tree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    treeMembers.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(MouseEvent e) {
            TreeItem[] selection = treeMembers.getSelection();
            if (selection.length > 0) {
                Object data = selection[0].getData();
                ItemPointer p = (ItemPointer) data;
                if (p != null) {
                    new PyOpenAction().run(p);
                }
            }
        }
    });
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) TreeViewer(org.eclipse.jface.viewers.TreeViewer) PyOpenAction(org.python.pydev.editor.actions.PyOpenAction) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) MouseAdapter(org.eclipse.swt.events.MouseAdapter) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DataAndImageTreeNodeContentProvider(org.python.pydev.shared_ui.quick_outline.DataAndImageTreeNodeContentProvider) SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) ISelection(org.eclipse.jface.viewers.ISelection) Tree(org.eclipse.swt.widgets.Tree) ItemPointer(org.python.pydev.ast.item_pointer.ItemPointer)

Aggregations

DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)1 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)1 ISelection (org.eclipse.jface.viewers.ISelection)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 SashForm (org.eclipse.swt.custom.SashForm)1 MouseAdapter (org.eclipse.swt.events.MouseAdapter)1 MouseEvent (org.eclipse.swt.events.MouseEvent)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Tree (org.eclipse.swt.widgets.Tree)1 ItemPointer (org.python.pydev.ast.item_pointer.ItemPointer)1 PyOpenAction (org.python.pydev.editor.actions.PyOpenAction)1 DataAndImageTreeNodeContentProvider (org.python.pydev.shared_ui.quick_outline.DataAndImageTreeNodeContentProvider)1