白玉成的專欄

          Eclipse,讓我歡喜讓我憂!

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            17 隨筆 :: 0 文章 :: 6 評論 :: 0 Trackbacks
          1. 編寫自己的nature:
          package com.byc.natures;

          import org.eclipse.core.resources.IProject;
          import org.eclipse.core.resources.IProjectNature;
          import org.eclipse.core.runtime.CoreException;


          /**
           * 
           * 
          @author Bai Yucheng 2008-4-28
           * 
           
          */

          public class MyProjectNature implements IProjectNature {
           
          private IProject project;

           
          public void configure() throws CoreException {
            
          //do nothing
           }


           
          public void deconfigure() throws CoreException {
            
          //do nothing
           }


           
          public IProject getProject() {
            
          return project;
           }


           
          public void setProject(IProject iproject) {
            project 
          = iproject;
           }


          }



          2. 添加擴(kuò)展點:org.eclipse.core.resources.natures,設(shè)置class屬性為我們的nature

          <extension
                
          id="com.byc.MyProjectNature"
                name
          ="Project Nature"
                point
          ="org.eclipse.core.resources.natures">
             
          <runtime>
                
          <run
                      
          class="com.byc.natures.MyProjectNature">
                
          </run>
             
          </runtime>
          </extension>


          3. 在新建工程的向?qū)е刑砑游覀兊膎ature,添加方法為:

          private void addProjectNature(IProject project) throws CoreException {
             
          if (!project.hasNature(PROJECT_NATURE)) {
             
          try {
              IProjectDescription description 
          = project.getDescription();
              String[] natures 
          = description.getNatureIds();
              String[] newNatures 
          = new String[natures.length + 1];
              System.arraycopy(natures, 
          0, newNatures, 0, natures.length);
              newNatures[natures.length] 
          = PROJECT_NATURE;
              description.setNatureIds(newNatures);
              project.setDescription(description, 
          null);
             }
           catch (CoreException e) {
              e.printStackTrace();
             }

            }

           }
          posted on 2008-11-25 22:57 白玉成 閱讀(451) 評論(0)  編輯  收藏 所屬分類: Eclipse

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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 黄浦区| 比如县| 榆中县| 东城区| 古田县| 长沙县| 永清县| 西华县| 开江县| 保靖县| 随州市| 望奎县| 关岭| 白水县| 厦门市| 罗源县| 六盘水市| 射洪县| 介休市| 德州市| 和硕县| 株洲市| 渭源县| 本溪市| 天峨县| 安宁市| 卓尼县| 台东县| 永泰县| 商河县| 吴川市| 谢通门县| 蓝山县| 驻马店市| 曲麻莱县| 抚顺市| 曲沃县| 佛学| 天水市| 普宁市| 木兰县|