简单eclipse插件开发: eclipse启动时间显示器

Eclipse插件开发shell

1. 下载并安装jdk和eclipse
   这里强调一下: 须要下载Eclipse for RCP and RAP Developers, 不然没法新建Plug-in Development 项目.
2. 新建项目
   安装好以后打开eclipse, 点击 File->NewProject。选择Plug-in Project,点击Next。新建一个名为com.developer.showtime的项目,全部参数采用默认值.eclipse

3. 在com.developer.showtime项目的src下新建一个类: ShowTime,代码以下:ui

  

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文件以下:orm

 

<?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>xml

5. 试运行ip

右键点击Run as -> Eclipse Application. 此时会运行一个eclipse, 启动以后就能显示启动所需时间.开发

6. 导出插件.get

右键Export -> Deployable plug-ins and fragments. 在Directory中输入须要导出的路径, 点击finish后会在该目录下产生一个plugins的目录, 里面就是插件包: com.developer.showTime_1.0.0.201110161216.jar. 把这个包复制到eclipse目录下的plugin目录下. 而后再启动eclipse 即可以看到eclipse启动所花的时间.io

相关文章
相关标签/搜索