Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Graphiti fails to handle resize after custom feature addition
Graphiti fails to handle resize after custom feature addition [message #660548] Sat, 19 March 2011 06:50 Go to next message
Eclipse UserFriend
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 #660686 is a reply to message #660548] Mon, 21 March 2011 07:50 Go to previous messageGo to next message
Matthias Gorning is currently offline Matthias GorningFriend
Messages: 81
Registered: April 2010
Location: Germany
Member
I've tested it also and I was able to perform a resize without a save of the diagram.
Re: Graphiti fails to handle resize after custom feature addition [message #661497 is a reply to message #660686] Thu, 24 March 2011 22:57 Go to previous messageGo to next message
Eclipse UserFriend
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.
>
Re: Graphiti fails to handle resize after custom feature addition [message #661596 is a reply to message #661497] Fri, 25 March 2011 14:15 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
When I try that in the finished tutorial, it works as expected (can resize
after the rename). But when I try to build the tutorial from scratch along
the snippets from the written tutorial, I can reproduce this as well. And
there is no obvious difference... - Strange

Could you please open a Bugzilla to track that? We should do some
investigation here.

Thanks,
Michael


"Wendell Beckwith" wrote in message news:imghrh$8q7$1@news.eclipse.org...

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.
>
Re: Graphiti fails to handle resize after custom feature addition [message #1014878 is a reply to message #661596] Tue, 26 February 2013 16:22 Go to previous message
Sylvester Oluyomi is currently offline Sylvester OluyomiFriend
Messages: 2
Registered: February 2013
Junior Member
I have just started learning to use Graphiti. I encountered this same problem trying to resize a shape, following the tutorial. Is there a solution to this as yet? Thanks.
Previous Topic:Disable reconnection
Next Topic:How to implement the undo&redo functions?
Goto Forum:
  


Current Time: Sat Apr 20 02:49:00 GMT 2024

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

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

Back to the top