嘟嘟

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  26 Posts :: 0 Stories :: 6 Comments :: 0 Trackbacks

1: 建立plugin project, (加入org.eclipse.gef)
2: 编辑plugin.xml, 设置editor
    <extension
         point="org.eclipse.ui.editors">
      <editor
         id="gef.tutorial.step.ui.DiagramEditor"
         name="Diagram Editor"
         icon="icons/alt_window_32.gif"
         class="gef.tutorial.step.ui.DiagramEditor"
         default="false">
      </editor>
   </extension>
3:建立editor类
   public class DiagramEditor extends GraphicalEditor {

       public static final String ID = "gef.tutorial.step.ui.DiagramEditor";
       .....}
4: 在ApplicationActionBarAdvisor中加入菜单和菜单项(Action类)
   建立各个相关action类(菜单项界面显示)
  有些action是直接调用得,如下
  IWorkbenchAction exitAction exitAction = ActionFactory.QUIT.create(window);
     register(exitAction);
  IWorkbenchAction aboutAction = ActionFactory.ABOUT.create(window);
     register(aboutAction);
5: 建立editorinput类
6: 在action得run函数中处理点击事件
    建立editorinput实例,打开editor
     public void run() {
        String path = openFileDialog();
        if (path != null) {
         IEditorInput input = new DiagramEditorInput(new Path(path));
         IWorkbenchPage page = window.getActivePage();
         try {
             page.openEditor(input, DiagramEditor.ID, true);
             } catch (PartInitException e) {
             // TODO Auto-generated catch block
               e.printStackTrace();
               }
           }
         }
7: 在Perspective中设置editor可视
     public void createInitialLayout(IPageLayout layout) {
        layout.setEditorAreaVisible(true);
       }
8: 在DiagramEditor中设置DefaultEditDomain
    public DiagramEditor() {
        setEditDomain(new DefaultEditDomain(this));
    }

在plugin.xml得overview页面点击"launce an eclipase application",可以进行测试

简单例子代码: 下载

posted on 2007-05-09 13:46 fyp1210 阅读(424) 评论(0)  编辑  收藏 所属分类: GEF

只有注册用户登录后才能发表评论。


网站导航: