1.Editor
【注】1.Editor页面需要接口IEditorInput 并将getName() 和 getToolTipText()返回值改为”“
1>打开editor同时关闭View
//获取page(页面)对象
try {
IWorkbenchPage page = MainView.this.getViewSite().getPage();
//实例化编辑视图
Cc ccEditor = new Cc();
//判断当前目标editor是否有被打开过
IEditorPart part = page.findEditor(ccEditor);
if(part!=null){
//如果已存在,则放到最顶层
page.bringToTop(part);
}else{
//如果不存在,则打开
System.out.println(Cc.ID+"---------");
page.openEditor(ccEditor, Cc.ID);
}
} catch (Exception e2) {
e2.printStackTrace();
}
2.Dialog
Dd dd = new Dd(new Shell(), SWT.APPLICATION_MODAL|SWT.CLOSE);
HashMap<String, String> map1 = (HashMap<String, String>) dd.open(map);
【注】1.需要修改Dialog open() 函数里的参数才能接受值
2.只有当Dialog关闭时才能接受返回值result
3.result返回值自己给定,返回时时object型,需要转数据类型
Error
1.!ENTRY org.eclipse.ui 4 0 2017-09-12 19:28:27.723
!MESSAGE Unable to create editor ID com.hzyc.aa.editor.Cc: Editor initialization failed: com.hzyc.aa.editor.Cc. Site is incorrect.
【问题】编辑器初始化失败-- 网站是不正确的
【解决】在editor页面添加【1】【2】初始化代码
public void init(IEditorSite site, IEditorInput input)
throws PartInitException {
// Initialize the editor part
this.setSite(site);//【1】
this.setInput(input);//【2】
}