Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Change Figurue of EditPart by code
Change Figurue of EditPart by code [message #646660] Wed, 29 December 2010 17:34 Go to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi all,

I have a EditPart that contains a method to change the figure of it to a small rectange with black background. Evererything works fine except the resizing by code. I cannot find anything wrong.

//**************************************************
//Clear all children (IFigures and EditParts)
//**************************************************
this.figure.getChildren().clear();
this.children.clear();
		
//**************************************************
//Create the new figure (Rectangle with black background)
//**************************************************
RectangleFigure rf = new RectangleFigure();
rf.setBackgroundColor(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
rf.setSize(1, 1);
		
ToolbarLayout layoutThis = new ToolbarLayout();
//layoutThis.setStretchMinorAxis(true);
layoutThis.setMinorAlignment(ToolbarLayout.ALIGN_TOPLEFT);

layoutThis.setSpacing(0);
layoutThis.setVertical(true);

rf.setLayoutManager(layoutThis);

//**************************************************
//Set the new Figure
//**************************************************
this.figure.add(rf);
this.figure.setSize(1, 1);


Any ideas?

Thanks,

Ralph
Re: Change Figurue of EditPart by code [message #646707 is a reply to message #646660] Thu, 30 December 2010 10:18 Go to previous message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi Ralph,

to resize a EditPart you need to use the SetBoundsCommand. Try the following code:

Rectangle rect = figure.getClientArea().getCopy();
rect.setSize(10, 10);
SetBoundsCommand sbc = new SetBoundsCommand(this.getEditingDomain(), "change size", new EObjectAdapter((View)this.getModel()), rect);
getEditDomain().getCommandStack().execute(new ICommandProxy(sbc));


Ralph
Previous Topic:GMF prevent cycles
Next Topic:can GMF guru help me please
Goto Forum:
  


Current Time: Thu Apr 25 03:59:06 GMT 2024

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

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

Back to the top