Modifying position from IGraphicalEditPart [message #162969] |
Wed, 28 November 2007 04:39  |
Eclipse User |
|
|
|
Originally posted by: boucher.fbk.eu
Hello,
Acyually, I'm trying to programatically change the position of elements
based on a reorganization algortihm. I have access to the
IGraphicalEditPart of the element but I don't know how to modify the
position! I have tried to get access to the Bounds thanks to the
getLayoutConstraint() but when I try to modify them, I get a "Cannot
modify resource set without a write transaction". COuld you help me?
Sorry for this basic question but I started using GMF last week.
Thank you.
|
|
|
Re: Modifying position from IGraphicalEditPart [message #162992 is a reply to message #162969] |
Wed, 28 November 2007 06:24   |
Eclipse User |
|
|
|
Originally posted by: external.deyaa.adranale.de.bosch.com
Hi,
using Bounds is the right way to modify the positions.
the exception means that you can't modiy the diagram outside a
transaction. this is necessary in GMF for several reasons, like supporting
Undo/Redo.
To make the code work, simply surround your code with the following:
TransactionalEditingDomain editingDomain = TransactionUtil
.getEditingDomain(model);
List<IFile> affectedFiles = new LinkedList<IFile>();
affectedFiles.add(WorkspaceSynchronizer.getFile(yourmodel.eR esource()));
AbstractTransactionalCommand command = new AbstractTransactionalCommand(
editingDomain, "Combine Domains", affectedFiles)
{
@Override
protected CommandResult doExecuteWithResult(
IProgressMonitor monitor, IAdaptable info)
throws ExecutionException
{
// your code goes here
return CommandResult.newOKCommandResult();
}
};
try
{
OperationHistoryFactory.getOperationHistory().execute(comman d,
new NullProgressMonitor(), null);
}
catch (ExecutionException e)
{
MessageDialog.openError(getShell(), "error", e
.getMessage());
XXXDiagramEditorPlugin.getInstance().logError(
"error", e);
}
I hope this will be helpful!
Deyaa
|
|
|
|
Powered by
FUDForum. Page generated in 0.02630 seconds