editor

editor的属性:
extensions:文件扩展名,逗号分隔;class实现org.eclipse.ui.IeditorPart的类名;launcher:实现org.eclipse.ui.IeditorLauncher的类名,打开外部编辑器;command启动外部编辑器的命令,可执行命令必须位于系统路径或者是插件目录,class、command、launcher互斥。contributionClass:只有定义了class才定义此属性,用于将action添加至工作台的菜单和工具栏。

editor需要主动打开,例如在一个treeView添加了一个事件用于打开一个editor:
treeViewer.addDoubleClickListener(new IDoubleClickListener(){
  @Override
  public void doubleClick(DoubleClickEvent event) {
     IStructuredSelection selection=(IStructuredSelection) event.getSelection();
     EntityElement element=(EntityElement) selection.getFirstElement();
     IEditorInput editorInput=element.getEditorInput();//获取IEditorInput
     String string=editorInput.getName();
     if(editorInput.getName().equals("员工档案"))
      {
      IWorkbenchPage workbenchPage=getViewSite().getPage();
      IEditorPart editorPart=workbenchPage.findEditor(editorInput);
      String editorId="hoodman.editor1";
        if(editorPart!=null)
         {
            workbenchPage.bringToTop(editorPart);//若果已经打开则将editor置为当前
          }
          else {
            try {
            editorPart=workbenchPage.openEditor(editorInput, editorId);
             } catch (PartInitException e) {
e.printStackTrace();
 }
 }
}              
 }
});

editor需要一个 IEditorInput对象,需要自己定义:
public class MyEditorInput implements IEditorInput {
@Override
    public String getName() {
        // TODO Auto-generated method stub
        return "员工档案";
    }
@Override
    public String getToolTipText() {
        // TODO Auto-generated method stub
        return "员工档案/员工管理!";
    }
...
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值