Search in sources :

Example 6 with NodePart

use of org.jkiss.dbeaver.erd.ui.part.NodePart in project dbeaver by dbeaver.

the class EntityConnectionEditPolicy method getConnectionCreateCommand.

@Override
protected Command getConnectionCreateCommand(CreateConnectionRequest request) {
    AssociationCreateCommand cmd = makeCreateCommand();
    NodePart part = (NodePart) getHost();
    cmd.setSourceEntity(part.getElement());
    request.setStartCommand(cmd);
    return cmd;
}
Also used : AssociationCreateCommand(org.jkiss.dbeaver.erd.ui.command.AssociationCreateCommand) NodePart(org.jkiss.dbeaver.erd.ui.part.NodePart)

Example 7 with NodePart

use of org.jkiss.dbeaver.erd.ui.part.NodePart in project dbeaver by dbeaver.

the class EntityConnectionEditPolicy method getConnectionCompleteCommand.

@Override
protected Command getConnectionCompleteCommand(CreateConnectionRequest request) {
    AssociationCreateCommand cmd = (AssociationCreateCommand) request.getStartCommand();
    NodePart part = (NodePart) request.getTargetEditPart();
    cmd.setTargetEntity(part.getElement());
    return cmd;
}
Also used : AssociationCreateCommand(org.jkiss.dbeaver.erd.ui.command.AssociationCreateCommand) NodePart(org.jkiss.dbeaver.erd.ui.part.NodePart)

Example 8 with NodePart

use of org.jkiss.dbeaver.erd.ui.part.NodePart 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)

Example 9 with NodePart

use of org.jkiss.dbeaver.erd.ui.part.NodePart in project dbeaver by dbeaver.

the class ChangeZOrderAction method createReorderCommand.

private Command createReorderCommand(final Object[] objects) {
    return new Command() {

        @Override
        public void execute() {
            for (Object item : objects) {
                if (item instanceof NodePart) {
                    IFigure child = ((NodePart) item).getFigure();
                    final IFigure parent = child.getParent();
                    final List children = parent.getChildren();
                    if (children != null) {
                        children.remove(child);
                        if (front) {
                            children.add(child);
                        } else {
                            children.add(0, child);
                        }
                        child.repaint();
                    }
                // ((NodePart) item).getDiagram().
                }
            }
        }

        @Override
        public boolean canUndo() {
            return false;
        }
    };
}
Also used : Command(org.eclipse.gef.commands.Command) List(java.util.List) NodePart(org.jkiss.dbeaver.erd.ui.part.NodePart) IFigure(org.eclipse.draw2d.IFigure)

Example 10 with NodePart

use of org.jkiss.dbeaver.erd.ui.part.NodePart in project dbeaver by dbeaver.

the class EntityConnectionEditPolicy method getReconnectTargetCommand.

@Override
protected Command getReconnectTargetCommand(ReconnectRequest request) {
    AssociationReconnectTargetCommand cmd = makeReconnectTargetCommand();
    cmd.setRelationship((ERDAssociation) request.getConnectionEditPart().getModel());
    NodePart entityPart = (NodePart) getHost();
    cmd.setTargetEntity(entityPart.getElement());
    return cmd;
}
Also used : AssociationReconnectTargetCommand(org.jkiss.dbeaver.erd.ui.command.AssociationReconnectTargetCommand) NodePart(org.jkiss.dbeaver.erd.ui.part.NodePart)

Aggregations

NodePart (org.jkiss.dbeaver.erd.ui.part.NodePart)16 EntityPart (org.jkiss.dbeaver.erd.ui.part.EntityPart)6 IFigure (org.eclipse.draw2d.IFigure)4 Command (org.eclipse.gef.commands.Command)4 AssociationCreateCommand (org.jkiss.dbeaver.erd.ui.command.AssociationCreateCommand)4 NotePart (org.jkiss.dbeaver.erd.ui.part.NotePart)4 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Figure (org.eclipse.draw2d.Figure)2 Rectangle (org.eclipse.draw2d.geometry.Rectangle)2 AssociationReconnectSourceCommand (org.jkiss.dbeaver.erd.ui.command.AssociationReconnectSourceCommand)2 AssociationReconnectTargetCommand (org.jkiss.dbeaver.erd.ui.command.AssociationReconnectTargetCommand)2 NodeMoveCommand (org.jkiss.dbeaver.erd.ui.command.NodeMoveCommand)2 EntityDiagram (org.jkiss.dbeaver.erd.ui.model.EntityDiagram)2 ICustomizablePart (org.jkiss.dbeaver.erd.ui.part.ICustomizablePart)2