Search in sources :

Example 1 with ERDNote

use of org.jkiss.dbeaver.erd.model.ERDNote in project dbeaver by dbeaver.

the class DiagramContainerEditPolicy method getCreateCommand.

/**
 * @see ContainerEditPolicy#getCreateCommand(org.eclipse.gef.requests.CreateRequest)
 */
@Override
protected Command getCreateCommand(CreateRequest request) {
    DiagramPart diagramPart = (DiagramPart) getHost();
    Point location = request.getLocation();
    diagramPart.getFigure().translateToRelative(location);
    Object newObject = request.getNewObject();
    if (newObject instanceof ERDNote) {
        return new NoteCreateCommand(diagramPart, (ERDNote) newObject, location, request.getSize());
    }
    List<ERDEntity> entities = null;
    if (newObject instanceof ERDEntity) {
        entities = Collections.singletonList((ERDEntity) newObject);
    } else if (newObject instanceof Collection) {
        entities = new ArrayList<>((Collection<ERDEntity>) newObject);
    }
    if (CommonUtils.isEmpty(entities)) {
        return null;
    }
    // EditPart host = getTargetEditPart(request);
    Command entityAddCommand = diagramPart.createEntityAddCommand(entities, location);
    if (!entityAddCommand.canExecute()) {
        return null;
    }
    return entityAddCommand;
}
Also used : NoteCreateCommand(org.jkiss.dbeaver.erd.ui.command.NoteCreateCommand) NoteCreateCommand(org.jkiss.dbeaver.erd.ui.command.NoteCreateCommand) Command(org.eclipse.gef.commands.Command) ERDEntity(org.jkiss.dbeaver.erd.model.ERDEntity) ERDNote(org.jkiss.dbeaver.erd.model.ERDNote) ArrayList(java.util.ArrayList) Collection(java.util.Collection) Point(org.eclipse.draw2d.geometry.Point) DiagramPart(org.jkiss.dbeaver.erd.ui.part.DiagramPart)

Example 2 with ERDNote

use of org.jkiss.dbeaver.erd.model.ERDNote in project dbeaver by serge-rider.

the class DiagramContainerEditPolicy method getCreateCommand.

/**
 * @see ContainerEditPolicy#getCreateCommand(org.eclipse.gef.requests.CreateRequest)
 */
@Override
protected Command getCreateCommand(CreateRequest request) {
    DiagramPart diagramPart = (DiagramPart) getHost();
    Point location = request.getLocation();
    diagramPart.getFigure().translateToRelative(location);
    Object newObject = request.getNewObject();
    if (newObject instanceof ERDNote) {
        return new NoteCreateCommand(diagramPart, (ERDNote) newObject, location, request.getSize());
    }
    List<ERDEntity> entities = null;
    if (newObject instanceof ERDEntity) {
        entities = Collections.singletonList((ERDEntity) newObject);
    } else if (newObject instanceof Collection) {
        entities = new ArrayList<>((Collection<ERDEntity>) newObject);
    }
    if (CommonUtils.isEmpty(entities)) {
        return null;
    }
    // EditPart host = getTargetEditPart(request);
    Command entityAddCommand = diagramPart.createEntityAddCommand(entities, location);
    if (!entityAddCommand.canExecute()) {
        return null;
    }
    return entityAddCommand;
}
Also used : NoteCreateCommand(org.jkiss.dbeaver.erd.ui.command.NoteCreateCommand) NoteCreateCommand(org.jkiss.dbeaver.erd.ui.command.NoteCreateCommand) Command(org.eclipse.gef.commands.Command) ERDEntity(org.jkiss.dbeaver.erd.model.ERDEntity) ERDNote(org.jkiss.dbeaver.erd.model.ERDNote) ArrayList(java.util.ArrayList) Collection(java.util.Collection) Point(org.eclipse.draw2d.geometry.Point) DiagramPart(org.jkiss.dbeaver.erd.ui.part.DiagramPart)

Aggregations

ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 Point (org.eclipse.draw2d.geometry.Point)2 Command (org.eclipse.gef.commands.Command)2 ERDEntity (org.jkiss.dbeaver.erd.model.ERDEntity)2 ERDNote (org.jkiss.dbeaver.erd.model.ERDNote)2 NoteCreateCommand (org.jkiss.dbeaver.erd.ui.command.NoteCreateCommand)2 DiagramPart (org.jkiss.dbeaver.erd.ui.part.DiagramPart)2