I am pretty new to this framework. I have done the tutorial and ok, i know more or less how does it works. But now that i want to do some more i dont know how to.
I wanted to move one shape into another (like drop one rectange and then drop anotherone inside of it) and it is not explained in the tutorial and I could not find other clear things on the internet. i would really appreciate your help.
package org.eclipse.graphiti.examples.tutorial.features;
public class TutorialMoveEClassFeature extends DefaultMoveShapeFeature {
public TutorialMoveEClassFeature(IFeatureProvider fp) {
super(fp);
}
@Override
public boolean canMoveShape(IMoveShapeContext context) {
boolean canMove = super.canMoveShape(context);
// perform further check only if move allowed by default feature
if (canMove) {
// don't allow move if the class name has the 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) {
canMove = false;
}
}
}
return canMove;
}
}
This is what I gor from tutorial just in case someone wants to write something in the middle.
Michael Wenz Messages: 1370 Registered: July 2009 Location: Walldorf, Germany
Senior Member
Victor,
basically the super class DefaultMoveShapeFeature does what you need (see
internalMove()). The trick is simply to change the parent of the moved
shape.