Package org.eclipse.jface.viewers

Examples of org.eclipse.jface.viewers.TreeViewer


     */
    public void createControl( Composite parent )
    {
        super.createControl( parent );

        final TreeViewer treeViewer = getTreeViewer();
        treeViewer.setLabelProvider( new LdifLabelProvider() );
        treeViewer.setContentProvider( new LdifContentProvider() );
        // treeViewer.setAutoExpandLevel(1);

        treeViewer.addSelectionChangedListener( new ISelectionChangedListener()
        {
            public void selectionChanged( SelectionChangedEvent event )
            {
                if ( !event.getSelection().isEmpty() && event.getSelection() instanceof IStructuredSelection )
                {
                    Object element = ( ( IStructuredSelection ) event.getSelection() ).getFirstElement();

                    if ( element instanceof LdifRecord )
                    {
                        LdifRecord ldifRecord = ( LdifRecord ) element;
                        ldifEditor.selectAndReveal( ldifRecord.getDnLine().getOffset(), ldifRecord.getDnLine()
                            .getLength() );
                    }
                    else if ( element instanceof List )
                    {
                        List list = ( List ) element;
                        if ( !list.isEmpty() && list.get( 0 ) instanceof LdifAttrValLine )
                        {
                            LdifAttrValLine line = ( LdifAttrValLine ) list.get( 0 );
                            ldifEditor.selectAndReveal( line.getOffset(), line.getRawAttributeDescription().length() );
                        }
                    }
                    else if ( element instanceof LdifAttrValLine )
                    {
                        LdifAttrValLine line = ( LdifAttrValLine ) element;
                        ldifEditor.selectAndReveal( line.getOffset() + line.getRawAttributeDescription().length()
                            + line.getRawValueType().length(), line.getRawValue().length() );
                    }
                    else if ( element instanceof LdifModSpec )
                    {
                        LdifModSpec modSpec = ( LdifModSpec ) element;
                        ldifEditor.selectAndReveal( modSpec.getOffset(), modSpec.getModSpecType().getLength() );
                    }
                }
            }
        } );

        treeViewer.addDoubleClickListener( new IDoubleClickListener()
        {
            public void doubleClick( DoubleClickEvent event )
            {
                if ( event.getSelection() instanceof IStructuredSelection )
                {
                    Object obj = ( ( IStructuredSelection ) event.getSelection() ).getFirstElement();
                    if ( treeViewer.getExpandedState( obj ) )
                        treeViewer.collapseToLevel( obj, 1 );
                    else if ( ( ( ITreeContentProvider ) treeViewer.getContentProvider() ).hasChildren( obj ) )
                        treeViewer.expandToLevel( obj, 1 );
                }
            }
        } );

        this.refresh();
View Full Code Here


     * @param element
     *      the element
     */
    public void refresh( Object element )
    {
        final TreeViewer treeViewer = getTreeViewer();
        if ( treeViewer != null && treeViewer.getTree() != null && !treeViewer.getTree().isDisposed() )
        {
            treeViewer.refresh( element );
        }
    }
View Full Code Here

    /**
     * Refreshes this viewer completely with information freshly obtained from this viewer's model.
     */
    public void refresh()
    {
        final TreeViewer treeViewer = getTreeViewer();

        if ( treeViewer != null && treeViewer.getTree() != null && !treeViewer.getTree().isDisposed() )
        {
            // ISelection selection = treeViewer.getSelection();
            // Object[] expandedElements = treeViewer.getExpandedElements();

            if ( !treeViewer.getTree().isEnabled() )
            {
                treeViewer.getTree().setEnabled( true );
            }

            if ( ldifEditor != null )
            {
                if ( treeViewer.getInput() != ldifEditor.getLdifModel() )
                {
                    treeViewer.setInput( ldifEditor.getLdifModel() );
                }
            }

            treeViewer.refresh();

            // treeViewer.setSelection(selection);
            // treeViewer.setExpandedElements(expandedElements);
        }
    }
View Full Code Here

    }
    @Override
    protected Control createDialogArea( Composite parent ) {
        Composite composite = (Composite) super.createDialogArea(parent);
        org.eclipse.swt.widgets.Tree tree=new org.eclipse.swt.widgets.Tree(composite, SWT.V_SCROLL|SWT.MULTI);
        viewer = new TreeViewer(tree);

        GridData gridData = new GridData(GridData.FILL_BOTH);
        gridData.heightHint=SWT.DEFAULT;
        gridData.widthHint=SWT.DEFAULT;
        gridData.verticalSpan=4;
View Full Code Here

    private IAction deleteAction;
    private IAction refreshAction;
    private boolean drools4 = false;

    protected Viewer createViewer(Composite parent) {
        final TreeViewer variablesViewer = new TreeViewer(parent);
        variablesViewer.setContentProvider(new AuditViewContentProvider());
        variablesViewer.setLabelProvider(new AuditLabelProvider());
        variablesViewer.setUseHashlookup(true);
        variablesViewer.addSelectionChangedListener(new ISelectionChangedListener() {
            public void selectionChanged(SelectionChangedEvent event) {
                getViewer().refresh();
            }
        });
       
        int ops = DND.DROP_COPY | DND.DROP_MOVE;
        Transfer[] transfers = new Transfer[] { FileTransfer.getInstance()};
        variablesViewer.addDropSupport(ops, transfers, new FileAuditDropAdapter(variablesViewer,this));
       
        return variablesViewer;
    }
View Full Code Here

    private Map resourcesMap = new HashMap();
    private TreeViewer treeViewer;

    public void createPartControl(Composite parent) {
        treeViewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
        treeViewer.setContentProvider(new DroolsContentProvider());
        treeViewer.setLabelProvider(new DroolsLabelProvider());
        treeViewer.setSorter(new DroolsTreeSorter());
        treeViewer.addDoubleClickListener(this);
        treeViewer.setUseHashlookup(true);
View Full Code Here

            ((TreeViewer) getViewer()).expandToLevel(getAutoExpandLevel());
        }
    }

    protected Viewer createViewer(Composite parent) {
        TreeViewer variablesViewer = new TreeViewer(parent);
        variablesViewer.setContentProvider(createContentProvider());
        variablesViewer.setLabelProvider(new VariablesViewLabelProvider(
            getModelPresentation()));
        variablesViewer.setUseHashlookup(true);
        DebugContextManager.getDefault().addDebugContextListener(this);
        getSite().getPage().addSelectionListener(IDebugUIConstants.ID_VARIABLE_VIEW, this);
        return variablesViewer;
    }
View Full Code Here

    private IAction deleteAction;
    private IAction refreshAction;
    private boolean drools4 = false;

    protected Viewer createViewer(Composite parent) {
        final TreeViewer variablesViewer = new TreeViewer(parent);
        variablesViewer.setContentProvider(new AuditViewContentProvider());
        variablesViewer.setLabelProvider(new AuditLabelProvider());
        variablesViewer.setUseHashlookup(true);
        variablesViewer.addSelectionChangedListener(new ISelectionChangedListener() {
            public void selectionChanged(SelectionChangedEvent event) {
                getViewer().refresh();
            }
        });
       
        int ops = DND.DROP_COPY | DND.DROP_MOVE;
        Transfer[] transfers = new Transfer[] { FileTransfer.getInstance()};
        variablesViewer.addDropSupport(ops, transfers, new FileAuditDropAdapter(variablesViewer,this));
       
        return variablesViewer;
    }
View Full Code Here

            ((TreeViewer) getViewer()).expandToLevel(getAutoExpandLevel());
        }
    }

    protected Viewer createViewer(Composite parent) {
        TreeViewer variablesViewer = new TreeViewer(parent);
        variablesViewer.setContentProvider(createContentProvider());
        variablesViewer.setLabelProvider(new VariablesViewLabelProvider(
            getModelPresentation()));
        variablesViewer.setUseHashlookup(true);
        DebugContextManager.getDefault().addDebugContextListener(this);
        getSite().getPage().addSelectionListener(IDebugUIConstants.ID_VARIABLE_VIEW, this);
        return variablesViewer;
    }
View Full Code Here

    private Map<IFile, List<DroolsElement>> resourcesMap = new HashMap<IFile, List<DroolsElement>>();
    private TreeViewer treeViewer;

    public void createPartControl(Composite parent) {
        treeViewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
        treeViewer.setContentProvider(new DroolsContentProvider());
        treeViewer.setLabelProvider(new DroolsLabelProvider());
        treeViewer.setSorter(new DroolsTreeSorter());
        treeViewer.addDoubleClickListener(this);
        treeViewer.setUseHashlookup(true);
View Full Code Here

TOP

Related Classes of org.eclipse.jface.viewers.TreeViewer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.