Search in sources :

Example 1 with DBSEntityAssociation

use of org.jkiss.dbeaver.model.struct.DBSEntityAssociation in project dbeaver by serge-rider.

the class AssociationPart method setSelected.

/**
     * Sets the width of the line when selected
     */
@Override
public void setSelected(int value) {
    super.setSelected(value);
    if (value != EditPart.SELECTED_NONE) {
        ((PolylineConnection) getFigure()).setLineWidth(2);
    } else {
        ((PolylineConnection) getFigure()).setLineWidth(1);
    }
    if (getSource() == null || getTarget() == null) {
        // This part seems to be deleted
        return;
    }
    DBSEntityAssociation association = getAssociation().getObject();
    if (association instanceof DBSEntityReferrer && association.getReferencedConstraint() instanceof DBSEntityReferrer) {
        List<AttributePart> sourceAttributes = getEntityAttributes((EntityPart) getSource(), DBUtils.getEntityAttributes(VoidProgressMonitor.INSTANCE, (DBSEntityReferrer) association.getReferencedConstraint()));
        List<AttributePart> targetAttributes = getEntityAttributes((EntityPart) getTarget(), DBUtils.getEntityAttributes(VoidProgressMonitor.INSTANCE, (DBSEntityReferrer) association));
        Color columnColor = value != EditPart.SELECTED_NONE ? Display.getDefault().getSystemColor(SWT.COLOR_RED) : getViewer().getControl().getForeground();
        for (AttributePart attr : sourceAttributes) {
            attr.getFigure().setForegroundColor(columnColor);
        }
        for (AttributePart attr : targetAttributes) {
            attr.getFigure().setForegroundColor(columnColor);
        }
    }
}
Also used : DBSEntityAssociation(org.jkiss.dbeaver.model.struct.DBSEntityAssociation) DBSEntityReferrer(org.jkiss.dbeaver.model.struct.DBSEntityReferrer) Color(org.eclipse.swt.graphics.Color)

Aggregations

Color (org.eclipse.swt.graphics.Color)1 DBSEntityAssociation (org.jkiss.dbeaver.model.struct.DBSEntityAssociation)1 DBSEntityReferrer (org.jkiss.dbeaver.model.struct.DBSEntityReferrer)1