Search in sources :

Example 1 with NodeMoveCommand

use of org.jkiss.dbeaver.erd.ui.command.NodeMoveCommand 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 (!ALLOW_ENTITY_RESIZE && 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.erd.ui.command.NodeMoveCommand) Rectangle(org.eclipse.draw2d.geometry.Rectangle) NodePart(org.jkiss.dbeaver.erd.ui.part.NodePart) EntityPart(org.jkiss.dbeaver.erd.ui.part.EntityPart) Figure(org.eclipse.draw2d.Figure) IFigure(org.eclipse.draw2d.IFigure)

Example 2 with NodeMoveCommand

use of org.jkiss.dbeaver.erd.ui.command.NodeMoveCommand in project dbeaver by dbeaver.

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 (!ALLOW_ENTITY_RESIZE && 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.erd.ui.command.NodeMoveCommand) Rectangle(org.eclipse.draw2d.geometry.Rectangle) NodePart(org.jkiss.dbeaver.erd.ui.part.NodePart) EntityPart(org.jkiss.dbeaver.erd.ui.part.EntityPart) Figure(org.eclipse.draw2d.Figure) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

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