イントロ画面(概要画面)とは、Eclipseを初めて起動したときに表示される、ワークベンチを覆う青い画面のことです。初めてアプリを使うヒトのための「ようこそ」画面ですね。
org.eclipse.ui.intro
後のorg.eclipse.ui.intro.config.CustomizableIntroPartなどを使う場合は、plugin.xmlで <import plugin="org.eclipse.ui.intro"/> を追加してください。
<extension point="org.eclipse.ui.intro">
<intro class="nu.mine.kino.plugin.samples.rcp.SampleIntroPart"
icon="icons/sample.gif"
id="nu.mine.kino.plugin.samples.rcp.intro1"/> <-イントロのID
<introProductBinding
introId="nu.mine.kino.plugin.samples.rcp.intro1" <-上のイントロのID
productId="nu.mine.kino.plugin.samples.rcp.product"/> <-rcpのproductID
</extension>
拡張ポイントに対応するJavaのインタフェースは
org.eclipse.ui.intro.IIntroPart
ですがEclipseが
org.eclipse.ui.part.IntroPart : 自分でウィジェットを置いていく場合 org.eclipse.ui.intro.config.CustomizableIntroPart : コンテンツxhtmlを読み込んで表示する場合
などを提供してくれています。
<extension point="org.eclipse.ui.intro">
<intro class="org.eclipse.ui.intro.config.CustomizableIntroPart"
icon="icons/sample.gif" ↑コンテンツxhtmlを使う
id="nu.mine.kino.plugin.samples.rcp.intro1"/>
<introProductBinding ↓イントロのID
introId="nu.mine.kino.plugin.samples.rcp.intro1"
productId="nu.mine.kino.plugin.samples.rcp.product"/>
</extension> ↑ このRCPプロダクトIDに適用する
<extension point="org.eclipse.ui.intro.config">
<config content="introContent.xml"
id="template01" <- configのID ↓さっきのイントロのID
introId="nu.mine.kino.plugin.samples.rcp.intro1">
<presentation home-page-id="root" >
<implementation kind="html"/>
</presentation>
</config>
</extension> ここまでで、nu.mine.kino.plugin.samples.rcp.productというRCPプロダクトにintroContent.xmlというイントロ画面を追加する、という意味になりました。またhome-page-id="root"でintroContent.xml内のid="root"が初めのxhtmlですよ、ということを意味しています。
というわけで、引き続きintroContent.xmlです。
<?xml version="1.0" encoding="utf-8" ?> <introContent> <page id="root" content="content/root.xhtml"/> <-id="root"の記述 <page id="concept1" content="content/concept1.xhtml"/> <page id="concept2" content="content/concept2.xhtml"/> </introContent>このid="root"のpage要素の記述で、イントロのトップページはcontent/root.xhtmlとなります。またrootというIDの他にも、concept1、concept2というページIDに対するxhtmlファイル名も定義してあります。
引き続きcontent/root.xhtmlです。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>root.xhtml</title>
<link rel="stylesheet" href="root.css" type="text/css" />
</head>
<body>
<h1>Welcome to Product A</h1>
<h4 id="firstH4">
<img border="0" src="welcome_item.gif" alt="Concept1" />
<a href="http://org.eclipse.ui.intro/showPage?id=concept1">Learn about Concept One...
</a> ↑ root.xhtmlで定義した別のページIDに遷移できるリンク
</h4>
<h4>
<img border="0" src="welcome_item.gif" alt="Concept2" />
<a href="http://org.eclipse.ui.intro/showPage?id=concept2">Learn about Concept Two...</a>
</h4>
<anchor id="anchor1" /> <-アンカー。ここにコンテンツを追加できる。後述。
</body>
</html>
ここまでで、ようやくroot.xhtmlがプロダクト概要として画面に表示されます。既存のイントロに、拡張ポイントを使ってコンテンツを追加する。
<extension point="org.eclipse.ui.intro.configExtension">
<configExtension configId="template01" content="ext.xml"/>
</extension> ↑拡張したいイントロのconfigを指定。さっきのconfigのID。
ext.xml は追加したい「定義」?この拡張ポイントで、さっきのconfigのIDにext.xmlというコンテンツを追加する、という意味になります。さらにext.xmlは以下の通り:
<?xml version="1.0" encoding="utf-8" ?> <introContent> ↓追加したいxhtmlコンテンツを指定 <extensionContent content="content/extContent.xhtml" path="root/anchor1" /> <page id="concept3" content="content/concept3.xhtml"/> ↑pathはさっきのアンカーIDを指定 ↑新たに、concept3というページIDを定義 </introContent>
まだなんか理解できていないですがpath="root/anchor1"のタグで、ページIDがrootで、その中のanchor1というアンカー(さっき後述といっていた)の場所に、content/extContent.xhtmlを追加で挿入する、という意味になります。また新たにconcept3というページIDを定義しています。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>root.xhtml</title>
<link rel="stylesheet" href="root.css" type="text/css" />
</head>
<body>
<h4>
<img border="0" src="welcome_item.gif" alt="Concept3" />
<a href="http://org.eclipse.ui.intro/showPage?id=concept3">Learn about Concept Three...</a>
</h4>
</body>
</html>これでこのextContent.xhtmlの内容が、既存のイントロxhtml(root.xhtml)のanchor1の箇所に挿入されます。
これってxhtmlがxmlだからこんな芸当ができるんですよねぇ。こんなEclipse作ったIBMもすごいけど、やっぱxhtml(xml)って偉大ですね。。。。
消したイントロ画面を再表示するには
IWorkbench.getIntroManager() .showIntro(IWorkbenchWindow preferredWindow,boolean standby)
をよべばよい。boolean standbyは、IIntroManagerのJavaDocによるとstandby - true to put the intro part in its partially visible standy mode, and false to make it fully visible なので、全画面を覆い隠したい場合はfalse,一部分に出したい場合はtrueみたいです。
ちなみに、ActionFactoryから取得できる org.eclipse.ui.internal.IntroAction は
workbenchWindow.getWorkbench().getIntroManager().showIntro(
workbenchWindow, false);
となってましたね。
Eclipseのヘルプを「概要部分の定義」で検索してヒットするページは非常に参考になります。イントロを作る場合は必見です。
この記事は
現在のアクセス:11967