白玉成的專欄

          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)航:
           
          主站蜘蛛池模板: 台东市| 唐山市| 六安市| 临清市| 馆陶县| 兴业县| 太白县| 富宁县| 介休市| 绿春县| 尉犁县| 东海县| 宁国市| 洞头县| 潜山县| 鄱阳县| 大洼县| 应城市| 安福县| 平顶山市| 金昌市| 蕉岭县| 唐河县| 大余县| 伊通| 普格县| 新干县| 崇信县| 肇庆市| 青浦区| 田东县| 莎车县| 怀化市| 马龙县| 河北省| 伊金霍洛旗| 河东区| 辉南县| 民勤县| 古交市| 江西省|