[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[gmf-dev] edges not showing after copy with EcoreUtil.Copier
|
I have after create advice that supplies an
AbstractTransactionalCommand. The command uses the EcoreUtil to replace
the new object in the model with a copy of a template object. This was
my way of putting a list of template objects onto the palette. I just
add add a parameter to the normal create tool/request and my advice
makes the substitution. Here is the callback in my advice:
@Override
protected ICommand getAfterCreateCommand(final CreateElementRequest
request) {
if (request.getParameters().containsKey("templateElement") &&
request.getElementType() ==
CrosswalkElementTypes.MetadataBlock_3018) {
return new
ReplaceNewObjectWithTemplateCommand(request.getEditingDomain(), request);
}
return null;
}
Here is the way the command above works:
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor
monitor, IAdaptable info) throws ExecutionException {
EObject result = null;
EObject n = request.getNewElement();
EObject template =
(EObject)request.getParameter("templateElement");
EcoreUtil.Copier copier = new EcoreUtil.Copier(false, true);
//ViewRefactorHelper viewhelp = new ViewRefactorHelper();
EObject copy = copier.copy(template);
copier.copyReferences();
EcoreUtil.replace(n, copy);
//viewhelp.refactor(n, copy);
result = copy;
return CommandResult.newOKCommandResult(result);
}
The behavior that results is fine in terms of the semantic model, but
the notation seems to get strange in two ways.
First, the resulting node is no longer at the position at which it was
dropped. It seems to show up in the center of the content pane instead.
Second, my model includes links/edges between sub-elements within the
new node. These sub-element links do not show up unless I save, close
and reopen the editor.
As you can see I've been experimenting with the ViewRefactorHelper
class, but that didn't seem to help. I thought there was also some kind
of "recording command" superclass that I could extend that would update
the view to match the model. Any advice would be most appreciated.
many thanks,
Greg Jansen
UNC Chapel Hill