Search in sources :

Example 1 with NodePart

use of org.jkiss.dbeaver.ext.erd.part.NodePart in project dbeaver by serge-rider.

the class DiagramXYLayoutPolicy method createChangeConstraintCommand.

/**
	 * Creates command to move table. Does not allow table to be resized
	 */
@Override
protected Command createChangeConstraintCommand(EditPart child, Object constraint) {
    if (!(child instanceof NodePart))
        return null;
    if (!(constraint instanceof Rectangle))
        return null;
    NodePart nodePart = (NodePart) child;
    Figure figure = (Figure) nodePart.getFigure();
    Rectangle oldBounds = figure.getBounds();
    Rectangle newBounds = (Rectangle) constraint;
    // Restrict resize for entities
    if (nodePart instanceof EntityPart) {
        if (oldBounds.width != newBounds.width && newBounds.width != -1)
            return null;
        if (oldBounds.height != newBounds.height && newBounds.height != -1)
            return null;
    }
    return new NodeMoveCommand(nodePart, oldBounds.getCopy(), newBounds.getCopy());
}
Also used : NodeMoveCommand(org.jkiss.dbeaver.ext.erd.command.NodeMoveCommand) Rectangle(org.eclipse.draw2d.geometry.Rectangle) NodePart(org.jkiss.dbeaver.ext.erd.part.NodePart) EntityPart(org.jkiss.dbeaver.ext.erd.part.EntityPart) Figure(org.eclipse.draw2d.Figure) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

Figure (org.eclipse.draw2d.Figure)1 IFigure (org.eclipse.draw2d.IFigure)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 NodeMoveCommand (org.jkiss.dbeaver.ext.erd.command.NodeMoveCommand)1 EntityPart (org.jkiss.dbeaver.ext.erd.part.EntityPart)1 NodePart (org.jkiss.dbeaver.ext.erd.part.NodePart)1