JFace 的treeViewer的双击展开或收缩

13年前
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);     }            }  });