Search in sources :

Example 1 with AttributePart

use of org.jkiss.dbeaver.erd.ui.part.AttributePart in project dbeaver by serge-rider.

the class AttributeConnectionEditPolicy method getAddCommand.

@Override
protected Command getAddCommand(GroupRequest request) {
    List srcParts = request.getEditParts();
    if (srcParts.size() != 1) {
        // Can drop only one attribute
        return null;
    }
    if (!(srcParts.get(0) instanceof AttributePart)) {
        // Not attribute
        return null;
    }
    AttributePart srcPart = (AttributePart) srcParts.get(0);
    if (srcPart.getParent() == part.getParent()) {
        // Can't drop attribute to the same parent
        return null;
    }
    AssociationCreateCommand command = new AssociationCreateCommand();
    command.setSourceEntity(srcPart.getEntity());
    command.setTargetEntity(part.getEntity());
    command.setAttributes(srcPart.getAttribute(), part.getAttribute());
    return command;
}
Also used : AttributePart(org.jkiss.dbeaver.erd.ui.part.AttributePart) AssociationCreateCommand(org.jkiss.dbeaver.erd.ui.command.AssociationCreateCommand) List(java.util.List)

Example 2 with AttributePart

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

the class AttributeConnectionEditPolicy method getAddCommand.

@Override
protected Command getAddCommand(GroupRequest request) {
    List srcParts = request.getEditParts();
    if (srcParts.size() != 1) {
        // Can drop only one attribute
        return null;
    }
    if (!(srcParts.get(0) instanceof AttributePart)) {
        // Not attribute
        return null;
    }
    AttributePart srcPart = (AttributePart) srcParts.get(0);
    if (srcPart.getParent() == part.getParent()) {
        // Can't drop attribute to the same parent
        return null;
    }
    AssociationCreateCommand command = new AssociationCreateCommand();
    command.setSourceEntity(srcPart.getEntity());
    command.setTargetEntity(part.getEntity());
    command.setAttributes(srcPart.getAttribute(), part.getAttribute());
    return command;
}
Also used : AttributePart(org.jkiss.dbeaver.erd.ui.part.AttributePart) AssociationCreateCommand(org.jkiss.dbeaver.erd.ui.command.AssociationCreateCommand) List(java.util.List)

Example 3 with AttributePart

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

the class AttributeDirectEditPolicy method showCurrentEditValue.

@Override
protected void showCurrentEditValue(DirectEditRequest request) {
    String value = (String) request.getCellEditor().getValue();
    AttributePart attributePart = (AttributePart) getHost();
    attributePart.handleNameChange(value);
}
Also used : AttributePart(org.jkiss.dbeaver.erd.ui.part.AttributePart)

Example 4 with AttributePart

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

the class AttributeDirectEditPolicy method revertOldEditValue.

@Override
protected void revertOldEditValue(DirectEditRequest request) {
    CellEditor cellEditor = request.getCellEditor();
    cellEditor.setValue(oldValue);
    AttributePart attributePart = (AttributePart) getHost();
    attributePart.revertNameChange(oldValue);
}
Also used : AttributePart(org.jkiss.dbeaver.erd.ui.part.AttributePart) CellEditor(org.eclipse.jface.viewers.CellEditor)

Example 5 with AttributePart

use of org.jkiss.dbeaver.erd.ui.part.AttributePart in project dbeaver by serge-rider.

the class AttributeDirectEditPolicy method revertOldEditValue.

@Override
protected void revertOldEditValue(DirectEditRequest request) {
    CellEditor cellEditor = request.getCellEditor();
    cellEditor.setValue(oldValue);
    AttributePart attributePart = (AttributePart) getHost();
    attributePart.revertNameChange(oldValue);
}
Also used : AttributePart(org.jkiss.dbeaver.erd.ui.part.AttributePart) CellEditor(org.eclipse.jface.viewers.CellEditor)

Aggregations

AttributePart (org.jkiss.dbeaver.erd.ui.part.AttributePart)6 List (java.util.List)2 CellEditor (org.eclipse.jface.viewers.CellEditor)2 AssociationCreateCommand (org.jkiss.dbeaver.erd.ui.command.AssociationCreateCommand)2