Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » is the Layout Service example not compatible with GMF 2.1?
is the Layout Service example not compatible with GMF 2.1? [message #200974] Thu, 07 August 2008 08:10 Go to next message
Seweryn Niemiec is currently offline Seweryn NiemiecFriend
Messages: 80
Registered: July 2009
Member
Hi,

I've tried to call my AbstractLayoutNodeProvider (which is working
without problems as default "Arrange All" layouter) from custom Action.
I use analogous code as in the action of the Layout Service Example but
it doesn't work as expected anymore.

Modifications of a diagram made by a call of the SquareLayoutAction are
not undoable and are not animated when working with GMF 2.1.

The easiest way to solve my problem would be to override ArrangeAction
from org.eclipse.gmf.runtime.diagram.ui.actions.internal and replace
just one simple method, but of course I can't do that because it's
internal class.

I've tried something like this:

EditPart container = selectedEditPart.getParent();
ArrangeRequest arrangeRequest =
new ArrangeRequest(RequestConstants.REQ_ARRANGE_DEFERRED,
"my layout name");
arrangeRequest.setViewAdaptersToArrange(container.getChildre n());
Command arrangeCommand = container.getCommand(arrangeRequest);

But I dunno what next. Simple arrangeCommand.extecute() doesn't work.

Could someone give my any hint in what direction should i go?

Greetings,
Seweryn
Re: is the Layout Service example not compatible with GMF 2.1? [message #201052 is a reply to message #200974] Thu, 07 August 2008 15:28 Go to previous message
Seweryn Niemiec is currently offline Seweryn NiemiecFriend
Messages: 80
Registered: July 2009
Member
Seweryn Niemiec wrote:
> But I dunno what next. Simple arrangeCommand.extecute() doesn't work.

OK. This code works, but I dunno exactly why (maybe someone will
find it useful, it arranges all siblings of currently selected node):

import org.eclipse.gef.EditPart;
import org.eclipse.gef.commands.Command;
import org.eclipse.gmf.runtime.diagram.ui.actions.ActionIds;
import org.eclipse.gmf.runtime.diagram.ui.requests.ArrangeRequest;

....get selectedEditPart from IStructuralSelection...
EditPart container = selectedEditPart.getParent();

ArrangeRequest arrangeRequest =
new ArrangeRequest(ActionIds.ACTION_ARRANGE_ALL, "my layout name");

arrangeRequest.setPartsToArrange(container.getChildren());
Command arrangeCommand = container.getCommand(arrangeRequest);

Using ActionIds.ACTION_ARRANGE_ALL was a key to get it working.

Layout provider will get the "my layout string" as parameter,
so it will be able to choose right layout algorithm implementation.

To run the command I use something like this:

Object stack = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getActivePage().getActivePart().getAdapter(CommandStack.cla ss)
((DiagramCommandStack)stack).execute(arrangeCommand, null)

Greetings,
Seweryn
Previous Topic:How to get the result of a CreateElementCommand when doing Drag 'n Drop
Next Topic:Problems with creations of Metamodel or Specialization Types with Palette
Goto Forum:
  


Current Time: Fri Apr 26 15:54:59 GMT 2024

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

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

Back to the top