|
|
|
|
|
Re: Restricting the allowed ends when creating a relationship element type? [message #1747393 is a reply to message #1747278] |
Mon, 14 November 2016 04:46  |
Eclipse User |
|
|
|
no you cannot do that by an advice.
why ?
In the engine of elementtype, when advice returns a command that cannot be executed (canExecute()==false), the command is not added in the chain command. So you cannot restrict it. Only the helper send a command that can fail all the chained command.
Maybe there is means with the approved request. But we need to dig.
Patrick
see code from org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelper
private ICommand getEditCommand(IEditCommandRequest req, IEditHelperAdvice[] advice) {
ICompositeCommand command = createCommand(req);
// Get 'before' commands from matching element type
// specializations
if (advice != null) {
for (int i = 0; i < advice.length; i++) {
IEditHelperAdvice nextAdvice = advice[i];
// Before commands
ICommand beforeAdvice = nextAdvice.getBeforeEditCommand(req);
if (beforeAdvice != null) {
if (beforeAdvice.canExecute()) {
command.compose(beforeAdvice);
} else {
return beforeAdvice;
}
}
}
}
// Check if the parameter has been set to ignore the default edit command.
Object replaceParam = req
.getParameter(IEditCommandRequest.REPLACE_DEFAULT_COMMAND);
if (replaceParam != Boolean.TRUE) {
// Get 'instead' command from this edit helper
ICommand insteadCommand = getInsteadCommand(req);
if (insteadCommand != null) {
if (insteadCommand.canExecute()) {
command.compose(insteadCommand);
} else {
return insteadCommand;
}
}
}
// Get 'after' commands from matching element type
// specializations
if (advice != null) {
for (int i = 0; i < advice.length; i++) {
IEditHelperAdvice nextAdvice = advice[i];
// After commands
ICommand afterAdvice = nextAdvice.getAfterEditCommand(req);
if (afterAdvice != null) {
if (afterAdvice.canExecute()) {
command.compose(afterAdvice);
} else {
return afterAdvice;
}
}
}
}
return command.isEmpty() ? null
: command;
}
|
|
|
Powered by
FUDForum. Page generated in 1.12336 seconds