treeViewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event) { IStructuredSelection is = (IStructuredSelection)event.getSelection(); Object obj = is.getFirstElement(); //自定義的節點對象 Node node = (Node)obj; TreeItem[] items = treeViewer.getTree().getSelection(); if(null == items || items.length == 0){ return; } if(items[0].getExpanded()){ items[0].setExpanded(false); }else{ //從選中的節點處展開 treeViewer.expandToLevel(node, 1); } } });