複合提要

複合提要將問題分解成一連串更小的作業,提供指引來解決複雜的問題。複合提要是以 org.eclipse.ui.cheatsheets.cheatSheetContent 延伸點來登錄。

內容檔案格式

複合提要內容本身是定義在符合複合提要內容檔案規格的個別檔案中。 內容檔案是 XML 檔案,以樹狀結構中的一組作業群組所構成。

<compositeCheatsheet> 是複合提要的根元素。擁有單一的根作業,可能是 <task> 或 <taskGroup>。<taskGroup> 元素可能有一或多個子項,每一個子項目可能是 <task> 或 <taskGroup>。 <task> 沒有子作業。

作業和作業群組可包含 <intro> 元素,內含作業啟動之前要顯示的文字, 也可包含 <onCompletion> 元素,內含作業完成時要顯示的文字。 <intro> 和 <onCompletion> 元素可包含表單文字標記,在下列範例中, <b> 和 </b> 標示用來顯示粗體文字。

作業也可包含 <param> 元素。提要作業可以有下列任何參數:"id" 是登錄提要的 id,"path" 是提要內容檔案的相對路徑或 URL, "skipIntro" 是 Boolean 參數,若為 true,則提要從第一個步驟開始,而非從簡介開始。 必須指定 "id" 或 "path" 其中一個,但不可同時指定。

從作業 "B" 至作業 "A" 的 <dependency> 節點代表必須完成作業 A 才能啟動作業 B 的需求。

提要作業參數

如果作業的 kind = "cheatsheet",當啟動這項作業時,會開啟一份提要。 提要作業可能有三個參數。

參數名稱  說明
id 已利用 org.eclipse.ui.cheatsheets.cheatSheetContent 延伸點來登錄之提要的 ID。 這用來識別將關聯於這項作業的提要。 您應該指定 id 或 path 參數(不是同時指定這兩者)。
path 提要內容檔的 URL。 這可能是絕對 URL,也可能是複合提要內容檔的相對路徑。 如果同時指定了 id 和 path,就會利用 path 來尋找內容檔,系統會忽略 id 參數。
showIntro 預設值是 true 是 Boolean 參數。 如果是 "false",當提要啟動時,最初會顯示第一步驟,而不是簡介。

複合提要的範例

下列檔案示範如何從現有的提要中建立複合提要。 它會顯示如何建立作業群組及略過作業。

<?xml version="1.0" encoding="UTF-8"?>
<compositeCheatsheet name="Composite cheat sheet example">
    <taskGroup name= "Composite cheat sheet example">
         <intro> This is an example of a <b>composite cheat sheet</b> built from existing cheat sheets.
                 <br/><br/>You can select a task to work on either by following the hyperlinks or by
                 selecting a task in the tree.
         </intro>
         <onCompletion>Congratulations you have completed all the tasks.</onCompletion>
         <task kind="cheatsheet" name= "Branching and merging using CVS" skip="true">
              <param name = "id" value = "org.eclipse.platform.cvs_1" />
              <intro>This cheat sheet is intended for CVS users. If you are not using CVS or do
              not intend to branch and merge you may skip this task.
              </intro>
               <onCompletion>Congratulations you now know how to branch and merge.</onCompletion>
         </task>
         <taskGroup name= "Create Java Projects" kind = "sequence">
             <intro> First you will learn how to create a simple java project, then you will create
             an java project which uses SWT.
             <br/><br/>This task group is a sequence which means that
             if you click on the subtask "Standalone SWT Application" it will not let that task be started
             until "Create a java project" has been completed.
             </intro>
              <onCompletion>Congratulations you have built both Java applications.</onCompletion>
         <task kind="cheatsheet" name= "Create a java project" id = "createJavaProject">
             <param name="id" value = "org.eclipse.jdt.helloworld"/>
                 <param name="showIntro" value = "false"/>
                 <intro>This cheat sheet walks through the process of creating a simple hello world application.
                        The cheat sheet can launch wizards to create a new project and a new class.
</intro>
             <onCompletion>Congratulations you have succeeded in creating a hello world application</onCompletion>
         </task>
             <task kind="cheatsheet" name= "Standalone SWT Application">
                  <intro>Eclipse plugins which contribute to the user interface use The Standard Widget Toolkit (SWT). 
                        This task guide can be used to learn more about SWT. 
</intro>
                  <param name = "id" value = "org.eclipse.jdt.helloworld.swt" />
                  <onCompletion>Congratulations you have succeeded in creating an SWT application.</onCompletion>
         </task>
         </taskGroup>
         </taskGroup>
</compositeCheatsheet>

複合提要延伸 - Eclipse 3.2 暫定

複合提要可延伸,但在 Eclipse 3.2,這項延伸性只是暫定,且類別在成為 API 之前可能變更。 利用延伸點 org.eclipse.ui.cheatsheets.cheatSheetContent 可延伸複合提要支援, 此延伸點有 taskEditor 和 taskExplorer 這兩個新元素,可提供作業編輯器和作業瀏覽器。

外掛作業編輯器會定義一個在作業詳細資料區段中顯示的新作業類型。 若要外掛作業編輯器,請實作 TaskEditor 的具體子類別,再將 taskEditor 元素新增至 plugin.xml。

作業瀏覽器的外觀也可以利用延伸點來配置,Eclipse 平台已提供一個樹狀瀏覽器。 依預設,複合提要的瀏覽器最初開啟時為樹狀結構,<compositeCheatSheet> 元素有一個屬性可以置換此預設值。 如果登錄多個瀏覽器,檢視功能表將提供一個功能表項目來切換瀏覽器。 若要外掛作業瀏覽器,請先實作 TaskExplorer 的具體子類別,再將 taskExplorer 元素新增至 plugin.xml。

相關鏈結

使用提要
使用複合提要
建立提要
編寫準則
複合提要內容檔案規格
org.eclipse.ui.cheatsheets.cheatSheetContent 延伸點