我们先准备好一张要做成闪屏的图片,将图片直接复制到工程目录中去,注意图片名称最好改成splash.bmp,这样方便点,文件机构下图所示,
这时如果启动的话发现闪屏根本不会显示,因为我们没有给项目指定闪屏的位置,这时我们要给这个项目新增一个*.product 文件,文件名称任意取
我们选择创建一个基本的配置文件,点完成,然后可以配置文件的属性了,接下来我们指定 Product ID:
然后再切换到 Splash 标签页,我们在这里要指定闪屏所在的插件
这样就给插件加上闪屏了,保存文件,启动看看,
这就是我们的启动闪屏了,很酷吧,其实我们可以通过更简单的方法给项目加闪屏,那就是新建的时候选择有闪屏的模板,像"RCP application whit an intro" 和 "RCP Mail Template",这两个插件模板直接附带了闪屏,如果想将闪屏替换为自己的图片替换自带的 splash.bmp 文件即可
如果想像Eclipse那样启动时有进度栏显示的话,我们可以按照一下步骤来完成
我们要在 plugin.xml 文件的 "Extensions"标签页中新增名称为 "org.eclipse.core.runtime.products" 的扩展点,然后添加相应的属性, 方法如下,选中"org.eclipse.core.runtime.products",右键选择 "product(产品)" ,
然后在右边的扩展元素细节中填入相应的信息,比如我们在这里的application属性 为 org.vwpolo.rcp.example.application,name 属性为org.vwpolo.rcp.example,然后再在这个 product 上右键新增属性,我们要新增以下属性
Name: appName Value:欢迎使用RCP程序 Name:startupForegroupColor Value:000000 Name:preferenceCustomization Value:plugin_customization.ini Name:startupMessageRect Value:10,270,300,16 Name:startupProgressRect Value:10,250,300,16 |
说明: appName为应用程序的名称,就是显示在标题栏的名字
startupForegroupColor 为应用程序启动时候的前景色
preferenceCustomization 为应用程序启动配置的属性文件,文件作用等下做解释
startupMessageRect 为当闪屏启动时闪屏上显示文字的坐标
startupProgressRect 为闪屏上的进度条显示坐标
这时如果我们启动应用程序发现还是没有进度条的显示,这时我们要新增一个plugin_customization.ini文件,也就是上面说的应用程序启动配置的属性文件,文件的内容为:
org.eclipse.ui/SHOW_PROGRESS_ON_STARTUP=true org.eclipse.ui/SHOW_TRADITIONAL_STYLE_TABS=false org.eclipse.ui/DOCK_PERSPECTIVE_BAR=topRight |
第一行设置是否显示进度栏,默认是不显示的
第二行设置视图样式是否显示波浪样式的
第三行设置透视图工具栏显示在右上方
这时如果我们启动RCP程序的话就可以看到启动栏了
这里的显示坐标可以自己调节
这是plugin.xml文件
<?eclipse version="3.2"?>
<plugin>
< extension
id="application"
point ="org.eclipse.core.runtime.applications">
<application>
< run
class="org.vwpolo.rcp.example.Application">
</run>
</application>
</extension>
< extension
point="org.eclipse.ui.perspectives">
< perspective
name="RCP Perspective"
class ="org.vwpolo.rcp.example.Perspective"
id ="org.vwpolo.rcp.example.perspective">
</perspective>
</extension>
< extension
id="product"
point ="org.eclipse.core.runtime.products">
< product
application="org.vwpolo.rcp.example.application"
name ="org.vwpolo.rcp.example">
< property
name="appName"
value ="欢迎使用RCP程序">
</property>
< property
name="preferenceCustomization"
value ="plugin_customization.ini">
</property>
< property
name="startupMessageRect"
value ="10,270,300,16">
</property>
< property
name="startupForegroundColor"
value ="000000">
</property>
< property
name="startupProgressRect"
value ="10,250,300,16">
</property>
</product>
</extension>
< extension
point="org.eclipse.core.runtime.products">
< product
application="org.vwpolo.rcp.example.application"
name ="org.vwpolo.rcp.example">
</product>
</extension>
</plugin>
其实我们还有一种方法可以指定闪屏的位置,那就是在程序打包之后的的主文件的configuration 文件夹中的 config.ini 文件,
原来文件内容为
#Product Runtime Configuration File osgi.splashPath=platform:/base/plugins/org.vwpolo.rcp.example eclipse.product=org.vwpolo.rcp.example.product osgi.bundles=org.eclipse.equinox.common@2:start,org.eclipse.core.runtime@start,com.ibm.icu,javax.servlet,org.eclipse.core.commands,org.eclipse.core.contenttype,org.eclipse.core.databinding,org.eclipse.core.expressions,org.eclipse.core.jobs,org.eclipse.core.runtime.compatibility.auth,org.eclipse.core.runtime.compatibility.registry,org.eclipse.equinox.app,org.eclipse.equinox.preferences,org.eclipse.equinox.registry,org.eclipse.help,org.eclipse.jface,org.eclipse.jface.databinding,org.eclipse.osgi.services,org.eclipse.swt,org.eclipse.swt.win32.win32.x86,org.eclipse.ui,org.eclipse.ui.workbench,org.vwpolo.rcp.example,org.eclipse.equinox.launcher,org.eclipse.equinox.launcher.win32.win32.x86 osgi.bundles.defaultStartLevel=4 |
现在改成
#Product Runtime Configuration File osgi.splashPath=platform:/base/plugins/org.vwpolo.rcp.example osgi.splashLocation=C:/splash.bmp eclipse.product=org.vwpolo.rcp.example.product osgi.bundles=org.eclipse.equinox.common@2:start,org.eclipse.core.runtime@start,com.ibm.icu,javax.servlet,org.eclipse.core.commands,org.eclipse.core.contenttype,org.eclipse.core.databinding,org.eclipse.core.expressions,org.eclipse.core.jobs,org.eclipse.core.runtime.compatibility.auth,org.eclipse.core.runtime.compatibility.registry,org.eclipse.equinox.app,org.eclipse.equinox.preferences,org.eclipse.equinox.registry,org.eclipse.help,org.eclipse.jface,org.eclipse.jface.databinding,org.eclipse.osgi.services,org.eclipse.swt,org.eclipse.swt.win32.win32.x86,org.eclipse.ui,org.eclipse.ui.workbench,org.vwpolo.rcp.example,org.eclipse.equinox.launcher,org.eclipse.equinox.launcher.win32.win32.x86 osgi.bundles.defaultStartLevel=4 |
osgi.splashLocation 指定了闪屏文件的绝对路径,像 MyEclipse 也是通过这种方式替换Eclipse自带的闪屏图片的,不过按照这种方式的话只能指定绝对的路径,无法指定相对于插件的相对路径,运行看看,效果是一样的