posts - 28, comments - 37, trackbacks - 0, articles - 0

          Eclipse插件開發

          1. 下載并安裝jdkeclipse
            
          這里強調一下: 需要下載Eclipse for RCP and RAP Developers, 否則無法新建Plug-in Development 項目.
          2.
          新建項目
            
          安裝好之后打開eclipse, 點擊 File->NewProject。選擇Plug-in Project,點擊Next。新建一個名為com.developer.showtime的項目,所有參數采用默認值.

          3. com.developer.showtime項目的src下新建一個類: ShowTime,代碼如下:

           

          package com.developer.showtime;

          import org.eclipse.jface.dialogs.MessageDialog;
          import org.eclipse.swt.widgets.Display;
          import org.eclipse.swt.widgets.Shell;
          import org.eclipse.ui.IStartup;

          public class ShowTime implements IStartup {
              
          public void earlyStartup() {
                  Display.getDefault().syncExec(
          new Runnable() {
                      
          public void run(){
                          
          long eclipseStartTime = Long.parseLong(System.getProperty("eclipse.startTime"));
                          
          long costTime = System.currentTimeMillis() - eclipseStartTime;
                          Shell shell 
          = Display.getDefault().getActiveShell();
                          String message 
          = "Eclipse start in " + costTime + "ms";
                          MessageDialog.openInformation(shell, 
          "Information", message);
                      }
                  });
              }
          }

          4. 修改plugin.xml文件如下:


          <?xml version="1.0" encoding="UTF-8"?>

          <?eclipse version="3.4"?>

          <plugin>
             
          <extension

                   point
          ="org.eclipse.ui.startup">

                   
          <startup class="com.developer.showtime.ShowTime"/>

             
          </extension>

          </plugin>

          5. 試運行

          右鍵點擊Run as -> Eclipse Application. 此時會運行一個eclipse, 啟動之后就能顯示啟動所需時間.

          6. 導出插件.

          右鍵Export -> Deployable plug-ins and fragments. Directory中輸入需要導出的路徑, 點擊finish后會在該目錄下產生一個plugins的目錄, 里面就是插件包: com.developer.showTime_1.0.0.201110161216.jar. 把這個包復制到eclipse目錄下的plugin目錄下. 然后再啟動eclipse 便可以看到eclipse啟動所花的時間.

          Feedback

          # re: 簡單eclipse插件開發: eclipse啟動時間顯示器[未登錄]  回復  更多評論   

          2016-03-27 21:48 by 啊啊
          瀟灑瀟灑

          # re: 簡單eclipse插件開發: eclipse啟動時間顯示器  回復  更多評論   

          2016-05-26 20:30 by 孟翔
          在哪里有plugin.xml???????

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


          網站導航:
           
          主站蜘蛛池模板: 黄冈市| 科尔| 临沧市| 云和县| 于都县| 剑阁县| 芦溪县| 英德市| 格尔木市| 鄂托克旗| 桂东县| 雅安市| 乌拉特后旗| 察哈| 阿勒泰市| 本溪| 元阳县| 慈利县| 泰宁县| 邵武市| 天镇县| 天全县| 兰溪市| 建水县| 兴国县| 洛扎县| 阿拉善盟| 遵化市| 浏阳市| 集安市| 泸西县| 花莲县| 金乡县| 博客| 遂川县| 韶山市| 水富县| 绿春县| 弥勒县| 宣威市| 拜城县|