Graphiti fails to handle resize after custom feature addition [message #660548] |
Sat, 19 March 2011 06:50 |
Eclipse User |
|
|
|
Originally posted by: wbeckwith.gmail.com
I'm working through the tutorial in Graphiti version
0.8.0.v20110311-1155 and I think the tutorial exposes a bug in the
resize handling. I just finished tutorial step of adding the custom
feature to do the rename of an EClass and the steps to reproduce the
issue are the following:
1. Start the editor and create a new EClass with name "A".
2. Verify the EClass can't be moved or resized.
3. Now using the custom feature in the context menu, rename the class to
"A2".
4. Verify the EClass can now be moved but it can't be resized.
I'm unable to resize the class until I actually save the diagram.
Did I miss something somehow or is this a bug I need to report?
Wb
|
|
|
|
Re: Graphiti fails to handle resize after custom feature addition [message #661497 is a reply to message #660686] |
Thu, 24 March 2011 22:57 |
Eclipse User |
|
|
|
Originally posted by: wbeckwith.gmail.com
Took a while to get back to this but I've triple checked my code and I
still see this failing. Here is the code for my resize feature:
package com.itko.lisa.graphiti.tutorial.features;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.IResizeShapeContext;
import org.eclipse.graphiti.features.impl.DefaultResizeShapeFeature ;
import org.eclipse.graphiti.mm.pictograms.Shape;
/**
*
*/
public class TutorialResizeEClassFeature extends DefaultResizeShapeFeature
{
/**
* @param featureProvider
*/
public TutorialResizeEClassFeature(IFeatureProvider featureProvider)
{
super(featureProvider);
}
/*
* @see
*
org.eclipse.graphiti.features.impl.DefaultResizeShapeFeature #canResizeShape(org.eclipse.graphiti
* .features.context.IResizeShapeContext)
*/
@Override
public boolean canResizeShape(IResizeShapeContext context)
{
boolean canResize = super.canResizeShape(context);
// perform further check only if resize allowed by default
if (canResize)
{
// don't allow resize if the class name has a length of 1
Shape shape = context.getShape();
Object bo = getBusinessObjectForPictogramElement(shape);
if (bo instanceof EClass)
{
EClass c = (EClass) bo;
if (c.getName() != null && c.getName().length() == 1)
{
canResize = false;
}
}
}
return canResize;
}
}
Here's what I noticed.
1. I've added breakpoints in the resize feature and the move feature
where we do the test for whether the EClass's name is not null and and
of length 1.
2. When the diagram is 1st opened, I can see that the resize feature is
called for each of the 3 ECLasses in the saved diagram.
3. Now I use the palette to create a new EClass with the name "A" and I
can see the resize feature is called immediately for this EClass.
4. Also if I try and move EClass A, then the move feature is called and
correctly returns false preventing the move.
5. Now I right click on ECLass A and rename it to be "AA". At this
point I would think I could resize the class but I can not. I can
however move the new EClass AA.
Also if I click on any of the other 3 EClasses already on the diagram
then the resize feature is called for them, but clicking on the new AA
EClass does not invoke the resize feature.
So how do I trigger a resize without 1st saving the diagram?
On 3/21/2011 12:50 AM, Matthias Gorning wrote:
> I've tested it also and I was able to perform a resize without a save of
> the diagram.
>
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04977 seconds