Add or change content in welcome page

31 篇文章 0 订阅
5 篇文章 0 订阅

It is easy to customize the splash to use your own brand or logo during eclipse starts up. If you want to make your own welcome page, just follow these steps:

1. add extension point in your plugin

<extension
         point="org.eclipse.ui.intro.config">
      <config
            introId="myeclipse.intro"
            content="introContent.xml"
            id="myeclipse.configId">
         <presentation
               home-page-id="root">
            <implementation
                  kind="html"
                  os="win32,linux,macosx">
            </implementation>
         </presentation>
      </config>
   </extension>
2. use xml file to define your pages and contents

<?xml version="1.0" encoding="utf-8" ?>
<introContent>
    <page id="root" content="content/root.xhtml"/>
    <page id="concept1" content="content/concept1.xhtml"/>
    <page id="concept2" content="content/concept2.xhtml"/>
</introContent>

3. how eclipse makes it work internally?

public class BaseExtensionPointManager {

	 protected static final String CONFIG = "org.eclipse.ui.intro.config";
	 
	 protected BaseExtensionPointManager() {
			registry = Platform.getExtensionRegistry();
		}

	protected IConfigurationElement getIntroConfig(String attrributeName,
            String attributeValue) {

        IConfigurationElement[] configElements = registry
            .getConfigurationElementsFor(CONFIG);

        IConfigurationElement config = getConfigurationFromAttribute(
            configElements, attrributeName, attributeValue);

        if (config == null)
            // if there is no valid config, log the fact.
            Log.warning("No Intro configuration found with " + attrributeName //$NON-NLS-1$
                    + " of value = " + attributeValue); //$NON-NLS-1$

        return config;
    }
}

public class IntroModelRoot extends AbstractIntroContainer {

    public void loadModel() {
        getChildren();
        determineHomePage();
    }
	
    protected void loadChildren() {
        children = new Vector();
        if (Log.logInfo)
            Log.info("Creating Intro plugin model...."); //$NON-NLS-1$

        // load presentation first and create the model class for it. If there
        // is more than one presentation, load first one, and log rest.
        IConfigurationElement presentationElement = loadPresentation();
        if (presentationElement == null) {
            // no presentations at all, exit.
            setModelState(true, false);
            Log.warning("Could not find presentation element in intro config."); //$NON-NLS-1$
            return;
        }
        
        loadTheme();
        loadConfigurer();

        introPartPresentation = new IntroPartPresentation(presentationElement);
        children.add(introPartPresentation);
        // set parent.
        introPartPresentation.setParent(this);

        // now load all children of the config. There should only be pages and
        // groups here. And order is not important. These elements are loaded
        // from the content file DOM.
        Document document = loadDOM(getCfgElement());
        if (document == null) {
            // we failed to parse the content file. Intro Parser would have
            // logged the fact. Parser would also have checked to see if the
            // content file has the correct root tag.
            setModelState(true, false);
            return;
        }

        // set base for this model.
        this.base = getBase(getCfgElement());

        // now load content.
        loadPages(document, getBundle());
        loadSharedGroups(document, getBundle());

        // Attributes of root page decide if we have a static or dynamic case.
        setModelState(true, true);
    }
	
    private void determineHomePage() {
        String pid = Platform.getProduct().getId();
        startPageId = getProcessPreference("INTRO_START_PAGE", pid); //$NON-NLS-1$
        String homePagePreference = getProcessPreference("INTRO_HOME_PAGE", pid); //$NON-NLS-1$
        homePage = rootPage;  // Default, may be overridden
        if (homePagePreference.length() != 0) {
            AbstractIntroPage page = (AbstractIntroPage) findChild(homePagePreference,
                    ABSTRACT_PAGE);
            if (page != null) {
                homePage = page;
                if(startPageId.length() == 0) {
                    startPageId = homePagePreference;
                }
            }
        }
        String standbyPagePreference = getProcessPreference("INTRO_STANDBY_PAGE", pid); //$NON-NLS-1$
        modelStandbyPageId = getPresentation().getStandbyPageId();

        if (standbyPagePreference.length() != 0) {
            standbyPage = (AbstractIntroPage) findChild(standbyPagePreference,
                    ABSTRACT_PAGE);
        }
        if (standbyPage == null && modelStandbyPageId != null && modelStandbyPageId.length() != 0) {
            standbyPage = (AbstractIntroPage) findChild(modelStandbyPageId,
                    ABSTRACT_PAGE);
        }
        if (standbyPage != null) {
            standbyPage.setStandbyPage(true);
        }
    }
}


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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值