白玉成的專欄

          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 白玉成 閱讀(451) 評論(0)  編輯  收藏 所屬分類: Eclipse

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


          網站導航:
           
          主站蜘蛛池模板: 金川县| 方城县| 白银市| 定边县| 三门县| 文登市| 宜兰县| 通河县| 汤阴县| 鸡西市| 图们市| 容城县| 留坝县| 孟州市| 清徐县| 佛坪县| 平舆县| 巍山| 汝州市| 曲麻莱县| 南昌县| 黔江区| 铁岭市| 平邑县| 迁安市| 启东市| 岳阳县| 平罗县| 崇文区| 莲花县| 辉县市| 湘潭县| 简阳市| 冕宁县| 卓尼县| 合作市| 化州市| 纳雍县| 济阳县| 四子王旗| 建阳市|