Top / Eclipse / プラグイン開発のTIPS集 / イントロ(概要画面)を作る

イントロ画面(概要画面)とは、Eclipseを初めて起動したときに表示される、ワークベンチを覆う青い画面のことです。初めてアプリを使うヒトのための「ようこそ」画面ですね。

basicIntro.png

拡張ポイント

org.eclipse.ui.intro

後のorg.eclipse.ui.intro.config.CustomizableIntroPart?などを使う場合は、plugin.xmlで <import plugin="org.eclipse.ui.intro"/> を追加してください。

plugin.xmlのサンプル

<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を読み込んで表示する場合

などを提供してくれています。

やってみる

例1

  • plugin.xml
    <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です。

  • 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です。

  • 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がプロダクト概要として画面に表示されます。
phase1.png

例2

既存のイントロに、拡張ポイントを使ってコンテンツを追加する。

  • plugin.xmlに追加
    <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は以下の通り:

  • 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を定義しています。

  • extContent.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>
      <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の箇所に挿入されます。

phase2.png

これってxhtmlがxmlだからこんな芸当ができるんですよねぇ。こんなEclipse作ったIBMもすごいけど、やっぱxhtml(xml)って偉大ですね。。。。

TIPS

イントロ画面を再表示する

消したイントロ画面を再表示するには

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のヘルプを「概要部分の定義」で検索してヒットするページは非常に参考になります。イントロを作る場合は必見です。


この記事は

選択肢 投票
おもしろかった 7  
そうでもない 1  

Top / Eclipse / プラグイン開発のTIPS集 / イントロ(概要画面)を作る

現在のアクセス:11175


添付ファイル: filephase2.png 1139件 [詳細] filephase1.png 1087件 [詳細] filebasicIntro.png 1283件 [詳細]

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2021-12-14 (火) 11:32:33 (861d)