Java Reference
In-Depth Information
Creation
Table 9-4 details the elements involved in creation interactions.
Table 9-4
Creation Interactions
Tools
Requests
Edit Policies and Roles
Actions
CreationTool
REQ_CREATE
CONTAINER_ROLE
CopyTemplateAction
Create
LAYOUT_ROLE
PasteTemplateAction
TREE_CONTAINER_ROLE
ContainerEditPolicy
LayoutEditPolicy
A CreateRequest asks an EditPart to create a new child. The ID
REQ_CREATE identifies the request. Creation can occur through three different
methods: clicking, dragging, or pasting. The request provides the location,
object, and object type being created. A CreationFactory provides the object
and its type. The request hides the factory and provides access to the created
object directly, caching it in case multiple EditPolicies need access to the created
object. In some cases, the request contains a size attribute.
Producing CreateRequests
The creation tool provides a “loaded cursor” mode that attempts to create
an object at the mouse location when clicking. If the mouse is clicked and
dragged, the tool tracks the size of the rectangle defined by the user. The creation
tool can be placed on the palette using a CreationToolEntry . When the mouse
is released, the tool either repeats the process or switches back to the default tool.
Creation can also be performed using native drag-and-drop. The drag source
can be anything, but it is typically the PaletteViewer . A palette entry that
takes a template is added to the palette. The TemplateTransfer is used to
transfer the template, which is just an Object , from the drag source to the drop
target. A TemplateTransferDragSourceListener must be added to the
PaletteViewer . Similarly, the viewer must have a TemplateTransferDrop
TargetListener . Because a template is model specific, the application must
extend the drop target listener to convert the template into a CreationFactory
for the request.
A special palette entry called the CombinedTemplateCreationEntry sup-
ports both the creation tool and drag-and-drop styles of creation.
 
Search WWH ::




Custom Search