Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Resize connection decorator not executed(The resizeShape() method is never called even if canResize() returns true)
Resize connection decorator not executed [message #1221878] Wed, 18 December 2013 15:54 Go to next message
Martin Hanysz is currently offline Martin HanyszFriend
Messages: 30
Registered: November 2013
Member
Hello,

I am currently struggeling with creating resizable connection labels.
I create a FreeFormConnection with two ConnectionDecorators. One of the ConnectionDecorators holds a MultiText GraphicsAlgorithm that is directly editable, which works fine.

Now I need that ConnectionDecorator to be resizable in case the user enters a long text that does not fit into the current bounding box of the decorator. I want the user to be able to resize the decorator manually instead of doing that automatically when the text is changed.

To achieve this, I created a ResizeConnectionLabelFeature that extends DefaultResizeShapeFeature. It overrides the canResize() method to return true if the context holds a PictogramElement that is an instance of ConnectionDecorator and the GraphicsAlgorithm of that PictogramElement is an instance of AbstractText. The canResize() method is properly called and returns true, but the resizeShape() method is never called when I actually drag&drop the border of the MultiText (which also shows the resize handles) to resize it.

So my question is: is there a special behavior associated with resizing ConnectionDecorators? Why is ResizeConnectionLabelFeature#resizeShape() never called? How do I resize a GraphicsAlgorithm contained in a ConnectionDecorator?

Best regards,
Martin
Re: Resize connection decorator not executed [message #1222044 is a reply to message #1221878] Thu, 19 December 2013 14:55 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Martin,

this sounds like a bug. Would you file this as a bugzilla?

Do you have a small example containing the setup you describe for easy
reproduction?

Thanks,
Michael
Re: Resize connection decorator not executed [message #1222055 is a reply to message #1222044] Thu, 19 December 2013 15:20 Go to previous messageGo to next message
Martin Hanysz is currently offline Martin HanyszFriend
Messages: 30
Registered: November 2013
Member
Hello Michael,

I modified the tutorial example in the following way:
TutorialFeatureProvider.getResizeShapeFeature() now looks like this:
@Override
public IResizeShapeFeature getResizeShapeFeature(IResizeShapeContext context) {
	Shape shape = context.getShape();
	Object bo = getBusinessObjectForPictogramElement(shape);
	if (bo instanceof EClass) {
		return new TutorialResizeEClassFeature(this);
	} else if (shape instanceof ConnectionDecorator && shape.getGraphicsAlgorithm() instanceof AbstractText) {
		return new ResizeConnectionLabelFeature(this);
	}
	return super.getResizeShapeFeature(context);
}


and the class ResizeConnectionLabelFeature looks like this:
public class ResizeConnectionLabelFeature extends DefaultResizeShapeFeature {

	public ResizeConnectionLabelFeature(IFeatureProvider fp) {
		super(fp);
	}

	@Override
	public boolean canResizeShape(IResizeShapeContext context) {
		System.out.println("ResizeConnectionLabelFeature.canResizeShape() was called");
		return true;
	}

	@Override
	public void resizeShape(IResizeShapeContext context) {
		// Just call super.resizeShape().
		System.out.println("ResizeConnectionLabelFeature.resizeShape() was called");
		super.resizeShape(context);
	}

}


Now go ahead and start the tutorial as an eclipse application, add two EClasses and connect them. Once you select the label of the connection, your console should show that canResizeShape() was called, but if you actually resize it, there is no output.
In fact, doing a resize that would change the position of the label actually changes it (just drag the top or left border and the labe will change position, but not resize).

I will also file a bug report for this one.

Best regards,
Martin
Re: Resize connection decorator not executed [message #1222072 is a reply to message #1222055] Thu, 19 December 2013 15:49 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Martin,

thanks, I was able to debug this now.

The framework currently does not offer the option to resize decorators, it
seems this is simply not yet implemented. Only moving is supported
(DefaultMoveDecoratorFeature). The canResize is only called for deciding if
the handles are drawn aound a shape or not.

Maybe we need a ResizeDecoratorFeature...

Michael
Previous Topic:IllegalValueException when loading diagram
Next Topic:I can create a graph editor [GMF] with graphiti instead of GEF??
Goto Forum:
  


Current Time: Thu Dec 18 09:36:06 GMT 2014

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

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