eclipse启动时间插件

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启动所花的时间.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值