i have somme process elements that can contain other process elements with no limit.
i managed the addition of new process into other directly from the palette, it works right but when i drag a process already drawn to integrate it as a new child of another process already drawn, the editor don't let me do so and i have a white cross cursor.
in my model the Process class is extending ContainerElement class wich handles the addition and removal of children and the notification stuff.
i was thinking that since the process will have a new parent i must add this in the change ConstraintCommand
here's a snippet of my code
public class ProcessFigure extends Figure {
public ProcessFigure() {
setLayoutManager(new XYLayout());
ellipse = new Ellipse();
ellipse.setFill(false);
add(ellipse);
label = new Label();
add(label);
ellipse.setLayoutManager(new XYLayout());
}
public IFigure getContentPane() {
return ellipse;
}
...
}
------------------------------
public class ProcessEditPart extends ContainerElementEditPart {
...
public IFigure getContentPane() {
return ((ProcessFigure)getFigure()).getContentPane();
}
@Override
protected void createEditPolicies() {
installEditPolicy(EditPolicy.LAYOUT_ROLE, new ContainerElementXYLayoutEditPolicy(
(XYLayout) getContentPane().getLayoutManager()));
}
...
}
------------------------
public class ContainerElementXYLayoutEditPolicy extends XYLayoutEditPolicy {
...
public ContainerElementXYLayoutEditPolicy(XYLayout layoutManager) {
super();
setXyLayout(layoutManager);
}
private Command getProcessCreateCommand(CreateRequest request) {
ProcessCreateCommand result = new ProcessCreateCommand();
Rectangle constraint = (Rectangle) getConstraintFor(request);
result.setLocation(constraint.getLocation());
result.setProcess((Process)request.getNewObject());
result.setParent((ContainerElement)getHost().getModel());
return result;
}
protected Command createChangeConstraintCommand (ChangeBoundsRequest request,EditPart child , Object constraint) {
ProcessChangeConstraintCommand changeConstraintCommand = new ProcessChangeConstraintCommand ();
changeConstraintCommand.setProcess((Process)child.getModel());
changeConstraintCommand.setNewConstraint((Rectangle)constraint);
return changeConstraintCommand;
}
...
}
i think the problem is that gef can't figure the appropriate layout manager, i tried several changes but get everytime cast or stackoverflow exception, please help !