自定义启动界面的工作主要为实现一个自定义扩展类(继承自AbstractSplashHandler)。
主要步骤;
1、为RCP工程增加org.eclipse.core.runtime.products扩展点,并设定ID属性,此ID即为RCP程序的ProductID。
2、在org.eclipse.core.runtime.products扩展点中增加product扩展项,设定application属性,绑定ProductID与Application。
3、为RCP工程增加org.eclipse.ui.splashHandlers扩展点。
4、在org.eclipse.ui.splashHandlers扩展点中增加splashHandlers扩展项,设定HandlerID跟HandlerClass.
5、在org.eclipse.ui.splashHandlers扩展点中增加splashHandlerProductBinding扩展项,设定splashId跟productId,绑定Handler与ProductID,即绑定SplashHandler与程序。
6、实现第4步中指定的HandlerClass,其需继承自AbstractSplashHandler。
示例代码:
- * The splash screen controller for the RCP application. This has been modified to also act as a login screen for the
- package xxxx.SplashHandler;
- import org.eclipse.jface.dialogs.MessageDialog;
- /**
- * The splash handler overrides the default RCP splash handler.
- */
- public class LoginSplashHandler extends AbstractSplashHandler {
- private Composite loginComposite;
- private Text usernameTextBox;
- private Text passwordTextBox;
- private Button okButton;
- private Button cancelButton;
- private boolean isAuthenticated;
- private Label usernameLabel;
- private Label passwordLabel;
- public LoginSplashHandler() {
- isAuthenticated = false;
- }
- public void init(final Shell splash) {
- splash.setMinimumSize(new Point(400, 165));
- System.out.println("In splash windows.");
- super.init(splash);
- configureUISplash();
- createUI();