嘟嘟

            BlogJava :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
            26 Posts :: 0 Stories :: 6 Comments :: 0 Trackbacks

          1: 建立plugin project, (加入org.eclipse.gef)
          2: 編輯plugin.xml, 設(shè)置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類)
             建立各個相關(guān)action類(菜單項界面顯示)
            有些action是直接調(diào)用得,如下
            IWorkbenchAction exitAction exitAction = ActionFactory.QUIT.create(window);
               register(exitAction);
            IWorkbenchAction aboutAction = ActionFactory.ABOUT.create(window);
               register(aboutAction);
          5: 建立editorinput類
          6: 在action得run函數(shù)中處理點擊事件
              建立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中設(shè)置editor可視
               public void createInitialLayout(IPageLayout layout) {
                  layout.setEditorAreaVisible(true);
                 }
          8: 在DiagramEditor中設(shè)置DefaultEditDomain
              public DiagramEditor() {
                  setEditDomain(new DefaultEditDomain(this));
              }

          在plugin.xml得overview頁面點擊"launce an eclipase application",可以進行測試

          簡單例子代碼: 下載

          posted on 2007-05-09 13:46 fyp1210 閱讀(451) 評論(0)  編輯  收藏 所屬分類: GEF

          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 游戏| 晴隆县| 南开区| 阳城县| 鸡东县| 略阳县| 博湖县| 原阳县| 襄汾县| 北碚区| 炉霍县| 扶沟县| 云浮市| 咸阳市| 迁西县| 嵊泗县| 宁津县| 郧西县| 大邑县| 广丰县| 开平市| 浮山县| 江油市| 栖霞市| 乌审旗| 五峰| 古蔺县| 景东| 靖西县| 枝江市| 西乡县| 兴国县| 钦州市| 松江区| 青神县| 峨眉山市| 玛曲县| 农安县| 丰城市| 全椒县| 万盛区|