分享

显示欢迎页(org.eclipse.ui.intro)-DM

 jinzq 2007-01-18
每次运行rcp都显示欢迎页:
////////////////////////////////////////////////////////////////////////////////
1.继承WorkbenchAdvisor类的子类:
    public void postWindowCreate() {
        super.postWindowCreate();
        getWindowConfigurer().getWindow().getWorkbench().getIntroManager().showIntro(getWindowConfigurer().getWindow(),false);
      }
2.plugin.xml:  
  <extension
         point="org.eclipse.ui.intro">
      <intro
            class="com.bdaum.Hex.HexIntro"
            id="com.bdaum.Hex.intro">
      </intro>
      <introProductBinding
            introId="com.bdaum.Hex.intro"
            productId="com.bdaum.Hex.product">
      </introProductBinding>
   </extension>
3.实现IntroPart类:
    public void setFocus() {
        introForm.setFocus();
    }

    /*
     * (non-Javadoc)
     *
     * @see org.eclipse.ui.part.IntroPart
     *      #createPartControl(org.eclipse.swt.widgets.Composite)
     */
    public void createPartControl(Composite parent) {
        // Fetch Toolkit
        FormToolkit tk = new FormToolkit(parent.getDisplay());
        // Create Form and set Layout
        introForm = tk.createForm(parent);
        TableWrapLayout layout = new TableWrapLayout();
        introForm.getBody().setLayout(layout);
        // Create forms text, more space between paragraphs
        FormText tx = tk.createFormText(introForm.getBody(), true);
        tx.setParagraphsSeparated(true);
        // Set hyperlink appearance
        // (must be done before setting the text)
        HyperlinkSettings settings = new HyperlinkSettings(parent.getDisplay());
        settings.setHyperlinkUnderlineMode(HyperlinkSettings.UNDERLINE_HOVER);
        tx.setHyperlinkSettings(settings);
        // Marked-up text
        String text = "<form><p><span font=\"title\">Hex 7</span></p>"
                + "<p><span color=\"subtitle\" font=\"subtitle\">"
                + "The game of Hex</span></p>"
                + "<p><a href=\"http://startGame\">Start game</a></p></form>";
        tx.setText(text, true, false);
        // Set Fonts
        Font titleFont = JFaceResources.getFont(JFaceResources.HEADER_FONT);
        tx.setFont("title", titleFont);
        Font subtitleFont = JFaceResources.getFont(JFaceResources.BANNER_FONT);
        tx.setFont("subtitle", subtitleFont);
        // Set color for subtitle
        Color col = parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GREEN);
        tx.setColor("subtitle", col);
        // Process hyperlink events
        tx.addHyperlinkListener(new HyperlinkAdapter() {
            public void linkActivated(HyperlinkEvent e) {
                // Fetch IntroManager, close welcome screen
                IWorkbenchWindow window = getIntroSite().getWorkbenchWindow();
                IWorkbench workbench = window.getWorkbench();
                IIntroManager manager = workbench.getIntroManager();
                manager.closeIntro(HexIntro.this);
            }
        });
    }




    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多