• 沒有找到結果。

立 政 治 大 學

N a tio na

l C h engchi U ni ve rs it y

67

5.3 Android 導引精靈的轉換規則

本節專注在 M2M 的轉換上提供元件轉換方法與其轉換過程的介紹,首先分析 Wizard 的 PIM 架構再利用此架構建立 Android Wizard 的 PSM。以下是對於圖 5-14 的分析:

• 在元件轉換之前我們會先將導引精靈的無關平台描述部分轉換成 Android 平台相關 描述部分。即 IWizard 轉換成 AWizard 模型,藉此收集 Android 導引精靈的所有內容。

• 接著轉換所有的被宣告使用的頁面與頁面名稱,即 IPage 與 IPageName 分別轉換成 APage 與 APageName 模型,完成 Android 導引精靈的結構轉換。

• IPageList 與 IPageSeq 對應到 APageList 與 APageSeq 完成 Android 導引精靈頁面執行 順序的轉換。

• IBranches、IBranch 與 ICondition 對應到 ABranches、ABranch 與 ACondition 完成 Android 導引精靈分歧點頁面執行下一頁的轉換規則。

• 最後所有繼承 Question 類別的問題描述模型,都會被轉換成 AComponentSet 進行接 下來的元件轉換。

-name : string -title : string

AWizard -name : string

-title : string -description : string

APage

-name : string APageName

-name : string -type : string

AComponentSet

-title : string -name : string -description : string

IWizard

-title : string -name : iPageName -description : string

iPage

-name : string iPageName

-title : string -name : string -helpmsg : string

Question

-exp : string -lang : string

ICondition

IBranch

IBranches -conditions 1..*1

-cases 12..*

-exp : string -lang : string

ACondition

圖 5-14:Android 導引精靈的頁面結構轉換(M2M)示意圖。

AComponentSet 是用來收集描述一個資料收集問題所需的 Android 使用者介面元件 集合,不同的問題描述模型經過轉換後都會產生一組特定的 Android 使用者介面元件,

我們將從四種不同的問題描述的 PIM 轉換 PSM 超模型轉換規則的介紹,有 TextInput、

MultipleChoice、Dialog 與 GroupQuestion:

 TextInput

圖 5-15 為 TextInput 對應於 Android 導引精靈結構的轉換規則示意圖,TextInput 對於不 同的「style」屬性轉換結果也會有所不同,主要分成以下兩種類型:

• TextField:產生 ATextView 與單行 AEditText 模型。我們用 ATextView 顯示問題 的標題,AEditText 顯示問題的對話框。

• TextArea:產生 ATextView 與多行 AEditText 模型。ATextView 用來顯示資料收集 問題的標題。

PIM

-titlt : string -name : string -validate : string -reg : string -style : text_style

TextInput -text : string

ATextView

-name : string -validate : string -reg : string

AEditText

textfield -text : string

ATextView

-name : string -validate : string -reg : string

AEditText

textarea -name : string

-type : string ComponentSet

-name : string -type : string

ComponentSet

圖 5-15:TextInput 於 Android 導引精靈轉換(M2M)示意圖。

 MultipleChoice

圖 5-16 與圖 5-17 為 MultipleChoice(多選問題) 與 MenuItem(選項)對應於 Android 導引 精靈結構的轉換規則示意圖。MultipleChoice 會因為不同的「style」屬性而轉換成三種不 同的元件組合:

-name : string -title : string -value : string

ARadioButtton radiobutton

-text : string ATextView -style : choice_style

-title : string -name : string

MultipleChoice

-title : string -value : string

MenuItem

-items 0..*1

-name : string -title : string -value : string

AChekBox

checkbox -text : string

ATextView -name : string -type : string

AComponentSet -name : string

-type : string AComponentSet

圖 5-16:MultipleChoice 於 Android 導引精靈轉換(M2M)示意圖(1)。

• RadioButton:產生一個 ATextView 元件用來顯示資料收集問題的標題,接著根據 MenuItem 個數產生對等數量的 ARadioButton 元件。不同於 Java 平台按鈕的設 計,Android 在設計上並無所謂的按鈕群(ButtonGroup)物件,而是以直接在按鈕 元件中設定其(群組)名稱達成。將按鈕分群,以便定義按鈕間的的互斥關係,確 保單一或多重選項被選取。

• CheckBox:產生一個 ATextView 模型用來顯示資料收集問題的標題,接著根據 MenuItem 個數產生對等數量的 ACheckBox 元件。

• DropdownMenu:產生一個 ATextView 模型用來顯示資料收集問題的標題,然後 產生 ASpinner 元件作為下拉式選單的框架,接著根據 MenuItem 個數產生對等數 量的 Item 模型作為下拉式選單的選項。

-style : choice_style -title : string -name : string

MultipleChoice

-title : string -value : string

MenuItem

-items 1

0..*

-name : string -title : string -value : string

ASpinner dropdownmenu -text : string

ATextView -name : string -type : string

AComponentSet

圖 5-17:MultipleChoice 於 Android 導引精靈轉換(M2M)示意圖(2)。

 FileBrowser

圖 5-18 為 Dialog 對應於 Android 導引精靈的轉換示意圖,Dialog 對於不同的「style」

屬性轉換結果也會有所不同,但目前在本系統上只提供一種類型 AFilebrowser,此類型 在透過轉換後會產生 AtextView 與 AFileBrowser 模型,ATextView 用來顯示資料收集問 題的標題,AFileBrowser 用來產生一個啟動圖片瀏覽器的按鈕。

PIM

-style : dialog_style -title : string -name : string -def_value : string

Dialog

-text : string ATextView

AFileBrowser filebrowser

-name : string -type : string

AComponentSet

圖 5-18:Dialog 於 Android 導引精靈轉換(M2M)圖示意圖。

 GroupQuestion

圖 5-19 為 GroupQuestion 對應於 Android 導引精靈的轉換示意圖。QroupQuestion 經過 轉換後會產生類似 Java 元件中 Border 的介面顯示效果,在此定義 Border 的介面 Layout(在元件外圍以黑色外框包覆)用來收集相同性質的 AComponentSet 集合,接著將 包含在 GroupQuestion 裡的問題描述模型轉換成 AComponentSet 模型。

PIM

-title : string -name : string

GroupQuestion

-title : string -name : string -helpmsg : string

Question

-questions 1

0..*

Border

-name : string AComponentSet

-subsets 1 0..*

-text : string ATextView

圖 5-19:Border 於 Android 導引精靈轉換(M2M)示意圖。

最後是平台無關導引精靈的資料驗證模型轉換,主要為 Validation 資料驗證的部分。

圖 5-20 為 Validation 的 PIM 對應於 Android PSM 的導引精靈轉換示意圖。

PIM

-check_value : string -check_method : string

Validation -check_value : string

-check_method : string AValidation

圖 5-20:Validation 於 Android 導引精靈轉換(M2M)示意圖。

‧ 國

立 政 治 大 學

N a tio na

l C h engchi U ni ve rs it y

73

系統操作

此章節主要介紹如何在 Eclipse 平台上,利用 MoDWiz3 系統進行多平台導引精靈程式開 發的操作流程。首先從系統的執行環境與安裝過程開始,接著是延伸導引精靈描述語言 (EWDL)的相關語法介紹,最後介紹如何利用 MoDWiz3 產生符合特定平台的導引精靈 程式。