Adding a connection using a context menu action [message #225263] |
Thu, 09 April 2009 12:51 |
Robert Wloch Messages: 109 Registered: July 2009 |
Senior Member |
|
|
Hi,
I'm trying to add a figure and a connection to an already existing figure
using a context menu action on the existing figure. So far, I get the new
figure created by creating a CreateUnspecifiedTypeRequest (that's creating
an internal CreateViewAndElementRequest):
CreateUnspecifiedTypeRequest unspecifiedTypeRequest = new
CreateUnspecifiedTypeRequest(
elementTypes, getPreferencesHint());
request = unspecifiedTypeRequest.getRequestForType(elementType);
setRequestLocation(reqest, contextEP);
The request is send to my DiagramEditPart to get the command which is
executed (wrapped in an ICommandProxy and CompoundCommand). It does work
well for my figure Node.
Trying to create a connection the same way fails for some reason, although
I create a CreateUnspecifiedTypeConnectionRequest (that's creating an
internal CreateConnectionViewAndElementRequest):
CreateUnspecifiedTypeConnectionRequest unspecifiedTypeRequest = new
CreateUnspecifiedTypeConnectionRequest(
elementTypes, false, getPreferencesHint());
request = unspecifiedTypeRequest.getRequestForType(elementType);
if (request instanceof CreateConnectionViewAndElementRequest) {
CreateConnectionViewAndElementRequest req =
(CreateConnectionViewAndElementRequest) request;
req.setSourceEditPart(sourceEP);
req.setTargetEditPart(targetEP);
req.setSuppressibleUI(true);
req.setType(RequestConstants.REQ_CONNECTION_END);
}
Again, the request is send to my DiagramEditPart to get the command which
is executed (wrapped in an ICommandProxy and CompoundCommand) but nothing
happens. I get no error log message or alike.
Debugging the command execution revealed that the respective create
connection command is checking if it's executable but a deeply wrapped
CompoundCommand inbetween two ToggleCanonicalModeCommands returns false
upon its ICommandProxy's PromptForConnectAndEndCommand trying to open some
Dialog:
public boolean canExecute() {
return createPopupMenu() != null;
}
I thought by setting req.setSuppressibleUI(true) the command wouldn't
attempt to interact with the user? What did I miss or do wrong?
Cheers,
Rob
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03543 seconds