`

import org.eclipse.jface.viewers.TreeViewer; 展开树操作

    博客分类:
  • SWT
阅读更多
import org.eclipse.jface.viewers.TreeViewer; 

public void init(){
  tree.setLabelProvider(new TreeLabelProvider1());
  tree.setContentProvider(new TreeContentProvider1());
  tree.setInput(data);
  tree.expandToLevel(2);//默认打开根目录
 }
tree.addSelectionChangedListener(new ISelectionChangedListener(){

			public void selectionChanged(SelectionChangedEvent event) {
				// TODO Auto-generated method stub
				StructuredSelection select=(StructuredSelection)event.getSelection();
				DialogRegion r = (DialogRegion)select.getFirstElement();
				text.setText(r.getRegionName());
				list.setVisible(false);
				targetregion = r;
				tree.expandToLevel(r, 2);//若为文件夹,则展开树
			}
			
		});

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics