1. GEF的View實際上包含有很多部分,而不僅僅只是figure:
還包括visual parts, feedback, handles, toolipts等等.
It includes the visual part, which serves
as the primary representation for the model object(s). The most flexible visual parts are Figures
from draw2d. GEF also provides support
for SWT TreeItems, but support for other visuals can easily be added. While "visual part" refers to the
object primarily representing a model object, the more encompassing
"view" includes feedback, handles, tooltips, and all things visible
to the user. All of these make up the
view, and it is the controller's job to construct and manage them.
2. Graphical editing可以被定義為:
1) 操作模型,這是通過對Request進行響應(yīng),生成Command來完成的。
2) 顯示Feedback,在復(fù)雜的交互中,EditParts需要為用戶顯示操作的反饋。
3) 上面所提的兩個工作,均可以被EditParts代理到其他額外的EditParts上。
3. EditPolicy的Role字符串的作用,是使得EditPolicy能夠用過這個Key來進行替換。例如子類可以通過Role這個Key來覆蓋其父類所安裝的EditPolicy。在GEF中,Role和EditPolicies能夠被劃分為兩類:Graphical和Non-Graphical。非圖形的角色能夠不需要知道任何View的信息來處理模型對象,也就是說這種角色在不同類型的viewers中是可重用的。
4. 角色及其定義
Non-Graphical Roles:
1)
COMPONENT_ROLE:
一個Component存在于一個parent中,并且可以從parent中刪除。更為一般的,它可以使任何只涉及到這個EditPart,而與View無關(guān)的東西。(More generally, it is
anything that involves only this EditPart.)
2)
CONNECTION_ROLE
這是ConnectionEditParts應(yīng)該有的一個基本角色。Connections同Components有一點不同,刪除Connections時通常還需要其從其source和target節(jié)點中刪除,而不是從其parent中刪除。
3)
CONTAINER_ROLE
大部分擁有children的EditParts都應(yīng)該具有這個角色。一個Container會涉及到adds/orphans以及creates/deletes等操作。
4)
NODE_ROLE
如果一個EditParts用戶Connection,則其應(yīng)該具有這個角色,它可以用來創(chuàng)建,刪除,重新連接一個Connection。
Graphical Roles:
1)
PRIMARY_DRAG_ROLE:
用來允許用戶拖動這個EditPart。用戶可以通過點擊這個EditPart然后拖動,或者點擊這個EditPart所創(chuàng)建的一個Handle來進行拖動。
2)
LAYOUT_ROLE:
Layout角色用來放在一個Container的EditPart上,這個EditPart擁有一個graphical layout。如果這個layout有constraints,則它需要通過計算來得到這個constraints。
3)
GRAPHICAL_NODE_ROLE:
A node supports connections to
terminals. When creating and
manipulating connections, EditPolicies with this role might analyze a Request's
data to perform "hit testing" on the graphical view and determine the
semantics of the connection.
4)
CONNECTION_ENDPOINTS_ROLE:
這個Role允許用戶拖動一個ConnectionEditPart的端點。
5) CONNECTION_BENDPOINTS_ROLE:
這個Role允許用戶能夠在一個Connection中間拖動和創(chuàng)建bendpoints。
6)
SELECTION_FEEDBACK_ROLE:
這個角色只是用來顯示feedback。當鼠標進入或者在一個EditPart上暫停時,Selection Tool會發(fā)送兩個類型的request給EditPart。安裝了這個角色的EditPart能夠在此時接受這些請求來改變view的樣子,或者彈出tip,label等。
7)
TREE_CONTAINER_ROLE:
SWT Tree的Layout Role。