treeViewer.setInput(ResourcesPlugin.getWorkspace()); }
public void selectionChanged( SelectionChangedEvent event ) { IStructuredSelection selection = (IStructuredSelection) event .getSelection( ); containerSelectionChanged( (IContainer) selection .getFirstElement( ) ); } } ); treeViewer.addDoubleClickListener( new IDoubleClickListener( ) {  public void doubleClick( DoubleClickEvent event ) { ISelection selection = event.getSelection( ); if ( selection instanceof IStructuredSelection ) { Object item = ( (IStructuredSelection) selection ) .getFirstElement( ); if ( treeViewer.getExpandedState( item ) ) treeViewer.collapseToLevel( item, 1 ); else treeViewer.expandToLevel( item, 1 ); } } } );   treeViewer.setInput( ResourcesPlugin.getWorkspace( ) ); }
    protected void createTreeViewer(int heightHint) {        // Create drill down.        DrillDownComposite drillDown = new DrillDownComposite(this, SWT.BORDER);        GridData spec = new GridData(SWT.FILL, SWT.FILL, true, true);        spec.widthHint = SIZING_SELECTION_PANE_WIDTH;        spec.heightHint = heightHint;        drillDown.setLayoutData(spec);        // Create tree viewer inside drill down.        treeViewer = new TreeViewer(drillDown, SWT.NONE);        drillDown.setChildTree(treeViewer);        ContainerContentProvider cp = new ContainerContentProvider();        cp.showClosedProjects(showClosedProjects);        treeViewer.setContentProvider(cp);        treeViewer.setLabelProvider(WorkbenchLabelProvider                .getDecoratingWorkbenchLabelProvider());        treeViewer.setSorter(new ViewerSorter());        treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {            public void selectionChanged(SelectionChangedEvent event) {                IStructuredSelection selection = (IStructuredSelection) event                        .getSelection();                containerSelectionChanged((IContainer) selection                        .getFirstElement()); // allow null            }        });        treeViewer.addDoubleClickListener(new IDoubleClickListener() {            public void doubleClick(DoubleClickEvent event) {                ISelection selection = event.getSelection();                if (selection instanceof IStructuredSelection) {                    Object item = ((IStructuredSelection) selection)                            .getFirstElement();                    if (treeViewer.getExpandedState(item))                        treeViewer.collapseToLevel(item, 1);                    else                        treeViewer.expandToLevel(item, 1);                }            }        });        // This has to be done after the viewer has been laid out        treeViewer.setInput(ResourcesPlugin.getWorkspace());    }