Command#canExecute is false, why ? [message #535900] |
Wed, 26 May 2010 05:32 |
Eclipse User |
|
|
|
I created a simple DropEditPolicy which always inserts the same basic node (Activity_2003), but the created CompoundCommand always is not executable (canExecute() == false). Can anyone give me a clue where's the problem ?
public class DropObjectEditPolicy extends GraphicalEditPolicy implements EditPolicy {
public Command getCommand(Request request) {
if (RequestConstants.REQ_DROP_OBJECTS.equals(request.getType())) {
DropObjectsRequest dndRequest = (DropObjectsRequest) request;
return getDropCommand(dndRequest);
}
return null;
}
private Command getDropCommand(DropObjectsRequest dndRequest) {
ProcessEditPart editor = (ProcessEditPart) getHost();
IElementType type = ProcessElementTypes.Activity_2003; // Basic node, can be placed anywhere
ViewAndElementDescriptor viewDescriptor = new ViewAndElementDescriptor(
new CreateElementRequestAdapter(new CreateElementRequest(type)),
Node.class,
((IHintedType) type).getSemanticHint(),
editor.getDiagramPreferencesHint());
CreateViewAndElementRequest req = new CreateViewAndElementRequest(viewDescriptor);
CompoundCommand cmd = new CompoundCommand("Drop new activity");
cmd.add(editor.getCommand(req));
System.out.println(">>>>>> DropObjectEditPolicy.getDropCommand() canExecute()=" + cmd.canExecute());
return cmd;
}
public boolean understandsRequest(Request request) {
return RequestConstants.REQ_DROP_OBJECTS.equals(request.getType()) && request instanceof DropObjectsRequest;
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.08050 seconds