Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Custom Editpart events: Resize of Parent vs. Movement of child(Why is there a difference in treatment?)
Custom Editpart events: Resize of Parent vs. Movement of child [message #658993] Thu, 10 March 2011 16:03
Patrick  is currently offline Patrick
Messages: 10
Registered: December 2010
Junior Member
Hello Smile

I have a custom editpart for a node that lives in the compartment of another one. I want its figure to be of exactly the same size as the compartment figure.
First question, which might solve the main one, is whether this has to be done with a custom editpart at all? (I've tried all kinds of layouts and none had the desired outcome, have i missed something?)

Second part which is also confusing me in general. I have succeed in writing some code that seems to do what i want. BUT the child is only resized if i move it. If i just resize the parent it stays the same size. Though my custom handleNotification is also called in this case but it has no effect. The method resizing the child to its parent is not dependent on the type of notification.
What is the difference in those two calls to handleNotification?

Thank you Smile

ps: is there any good way to avoid getter cascades to get the right figure? The cascade seems rather dangerous to me...

public class CustomStoryPatternEditPart extends MatchingPatternEditPart {

	public CustomStoryPatternEditPart(View view) {
		super(view);
	}

	private void updateFigure() {
		
		StoryPattern patternNode = (StoryPattern) ((View) getModel()).getElement();
		RoundedRectangle primaryRectangle = (RoundedRectangle) getPrimaryShape();
		primaryRectangle.setLayoutManager(null);
		((RoundedRectangle) primaryRectangle.getChildren().get(0)).setLayoutManager(new FlowLayout());
		
		CustomMatchingStoryNodeEditPart aStoryNode = (CustomMatchingStoryNodeEditPart) this.getParent().getParent();
		
		IFigure rectangleFront = (IFigure) ((IFigure) aStoryNode.getFigure().getChildren().get(0)).getChildren().get(1);
		rectangleFront =  (IFigure) rectangleFront.getChildren().get(0);
		IFigure rectangleContent = (IFigure) rectangleFront.getChildren().get(1);
		Rectangle bounds = ((IFigure) rectangleContent.getChildren().get(1)).getBounds();
		
		primaryRectangle.setBounds(bounds);
		((RoundedRectangle) primaryRectangle.getChildren().get(0)).setBounds(bounds);
		((RoundedRectangle) primaryRectangle.getChildren().get(0)).setOpaque(true);
		primaryRectangle.setOpaque(true);
	}
	
	
	@Override
	protected void handleNotificationEvent(Notification event) {
		super.handleNotificationEvent(event);
		updateFigure();
	}
	

}
Previous Topic:gmf editor selection change events
Next Topic:figure's border color in GMF 2.2
Goto Forum:
  


Current Time: Sat Oct 25 09:48:46 GMT 2014

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

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