|
Runtime | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.eclipse.gef.editpolicies.AbstractEditPolicy
org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy
The base canonical editpolicy class. This edit policy will register itself with the model server to receive semantic events fired to its host editpart. It will create, if necessary, notation elements for all semantic elements inserted into the host element or delete the notation element for the semantic element removed from the host element.
This editpolicy will create the necessary notation element by simply
returning a CreateCommand.
CanonicalEditPolicy.refreshSemanticChildren(),
will create or delete notation elements
as required.,
CanonicalEditPolicy.getCreateViewCommand(CreateRequest),
CanonicalEditPolicy.shouldDeleteView(View)| Nested Class Summary | |
protected static class |
CanonicalEditPolicy.CanonicalElementAdapter
Adds String.class adaptablity to return a factory hint. |
| Field Summary |
| Fields inherited from interface org.eclipse.gef.EditPolicy |
COMPONENT_ROLE, CONNECTION_BENDPOINTS_ROLE, CONNECTION_ENDPOINTS_ROLE, CONNECTION_ROLE, CONTAINER_ROLE, DIRECT_EDIT_ROLE, GRAPHICAL_NODE_ROLE, LAYOUT_ROLE, NODE_ROLE, PRIMARY_DRAG_ROLE, SELECTION_FEEDBACK_ROLE, TREE_CONTAINER_ROLE |
| Fields inherited from interface org.eclipse.gef.RequestConstants |
REQ_ADD, REQ_ALIGN, REQ_ALIGN_CHILDREN, REQ_CLONE, REQ_CONNECTION_END, REQ_CONNECTION_START, REQ_CREATE, REQ_CREATE_BENDPOINT, REQ_DELETE, REQ_DELETE_DEPENDANT, REQ_DIRECT_EDIT, REQ_MOVE, REQ_MOVE_BENDPOINT, REQ_MOVE_CHILDREN, REQ_OPEN, REQ_ORPHAN, REQ_ORPHAN_CHILDREN, REQ_RECONNECT_SOURCE, REQ_RECONNECT_TARGET, REQ_RESIZE, REQ_RESIZE_CHILDREN, REQ_SELECTION, REQ_SELECTION_HOVER |
| Constructor Summary | |
CanonicalEditPolicy()
|
|
| Method Summary | |
void |
activate()
Registers with the model server to receive semantic events targeted to the host editpart. |
protected boolean |
addListenerFilter(java.lang.String filterId,
NotificationListener listener,
EObject element)
Adds a listener filter by adding the given listener to a passed notifier. |
protected boolean |
addListenerFilter(java.lang.String filterId,
NotificationListener listener,
EObject element,
EStructuralFeature feature)
Adds a listener filter by adding the given listener to a passed notifier. |
protected java.util.List |
cleanCanonicalSemanticChildren(java.util.Collection viewChildren,
java.util.Collection semanticChildren)
Synchronizes the semanticChildren the viewChildren to discover if any of the semanticChildren don't have a corresponding view. |
protected java.util.List |
createViews(java.util.List eObjects)
Creates a View element for each of the supplied semantic elements. |
void |
deactivate()
Unregisters all registered model server listeners. |
protected boolean |
deleteViews(java.util.Iterator views)
Deletes a list of views. |
void |
enableRefresh(boolean enable)
Disables the editpolicy. |
protected void |
executeCommand(Command cmd)
Executes the supplied command inside an unchecked action |
protected CanonicalStyle |
getCanonicalStyle()
gets the canonical style that may be installed on the host shape compartment view. |
protected Command |
getCreateViewCommand(CreateRequest request)
Returns a CreateCommand for each view descriptor contained
in the supplied request without forwarding create requests to the
host editpart. |
protected ICommand |
getCreateViewCommand(CreateViewRequest.ViewDescriptor descriptor)
|
protected CreateViewRequest |
getCreateViewRequest(java.util.List descriptors)
Return a create view request. |
protected java.lang.String |
getDefaultFactoryHint()
Returns the default factory hint. |
protected Command |
getDeleteViewCommand(View view)
gets a Command to delete the supplied View. |
protected java.lang.String |
getFactoryHint(IAdaptable elementAdapter)
Clients may override this method to return an appropriate factory hint for the supplied semantic element. |
protected java.lang.String |
getFactoryHint(IAdaptable elementAdapter,
java.lang.String defaultHint)
Return a factory hint to assign to this element. |
static java.util.List |
getRegisteredEditPolicies(EObject element)
Returns the Canonical EditPolicies mapped to the supplied element.
|
static java.util.List |
getRegisteredEditPolicies(EObject element,
java.lang.Class clazz)
Returns the enabled Canonical EditPolicies mapped
to the supplied element that are an instance of the supplied
clazz. |
protected abstract java.util.List |
getSemanticChildrenList()
Return the host's semantic children. |
EObject |
getSemanticHost()
Return the semantic element to be listened to by this editpolicy. |
protected java.util.List |
getViewChildren()
Return the host's model children. |
protected CreateViewRequest.ViewDescriptor |
getViewDescriptor(EObject element)
Convenience method to create a view descriptor. |
protected CreateViewRequest.ViewDescriptor |
getViewDescriptor(IAdaptable elementAdapter,
java.lang.Class viewKind,
java.lang.String hint,
int index)
Return a view descriptor. |
EditPartViewer |
getViewer()
|
protected int |
getViewIndexFor(EObject semanticChild)
This method tries to locate the position that the view will be inserted into it's parent. |
protected java.util.List |
getViewReferers(EObject element)
Return a list of all the notation elements mapped to the supplied semantic element. |
protected void |
handleNotificationEvent(Notification event)
Handles NotificationEvent and resynchronizes the canonical
container if the event should be handled. |
protected IGraphicalEditPart |
host()
|
boolean |
isActive()
check is this edit policy is active or not |
boolean |
isEnabled()
Return true if the editpolicy is enabled and its host is visible; otherwise false. |
protected boolean |
isHostStillValid()
Return true if the host is active and its view has not been deleted; otherwise false |
protected void |
makeViewsImmutable(java.util.List createdViews)
Sets views as being immutable, meaning that they are unmodifiable as non-persisted views. |
protected void |
makeViewsMutable(java.util.List createdViews)
Sets state on views to allow for modification without changing their non-persisted status. |
void |
notifyChanged(Notification notification)
Event callback: filters out non IElementEvent events. |
protected void |
postProcessRefreshSemantic(java.util.List viewDescriptors)
Allow for post processing of the refresh semantic to set the view mutable state and allow subclasses to add functionality. |
void |
refresh()
Resynchronize the canonical container. |
protected void |
refreshOnActivate()
Refresh that is called on activate of the editpolicy to ensure that all relevant editparts can receive canonically created connections. |
protected void |
refreshSemantic()
Redirects the call to CanonicalEditPolicy.refreshSemanticChildren(). |
protected java.util.List |
refreshSemanticChildren()
Updates the set of children views so that it is in sync with the semantic children. |
protected void |
removeListenerFilter(java.lang.String filterId)
Removes a listener previously added with the given id |
protected EObject |
resolveSemanticElement()
Convenience method to return the host's semantic element. |
void |
setEnable(boolean enable)
Sets enable(aBoolean) on all the edit policies of the semantic host. |
void |
setHost(EditPart host)
Asserts that the supplied host is an IGraphicalEditPart instance. |
protected boolean |
shouldDeleteView(View view)
returns true to always delete a view if required. |
protected boolean |
shouldHandleNotificationEvent(Notification event)
Determines if the the NotificationEvent should be handled / processed
by the editpolicy. |
| Methods inherited from class org.eclipse.gef.editpolicies.AbstractEditPolicy |
debugFeedback, eraseSourceFeedback, eraseTargetFeedback, getCommand, getHost, getTargetEditPart, showSourceFeedback, showTargetFeedback, toString, understandsRequest |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public CanonicalEditPolicy()
| Method Detail |
public static java.util.List getRegisteredEditPolicies(EObject element)
Canonical EditPolicies mapped to the supplied element.
Canonical EditPolicies are mapped to their CanonicalEditPolicy.getSemanticHost() as
the key. A single key may have multiple editpolicies registered against it.
element - a semantic element
public static java.util.List getRegisteredEditPolicies(EObject element,
java.lang.Class clazz)
Canonical EditPolicies mapped
to the supplied element that are an instance of the supplied
clazz. Canonical EditPolicies are mapped to their
CanonicalEditPolicy.getSemanticHost()as the key. A single key may have multiple
editpolicies registered against it.
element - a semantic elementclazz - a class type
public void setHost(EditPart host)
IGraphicalEditPart instance.
setHost in interface EditPolicyprotected final IGraphicalEditPart host()
(IGraphicalEditPart)host().protected abstract java.util.List getSemanticChildrenList()
protected java.lang.String getDefaultFactoryHint()
host().getView().getSemanticType()
protected java.lang.String getFactoryHint(IAdaptable elementAdapter,
java.lang.String defaultHint)
elementAdapter - adapter that adapts to EObject.defaultHint - a default factory hint (typically the host's factory hint).
CanonicalEditPolicy.getFactoryHint(IAdaptable)protected java.lang.String getFactoryHint(IAdaptable elementAdapter)
elementAdapter - adapter that adapts to EObject.
CanonicalEditPolicy.getFactoryHint(IAdaptable, String)protected final boolean deleteViews(java.util.Iterator views)
views - an iterator on a list of views.
protected Command getDeleteViewCommand(View view)
Command to delete the supplied View.
view - view to use
protected boolean shouldDeleteView(View view)
view - to consider
protected java.util.List getViewReferers(EObject element)
element - to use
Viewsprotected int getViewIndexFor(EObject semanticChild)
semanticChild -
protected final java.util.List createViews(java.util.List eObjects)
View element for each of the supplied semantic elements.
eObjects - list of semantic element
IAdaptable that adapt to View.protected void executeCommand(Command cmd)
unchecked action
cmd - command that can be executed (i.e., cmd.canExecute() == true)protected Command getCreateViewCommand(CreateRequest request)
CreateCommand for each view descriptor contained
in the supplied request without forwarding create requests to the
host editpart.
request - a create request
protected ICommand getCreateViewCommand(CreateViewRequest.ViewDescriptor descriptor)
descriptor -
protected CreateViewRequest getCreateViewRequest(java.util.List descriptors)
descriptors - a CreateViewRequest.ViewDescriptor list.
protected CreateViewRequest.ViewDescriptor getViewDescriptor(IAdaptable elementAdapter,
java.lang.Class viewKind,
java.lang.String hint,
int index)
elementAdapter - semantic elementviewKind - type of view to createhint - factory hintindex - index
protected CreateViewRequest.ViewDescriptor getViewDescriptor(EObject element)
CanonicalEditPolicy.getViewDescriptor(IAdaptable, Class, String, int)
element - semantic element.
public void activate()
CanonicalEditPolicy.getSemanticHost()
activate in interface EditPolicyCanonicalEditPolicy.deactivate()protected void refreshOnActivate()
public boolean isEnabled()
public void enableRefresh(boolean enable)
enable - public void setEnable(boolean enable)
enable - public final boolean isActive()
public EObject getSemanticHost()
host().getView().resolveSemanticElement() by default.public void deactivate()
deactivate in interface EditPolicyCanonicalEditPolicy.activate()
protected boolean addListenerFilter(java.lang.String filterId,
NotificationListener listener,
EObject element)
filterId - A unique filter id (within the same editpart instance)listener - A listener instance
java.lang.NullPointerException - if either filterId or listner parameters are null.
protected boolean addListenerFilter(java.lang.String filterId,
NotificationListener listener,
EObject element,
EStructuralFeature feature)
filterId - A unique filter id (within the same editpart instance)listener - A listener instance
java.lang.NullPointerException - if either filterId or listner parameters are null.protected void removeListenerFilter(java.lang.String filterId)
filterId - the filter idpublic final void notifyChanged(Notification notification)
notifyChanged in interface NotificationListenernotification - the notification objectprotected final boolean isHostStillValid()
protected void handleNotificationEvent(Notification event)
NotificationEvent and resynchronizes the canonical
container if the event should be handled.
event - NotificationEvent to handle.protected boolean shouldHandleNotificationEvent(Notification event)
NotificationEvent should be handled / processed
by the editpolicy.
event - NotificationEvent to check
true if event should be handled, false otherwise.protected java.util.List getViewChildren()
Viewspublic final void refresh()
protected void refreshSemantic()
CanonicalEditPolicy.refreshSemanticChildren().
protected final void makeViewsMutable(java.util.List createdViews)
createdViews - List of view adapters that were created during the
CanonicalEditPolicy.refreshSemantic() operationprotected final void makeViewsImmutable(java.util.List createdViews)
createdViews - List of view adapters that were created during the
CanonicalEditPolicy.refreshSemantic() operationprotected final java.util.List refreshSemanticChildren()
The update is performed by comparing the exising views with the set of
semantic children returned from CanonicalEditPolicy.getViewChildren(). Views whose
semantic element no longer exists are removed.
New semantic children have their View created. Subclasses must override getSemanticChildren().
Unlike AbstractEditPart#refreshChildren(), this refresh will not
reorder the view list to ensure both it and the semantic children are
in the same order since it is possible that this edit policy will handle
a specifc subset of the host's views.
The host is refreshed if a view has created or deleted as a result of this refresh.
List of new View objects that were created as a result of
the synchronization
protected final java.util.List cleanCanonicalSemanticChildren(java.util.Collection viewChildren,
java.util.Collection semanticChildren)
semanticChildren that do have a view are
removed from the list.
viewChildren - List of View elements that already exist in the container.semanticChildren - List of semantic elements that are candidates for synchronization
List of orphans views that should be deleted from the container.protected void postProcessRefreshSemantic(java.util.List viewDescriptors)
viewDescriptors - List of IAdaptable that adapt to Viewprotected final EObject resolveSemanticElement()
host().getView().resolveSemanticElement();
EObjectprotected CanonicalStyle getCanonicalStyle()
CanonicalStylepublic final EditPartViewer getViewer()
|
Runtime | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
Guidelines for using Eclipse APIs.
Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.