7.2 未來研究方向
7.2.2 客製化文件
國
立 政 治 大 學
‧
N a tio na
l C h engchi U ni ve rs it y
79
圖 7.2:條件式導引精靈流程。
條件式導引精靈的開發重點在於,如何明確的對導引精靈進行分析,定義那些導引 精靈頁面集合是屬於 Simple Wizard,那些又是屬於 Control Wizard,最重要的是找到 Break Point,明確的表示如何判斷下一個連接的導引精靈。
7.2.2 客製化文件
由於本系統一開始對於建立導引精靈超模型的要求,希望可以是簡潔扼要的涵蓋整個導 引精靈程式與多執行平台的特性,所以對於導引精靈超模型的描述,有些部分被我們給 省略,或者可以說是被我們給隱藏起來了,例如圖形使用者介面的排版設計、導引精靈 頁面字體的顏色大小或是圖形使用者介面的樣式...等,這些部分在我們的導引精靈超 模型描述裡都是沒有的,因此利用本系統進行開發的導引精靈程式看起來會顯得有點單 調。
所以在未來我們希望加入客製化文件,對於導引精靈超模型描述不足的地方,能夠 進一步的加以描述在客製化文件裡。本系統對於客製化文件的處理,主要是在特定平台 導引精靈模型透過專屬的程式碼產生器產生導引精靈程式時,對程式碼產生器提供客製 化文件,即可產生客製化的特定平台導引精靈程式。
‧ 國
立 政 治 大 學
‧
N a tio na
l C h engchi U ni ve rs it y
80
‧
[01] Model-Driven Architecture, 1997-2011. http://www.omg.org/mda/
[02] Object Management Group, Inc., 1997-2011. http://www.omg.org [03] Eclipse.org, 2011. http://www.eclipse.org/
[04] Eclipse Modeling Framework, 2011. http://www.eclipse.org/modeling/emf/
[05] Xtext2.0, 2011.
http://www.eclipse.org/Xtext/
[06] Xtend, 2011. http://www.eclipse.org/Xtext/xtend/
[07] Enis Afgan, Jeff Gray, Purushotham Bangalore, "Using Domain-Specific Modeling to Generate User Interfaces for Wizards", Proceedings of the MoDELS'07 Workshop on Model Driven Development of Advanced User Interfaces Nashville, Tennessee, USA, 2007.
[08] Unified Modeling Language, 1997-2011. http://www.uml.org
[09] Meta Object Facility Specification, 1997-2011. http://www.omg.org/mof/
[10] Frank Budinsky, David Steinberg, Ed Merks, Raymond Ellersick, Timothy J.
Grose, Eclipse Modeling Framework, Addison-Wesley,2003
[11] XML Metadata Interchange, 1997-2011.
http://www.omg.org/spec/XMI/2.4.1/PDF/
[12] Eclipse Modeling Project, 2011. http://www.eclipse.org/modeling/
[13] HTML, 1999. http://www.w3.org/TR/html401/
‧
[14] E. Afgan and P. Bangalore, "Application Specification Language (ASL) – A Language for Describing Applications in Grid Computing," 4th International Conference on Grid Services Engineering and Management (GSEM), Leipzig, Germany, 2007.
[15] D. Schmidt, "Model-Driven Engineering," IEEE Computer, vol. 39, pp. 25-32, 2006.
[16] J. Durkin, Expert Systems: Design and Development, Macmillan, 1998.
[17] K. Balasubramanian, A. Gokhale, G. Karsai, J. Sztipanovits, and S. Neema,
"Developing Applications using Model-Driven Design Environments," IEEE Computer, vol. 39, pp. 33-40, 2006.
[18] Object Constraint Language, 1997-2011.
http://www.omg.org/spec/OCL/2.2/PDF/
[19] Microsoft Component Object Model, 1998. http://www.cs.umd.edu/~pugh/com/
[20] JavaScript, 2001-2003.
http://devedge-temp.mozilla.org/central/javascript/index_en.html
[21] Asynchronous JavaScript XML, 2011.
http://www.adaptivepath.com/ideas/ajax-new-approach-web-applications
[22] Tim Boudreau, Java Wizard API, 2006.
http://weblogs.java.net/blog/timboudreau/archive/2006/09/wizard_project.html
[23] MigLayout, 2011. http://www.miglayout.com/‧
03 <script src="«w.name»-help_msg_ctrl.js"></script>
04 <script src="«w.name»-valid_ctrl.js"></script>
05 <script src="«w.name»-map.js"></script>
06 <script type="text/javascript">
07 var xmlhttp;
08 var count = -1;
09 var pages = new Array("«np.name»"導引精靈頁面名稱與順序);
10 function creatXMLHttpRequest() { 11 if (window.XMLHttpRequest) { 12 xmlhttp=new XMLHttpRequest();
13 }
14 else {
15 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
16 }
17 }
18 function loadPage(num) {
19 count+=num;
20 creatXMLHttpRequest();
21 xmlhttp.onreadystatechange=handleStatChange 22 xmlhttp.open("GET",pages[count]+".html",true);
23 xmlhttp.send();
24 if(count > 0)
‧
25 document.getElementById("back").disabled=false;
26 Else
27 document.getElementById("back").disabled=true;
28 document.getElementById("next").disabled=true;
29 if(pages[count] == "«wp.name»")
30 change«wp.name»State(null);
31 }
32 function handleStatChange() { 33 if (xmlhttp.readyState==4) {
34 if(xmlhttp.status == 200){
35 document.getElementById("content").innerHTML = xmlhttp.responseText;
36 clearData();
37 }
38 }
39 } 40 </script>
41 </head>
42 <body onload="loadPage(1)">
43 <!----Wizard Title---->
44 <title>«w.title»導引精靈title</title>
45 <!--Wizard Title End-->
46
47 <!----Wizard Description---->
48 <h2>«w.description»導引精靈description</h2><hr>
49 <!--Wizard Description End-->
50
51 <!----Help Tooltip Message---->
52 <div style="position:absolute; background-color:#CCCCFF;" d =
"popup_msg" ></div>
53 <!--Help Tooltip Message End-->
54
55 <!----Wizard Content---->
56 <div id="content"></div>
57 <!--Wizard Content End-->
58 <!----Button Bar---->
‧
59 <div id="buttonbar"><p><hr>
60 <form action="«w.name»-summary.html">
61 <center>
62 <!--back-->
63 <button id="back" type="button" onclick="loadPage(-1)"
disabled>< Back</button>
64 <!--next-->
65 <button id="next" type="button" Nclick = "loadPage(1)">
Next ></button>
66 <!--finish-->
67 <input id="finish" type="submit" value=" Finish " disabled />
68 </center>
01 <fieldset>
02 <legend>
03 <var><strong>«wp.title»導引精靈頁面title </strong></var> ->
Summary :
04 </legend>
05 <p><var>«wp.description»導引精靈頁面description </var></p>
06 <hr/>
13 </fieldset>
‧
05 function help_message(element) { 06
07 dataDiv = document.getElementById("popup_msg");
08 setPos(element);
09 if(enable){
10 getMsgText(element.id);
11 enable=false;
19 function getMsgText(ele_ID) { 20
31 function setData(data) { 32
33 document.getElementById("popup_msg").innerHTML=data;
34 }
‧
<textarea id="«ta.id»" name="«ta.name»" rows="«ta.rows»" cols="«ta.cols»" readonly disabled >«ta.value»</textarea>
01 function «wv.name»資料驗證方法名稱(id) { 02 //«wv.description»資料驗證描述
‧
Select & Option
<select id="«s.id»" name="«s.name»" size="«s.size»" disabled >
<option id="«o.id»" value="«o.value»" disabled selected>«o.text»</option>
other options…
</select>
Input input type
text
<input id="«i.id»" type="text" name="«i.name»" value="«i.value»"
maxlength="«i.maxlength»" size="«i.size»"/>
radio
<input id="«i.id»" type="radio" name="«i.name»" value="«i.value»"
checked disabled />
checkbox
<input id="«i.id»" type="checkbox" name="«i.name»" value="«i.value»"
checked disabled />
file <input id="«i.id»" type="file" name="«i.name»" />
‧ 國
立 政 治 大 學
‧
N a tio na
l C h engchi U ni ve rs it y
89
FieldSet & ComponentSet
<li><fieldset id="«fs.id»">
<legend>«fs.legend» : </legend><ul>
subsets…
</ul></fieldset></li>
附錄 A-6:網頁應用程式導引精靈輔助元件
導引精靈超模型 圖形使用者介面
程式範本
HelpMsg
<label id="«hm.name»" onclick="help_message(this)">
[<font size="2"color="blue" >HELP</font>]
</label>
‧ 國
立 政 治 大 學
‧
N a tio na
l C h engchi U ni ve rs it y
90
WValidation & ErrorMsg
<input type="button" value="validate" onclick="«wv.name»(«wv.data_id»)"/>
‧
01 package result.java;
02
03 import java.awt.*;
04 import java.util.List;
05 import java.util.*;
06
07 import org.netbeans.api.wizard.WizardDisplayer;
08 import org.netbeans.spi.wizard.*;
09
10 public class «jw.name»Java導引精靈名稱{ 11
12 public static void main(String[] args) { 13
14 final Class [] pages = new Class [] {
15 «jpn.name»Java導引精靈頁面名稱與順序.class
16 };
17 Runnable r = new Runnable () {
18 public void run () {
19
20 WizardProducer jwp = new WizardProducer ();
21 Wizard wizard = WizardPage.createWizard (pages, jwp);
22
23 System.out.println (WizardDisplayer.showWizard 24 (wizard,new Rectangle (700, 200, 580, «jw.wizardCols»)));
‧
28 EventQueue.invokeLater (r);
29 } 30 } 31
32 class WizardProducer implements WizardPage.WizardResultProducer { 33 «jw.declareItem»
34 public Object finish(Map wizardData) throws WizardException { 35 //show data collected
36 String [] items = new String [«jw.itemSize»];
37 «jw.setItemValue»
38
39 return Summary.create(items, null);
40 }
41 public void Content(List<String> name, String value, String flag){
42 if(flag == "true")
43 name.add(value);
44 }
45 public boolean cancel(Map settings) {
46 return true;
47 } 48 }
01 package result.java;
02
03 import java.awt.*;
04 import javax.swing.*;
05 import net.miginfocom.swing.MigLayout;
06 import org.netbeans.spi.wizard.*;
07 import javax.swing.border.Border;
‧
08 import java.awt.event.ActionEvent;09 import java.awt.event.ActionListener;
10 import java.io.*;
11
12 public class «jwp.name»Java導引精靈頁面名稱 extends WizardPage { 13 private static final long serialVersionUID = 1L;
14 private «element.type» «element.value»全域變數宣告;
15 public «jwp.name»Java導引精靈頁面名稱 () { 16 setLayout(new MigLayout("wrap 1"));
17 //---JComponentSets--- 18 Java導引精靈JComponentSets
19 //---End JComponentSets--- 20 }
21 //Page Description
22 public static final String getDescription () { 23 return "«jwp.title»Java導引精靈頁面title";
24 }
25 //Component Validate
26 protected String validateContents (Component comp, Object o){
27 if(«set.condition»)
28 return "«set.help.helpmsg»";
29 //---«set.help.name» : «set.help.description»
30 //else if()
31 // return "«set.help.name» : «error.text»";
32 //---end of «set.help.name»---
33 return null;
34 }
35 private class «jc.name»Listener implements ActionListener 36 public void actionPerformed(ActionEvent event) { 37 JFileChooser chooser = new JFileChooser();
38 chooser.showOpenDialog(null);
39 File f = chooser.getSelectedFile();
40 «set.name».setText(f.getName());
41 }
42 } 43 }
‧ 國
立 政 治 大 學
‧
N a tio na
l C h engchi U ni ve rs it y
94
附錄 B-3:Java 導引精靈使用者介面元件
導引精靈超模型 圖形使用者介面
程式範本
JLabel
JLabel «l.name» = new JLabel ("«l.title»");
JTextField
«tf.name» = new JTextField(20);
«tf.name».setText("«tf.value»");
«tf.name».setName("«tf.name»");
JTextArea
«ta.name» = new JTextArea (3, 20);
«ta.name».setText("«ta.value»");
«ta.name».setName ("«ta.name»");
«ta.name».setLineWrap(true);
‧ 國
立 政 治 大 學
‧
N a tio na
l C h engchi U ni ve rs it y
95
ButtonGroup & JRadioButton
ButtonGroup «bg.name» = new ButtonGroup();
«rb.name» = new JRadioButton ("«rb.title»");
«rb.name».setName ("«rb.name»");
«bg.name».add(«rb.name»);
JCheckBox
«cb.name» = new JCheckBox ("«cb.title»");
«cb.name».setName ("«cb.name»");
JComboBox & Item
String[] data = {"«i.title»"};
«cb.name» = new JComboBox (data);
«cb.name».setSelectedIndex(-1);
«cb.name».setName ("«cb.name»");
‧ 國
立 政 治 大 學
‧
N a tio na
l C h engchi U ni ve rs it y
96
FileBrowser
JButton «f.name» = new JButton("Open");
«f.name».addActionListener(new «f.name»Listener());
Border & JComponentSet
Border «b.name» = BorderFactory.createEtchedBorder();
«b.name»_pnl.setBorder(BorderFactory.createTitledBorder(«b.name», "«b.title»"));
subsets…
‧
附錄 C-1:Eclipse 導引精靈主程式
01 package result.eclipse;
02
03 import java.util.HashMap;
04 import java.util.Map;
05
06 import org.eclipse.jface.dialogs.IDialogConstants;
07 import org.eclipse.jface.wizard.Wizard;
08 import org.eclipse.jface.wizard.WizardDialog;
09 import org.eclipse.swt.widgets.*;
10
11 public class «ew.name»Eclipse導引精靈名稱 { 12
13 public static void main(String[] args) { 14
15 Map<String, Object> wizarddata = new HashMap<String,Object>();
16
17 Shell shell = new Shell();
18 WizardDialog dlg = new WizardDialog(shell,new MyWizard (wizarddata));
19 int rc = dlg.open();
20 if(rc == IDialogConstants.OK_ID)
21 new Summary(wizarddata);
22 } 23 }
‧
附錄 C-2:Eclipse 導引精靈頁面
24 class MyWizard extends Wizard{
25 Map<String, Object> wizarddata = new HashMap<String, Object>();
26
27 public MyWizard(Map<String, Object> wizarddata){
28 this.wizarddata = wizarddata;
29
30 addPage(new «epn.name»Eclipse導引精靈頁面順序與名稱
(wizarddata));
31 setWindowTitle("«ew.title»Eclipse導引精靈title");
32 } 33
34 public boolean performFinish() {
35 return true;
36 } 37
38 public boolean canFinish() {
39 if(wizarddata.size() == «ew.compositeSize»)
40 return true;
41 return false;
42 } 43 }
01 package result.eclipse;
02
03 import java.util.*;
04 import java.util.List;
05 import org.eclipse.jface.wizard.WizardPage;
06 import org.eclipse.swt.SWT;
07 import org.eclipse.swt.events.*;
08 import org.eclipse.swt.layout.*;
09 import org.eclipse.swt.widgets.*;
‧
10 public class «ewp.name»Eclipse導引精靈頁面名稱 extends WizardPage { 11
12 Map<String, Object> wizarddata = new HashMap<String, object>();
13
14 «element.type» «element.value»全域變數宣告;
15
16 public «ewp.name»Eclipse導引精靈頁面名稱(Map<String, Object>
wizarddata) { 17
18 super("«ewp.name»Eclipse導引精靈頁面名稱");
19 this.wizarddata = wizarddata;
20
21 setTitle("«ewp.title»Eclipse導引精靈頁面title");
22 setDescription("«ewp.description»Eclipse導引精靈頁面 description");
23 } 24
25 public void createControl(Composite parent) { 26
27 Composite composite = new Composite(parent, SWT.NONE);
28 composite.setLayout(new GridLayout(1, true));
29
30 //---Composites--- 31 Eclipse導引精靈Composites
32 //---End Composites--- 33
34 setControl(composite);
35 } 36
37 public boolean canFlipToNextPage() { 38
39 if(getErrorMessage() != null) return false;
40 if(«ewp.composites.conditionCompile»)
41 return true;
42 return false;
43 }
‧ 國
立 政 治 大 學
‧
N a tio na
l C h engchi U ni ve rs it y
100
附錄 C-3:Eclipse 導引精靈使用者介面元件
導引精靈超模型 圖形使用者介面
程式範本
Label
final Label «l.name» = new Label(«composite.name»_comp, SWT.LEFT);
«l.name».setText("«l.title»");
Combo & Item
«cb.name» = new Combo(«composite.name»_comp, SWT.READ_ONLY);
String «cb.name»_items[] = {"«i.title»"};
«cb.name».setItems(«cb.name»_items)
Text multi
false
true
multi
false
«t.name» = new Text(«composite.name»_comp, SWT.BORDER);
«t.name».setText("«t.value»");
‧
GridData «t.name»_gd = new GridData();«t.name»_gd.widthHint = 235;
«t.name».setLayoutData(«t.name»_gd);
true
«t.name» = new Text(«composite.name»_comp, SWT.BORDER|SWT.MULTI|
SWT.V_SCROLL|SWT.WRAP);
«t.name».setText("«t.value»");
GridData «t.name»_gd = new GridData();
«t.name»_gd.widthHint = 215;
«t.name»_gd.heightHint = 50;
«t.name».setLayoutData(«t.name»_gd);
Button button type
CHECK
RADIO
button type
CHECK«b.name» = new Button («composite.name»_bcomp, SWT.CHECK);
«b.name».setText("«b.title»");
RADIO
«b.name» = new Button («composite.name»_bcomp, SWT.RADIO);
«b.name».setText("«b.title»");
FileBrowser
final Button «f.name» = new Button(«composite.name»_comp, SWT.BUTTON2);
«f.name».setText("Open...");
‧ 國
立 政 治 大 學
‧
N a tio na
l C h engchi U ni ve rs it y
102
Group & Composite
final Group «g.name» = new Group(composite, SWT.NONE);
«g.name».setText("«g.title»");
subcomposites…