Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Modifying position from IGraphicalEditPart
Modifying position from IGraphicalEditPart [message #162969] Wed, 28 November 2007 04:39 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Modifying position from IGraphicalEditPart [message #163251 is a reply to message #162992] Thu, 29 November 2007 08:16 Go to previous message
Eclipse UserFriend
Originally posted by: boucher.fbk.eu

Hi,

Thank you for your help. Everything is ok now!
Previous Topic:sorting custom propsheet in-groups
Next Topic:Connecting a TextLabel to a figure descriptor
Goto Forum:
  


Current Time: Sun May 11 16:32:10 EDT 2025

Powered by FUDForum. Page generated in 0.02630 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top