Search in sources :

Example 6 with ERDEditorPart

use of org.jkiss.dbeaver.ext.erd.editor.ERDEditorPart 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;
}
Also used : Control(org.eclipse.swt.widgets.Control) DBPNamedObject(org.jkiss.dbeaver.model.DBPNamedObject) ERDEditorPart(org.jkiss.dbeaver.ext.erd.editor.ERDEditorPart) ERDEntity(org.jkiss.dbeaver.ext.erd.model.ERDEntity) Point(org.eclipse.draw2d.geometry.Point) EntityAddCommand(org.jkiss.dbeaver.ext.erd.command.EntityAddCommand)

Aggregations

ERDEditorPart (org.jkiss.dbeaver.ext.erd.editor.ERDEditorPart)6 Control (org.eclipse.swt.widgets.Control)3 DeleteAction (org.eclipse.gef.ui.actions.DeleteAction)2 EntityDiagram (org.jkiss.dbeaver.ext.erd.model.EntityDiagram)2 Point (org.eclipse.draw2d.geometry.Point)1 SelectAllAction (org.eclipse.gef.ui.actions.SelectAllAction)1 EntityAddCommand (org.jkiss.dbeaver.ext.erd.command.EntityAddCommand)1 ERDEntity (org.jkiss.dbeaver.ext.erd.model.ERDEntity)1 DBPNamedObject (org.jkiss.dbeaver.model.DBPNamedObject)1