GEF:EditPolicy接口参考(摘)

Interface EditPolicy

All Known Implementing Classes:
AbstractEditPolicy

A pluggable contribution implementing a portion of an EditPart's behavior. EditPolicies contribute to the overall editing behavior of an EditPart. Editing behavior is defined as one or more of the following:

EditPolicy用于实现EditPart的editing behavior 功能:

  • Command Creation - Returning a Command in response to getCommand(Request) 。响应getCommand的时候返回一个Command.
  • Feedback Management - Showing/erasing source and/or target feedback in response to Requests. 展示/删除掉用于用户交互的 feedback 块
  • Delegation/Forwarding (代管/中转)- Collecting contributions from other EditParts (and therefore their EditPolicies). In response to a given Request, an EditPolicy may create a derived Request and forward it to other EditParts. For example, during the deletion of a composite EditPart, that composite may consult its children for contributions to the delete command. Then, if the children have any additional work to do, they will return additional comands to be executed. EditPolicy 可以将派生的Request 转发给其他EditParts。举例来说,删除一个组合的EditPart时候,将会同时处理子EditPart的删除命令,如果children有附加的工作,将返回执行附加的comands。

EditPolicies should determine an EditPart's editing capabilities. It is possible to implement an EditPart such that it handles all editing responsibility. However, it is much more flexible and object-oriented to use EditPolicies. Using policies, you can pick and choose the editing behavior for an EditPart without being bound to its class hierarchy. Code reuse is increased, and code management is easier.

EditPolicy特性:便捷、面向对象、可拔插,增强了复用性。

IMPORTANT: This interface is not intended to be implemented by clients. Clients should inherit from AbstractEditPolicy. New methods may be added in the future. 使用时候继承AbstractEditPolicy,不要直接实现EditPolicy。

 


COMPONENT_ROLE:该EditPolicy处理不适用于其他EditPolicy的基础 操作,如删除操作。一般来说,该EditPolicy仅仅知道与模型有关的事情,可以用于各种类型的EditPartViewer。

CONNECTION_ENDPOINTS_ROLE:通常使用SelectionHandlesEditPolicy 子类。除了在连接结束的时候通过displaying Handles渲染selection外,该EditPolicy还知道如何移动endpoints。如果结束点可移动,EditPolicy将展示feedback,并提供Commands用于执行移动操作。

CONNECTION_ROLE:ConnectionEditPart应该具有的基本Role(而不是COMPONENT_ROLE),Connections与components稍有不同:Connections典型的删除是从它的源、目标结点间去掉connection,而不必从它的parent中去掉。

CONTAINER_ROLE:大多数有children的EditParts应该具有的基本Role,一个容器可能涉及adds/orphans, 和 creates/deletes。

PRIMARY_DRAG_ROLE :用于允许用户拖拽EditPart,用户可以通过clicking和dragging直接拖拽它,也可以间接地通过点击EditPart创建的Handle来完成。

LAYOUT_ROLE :它被置于有图形布局(graphical layout)的容器EditPart上。如果布局有约束(constraints),它将为输入计算合理的约束;否则它可能除了有child的index外,没有约束。(it may have no constraints other than the index where children will be placed.)

GRAPHICAL_NODE_ROLE :A node supports connections to terminals.当创建、操作连接时,包含这个Role的Editpolicy会分析request的数据,来在图形view上做“hit testing”,并且判断这个connection的语义。

CONNECTION_ENDPOINTS_ROLE:允许用户以图形的方式拖拽一个connectionEditPart的端点。

CONNECTION_BENDPOINTS_ROLE :允许用户在连接的中间拖拽和创建拐点(bendpoint).

SELECTION_FEEDBACK_ROLE :这个Role仅仅是个反馈(feedback)。当鼠标进入并停留在对象上时,选择工具将向parts发出两种request。EditPolicy实现这个Role会在某方面改变EditPart的View,或弹出提示和标签等等。

TREE_CONTAINER_ROLE      
本地SWT Tree的Layout Role的等价物。这个EditPolicy应该在树上显示反馈并计算索引,就像在file explorer里拖拽一样。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值