每次运行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); } }); } |
|