白玉成的專欄

          Eclipse,讓我歡喜讓我憂!

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            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,設置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. 在新建工程的向導中添加我們的nature,添加方法為:

          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

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


          網站導航:
           
          主站蜘蛛池模板: 宝鸡市| 保德县| 拉孜县| 紫阳县| 华池县| 涟水县| 邳州市| 上思县| 如东县| 颍上县| 翁源县| 乐亭县| 定襄县| 台湾省| 张家口市| 宣城市| 和龙市| 延长县| 临邑县| 思南县| 全州县| 湘潭县| 普兰店市| 古交市| 新田县| 牙克石市| 江口县| 霞浦县| 班玛县| 淮滨县| 高尔夫| 邵武市| 区。| 苏尼特右旗| 新绛县| 吉首市| 安仁县| 贵阳市| 兴仁县| 库车县| 内丘县|