白玉成的專欄

          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. 添加擴展點: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 白玉成 閱讀(456) 評論(0)  編輯  收藏 所屬分類: Eclipse

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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 水富县| 韩城市| 远安县| 鄯善县| 酉阳| 金溪县| 出国| 阳原县| 天等县| 青龙| 顺昌县| 汝城县| 梓潼县| 麻江县| 堆龙德庆县| 石棉县| 慈利县| 汶上县| 山阴县| 锦州市| 新蔡县| 元氏县| 腾冲县| 鄱阳县| 社会| 象州县| 托克托县| 航空| 德庆县| 呼伦贝尔市| 威远县| 库尔勒市| 台山市| 泽州县| 兰溪市| 岳普湖县| 岳西县| 会理县| 陇川县| 尼木县| 长武县|