我现在想实现向eclipse 3.4中的那个功能,就是window-->show view -->other..,然后点击对应 的视图的名字
可以显示对应的视图的,
代码片段如下:
ApplicationActionBarAdvisor.java
public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
private IWorkbenchAction otherAction;
protected void makeActions(IWorkbenchWindow window) {
otherAction = (IWorkbenchAction) new OtherAction(window);
otherAction.setText("other");
}
protected void fillMenuBar(IMenuManager menuBar) {
MenuManager menubj = new MenuManager("编辑(E)" , "menubj");
menubj.add(otherAction);
}
}
对应 的Action(OtherAction)类
public class OtherAction extends Action implements IWorkbenchAction {
private IWorkbenchWindow window ;
public OtherAction (IWorkbenchWindow window){
if(window == null){
throw new IllegalArgumentException();
}
this.window = window;
}
@Override
public void run() {
if(null != window){
try {
Others other = new Others(window.getShell());
other.open();
//可以显示相应的树的,这个以经实现的,
} catch (PartInitException ee) {
// TODO Auto-generated catch block
ee.printStackTrace();
}
}
}
@Override
public void dispose() {
// TODO Auto-generated method stub
window = null ;
}
}
Others .java 片段
public class Others extends Dialog{
protected Control createDialogArea(Composite parent) {
Composite container = (Composite) super.createDialogArea(parent);
{
TreeViewer treeViewer = new TreeViewer(container, SWT.BORDER|SWT.H_SCROLL);
Tree tree = treeViewer.getTree();
tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
//TreeColumn column = new TreeColumn(tree, SWT.NONE);
treeViewer.setLabelProvider(new TreeLabelProvider());
treeViewer.setContentProvider(new TreeContentProvider());
treeViewer.setInput(Factory.createTree());
//可以显示相应的树视图的,现在的问题就是不知道该怎么写事件,根据不同的树子节点显示不同的视图,
}
return container;
}
}
@Override
protected void createButtonsForButtonBar(Composite parent) {
createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,
true);
createButton(parent, IDialogConstants.CANCEL_ID,
IDialogConstants.CANCEL_LABEL, false);
}
还请老大们指点一二,小弟先谢谢了,其实我是个新手,很多东西都不是很懂的,还请大家帮帮忙呀!谢谢了!!!!!!!!!!