use of org.jkiss.dbeaver.ext.erd.command.EntityAddCommand 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);
}
Collection<ERDEntity> entities = null;
if (newObject instanceof ERDEntity) {
entities = Collections.singletonList((ERDEntity) newObject);
} else if (newObject instanceof Collection) {
entities = (Collection<ERDEntity>) newObject;
}
if (CommonUtils.isEmpty(entities)) {
return null;
}
return new EntityAddCommand(diagramPart, entities, location);
}
use of org.jkiss.dbeaver.ext.erd.command.EntityAddCommand in project dbeaver by serge-rider.
the class ERDHandlerPaste method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Control control = (Control) HandlerUtil.getVariable(event, ISources.ACTIVE_FOCUS_CONTROL_NAME);
if (control != null) {
ERDEditorPart editor = ERDEditorAdapter.getEditor(control);
if (editor != null && !editor.isReadOnly()) {
final Collection<DBPNamedObject> objects = DatabaseObjectTransfer.getInstance().getObject();
if (!CommonUtils.isEmpty(objects)) {
final List<ERDEntity> erdEntities = DiagramObjectCollector.generateEntityList(editor.getDiagram(), objects);
if (!CommonUtils.isEmpty(erdEntities)) {
EntityAddCommand command = new EntityAddCommand(editor.getDiagramPart(), erdEntities, new Point(10, 10));
editor.getCommandStack().execute(command);
}
}
}
}
return null;
}
Aggregations