Search in sources :

Example 21 with DBVEntity

use of org.jkiss.dbeaver.model.virtual.DBVEntity in project dbeaver by serge-rider.

the class ResultSetModel method updateColorMapping.

public void updateColorMapping(boolean reset) {
    colorMapping.clear();
    DBSDataContainer dataContainer = getDataContainer();
    if (dataContainer == null) {
        return;
    }
    DBVEntity virtualEntity = DBVUtils.getVirtualEntity(dataContainer, false);
    if (virtualEntity == null) {
        return;
    }
    {
        List<DBVColorOverride> coList = virtualEntity.getColorOverrides();
        if (!CommonUtils.isEmpty(coList)) {
            for (DBVColorOverride co : coList) {
                DBDAttributeBinding binding = DBUtils.findObject(attributes, co.getAttributeName());
                if (binding != null) {
                    List<AttributeColorSettings> cmList = colorMapping.computeIfAbsent(binding, k -> new ArrayList<>());
                    cmList.add(new AttributeColorSettings(co));
                } else {
                    log.debug("Attribute '" + co.getAttributeName() + "' not found in bindings. Skip colors.");
                }
            }
        }
    }
    if (reset) {
        updateRowColors(true, curRows);
    }
}
Also used : CommonUtils(org.jkiss.utils.CommonUtils) DBPDataKind(org.jkiss.dbeaver.model.DBPDataKind) java.util(java.util) org.jkiss.dbeaver.model.struct(org.jkiss.dbeaver.model.struct) DBUtils(org.jkiss.dbeaver.model.DBUtils) org.jkiss.dbeaver.model.exec(org.jkiss.dbeaver.model.exec) org.jkiss.dbeaver.model.data(org.jkiss.dbeaver.model.data) Nullable(org.jkiss.code.Nullable) ArrayUtils(org.jkiss.utils.ArrayUtils) NotNull(org.jkiss.code.NotNull) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer) DBVColorOverride(org.jkiss.dbeaver.model.virtual.DBVColorOverride) DBVUtils(org.jkiss.dbeaver.model.virtual.DBVUtils) DataSourceJob(org.jkiss.dbeaver.runtime.jobs.DataSourceJob) RuntimeUtils(org.jkiss.dbeaver.utils.RuntimeUtils) DBCTrace(org.jkiss.dbeaver.model.exec.trace.DBCTrace) DBVEntity(org.jkiss.dbeaver.model.virtual.DBVEntity) Color(org.eclipse.swt.graphics.Color) DBException(org.jkiss.dbeaver.DBException) UIUtils(org.jkiss.dbeaver.ui.UIUtils) Log(org.jkiss.dbeaver.Log) RGB(org.eclipse.swt.graphics.RGB) ModelPreferences(org.jkiss.dbeaver.ModelPreferences) DBVColorOverride(org.jkiss.dbeaver.model.virtual.DBVColorOverride) DBVEntity(org.jkiss.dbeaver.model.virtual.DBVEntity)

Example 22 with DBVEntity

use of org.jkiss.dbeaver.model.virtual.DBVEntity in project dbeaver by serge-rider.

the class DBDAttributeBinding method findVirtualReferrers.

protected List<DBSEntityReferrer> findVirtualReferrers() {
    DBSDataContainer dataContainer = getDataContainer();
    if (dataContainer instanceof DBSEntity) {
        DBSEntity attrEntity = (DBSEntity) dataContainer;
        DBVEntity vEntity = DBVUtils.getVirtualEntity(attrEntity, false);
        if (vEntity != null) {
            List<DBVEntityForeignKey> foreignKeys = vEntity.getForeignKeys();
            if (!CommonUtils.isEmpty(foreignKeys)) {
                List<DBSEntityReferrer> referrers = null;
                for (DBVEntityForeignKey vfk : foreignKeys) {
                    for (DBVEntityForeignKeyColumn vfkc : vfk.getAttributes()) {
                        if (CommonUtils.equalObjects(vfkc.getAttributeName(), getFullyQualifiedName(DBPEvaluationContext.DML))) {
                            if (referrers == null) {
                                referrers = new ArrayList<>();
                            }
                            referrers.add(vfk);
                        }
                    }
                }
                return referrers;
            }
        }
    }
    return null;
}
Also used : DBVEntityForeignKeyColumn(org.jkiss.dbeaver.model.virtual.DBVEntityForeignKeyColumn) DBVEntityForeignKey(org.jkiss.dbeaver.model.virtual.DBVEntityForeignKey) DBVEntity(org.jkiss.dbeaver.model.virtual.DBVEntity)

Aggregations

DBVEntity (org.jkiss.dbeaver.model.virtual.DBVEntity)22 DBException (org.jkiss.dbeaver.DBException)5 DBVEntityAttribute (org.jkiss.dbeaver.model.virtual.DBVEntityAttribute)5 DBSEntity (org.jkiss.dbeaver.model.struct.DBSEntity)4 DBVEntityForeignKey (org.jkiss.dbeaver.model.virtual.DBVEntityForeignKey)4 DBSTable (org.jkiss.dbeaver.model.struct.rdb.DBSTable)3 DBSTableIndex (org.jkiss.dbeaver.model.struct.rdb.DBSTableIndex)3 DBVColorOverride (org.jkiss.dbeaver.model.virtual.DBVColorOverride)3 RGB (org.eclipse.swt.graphics.RGB)2 DBDAttributeBinding (org.jkiss.dbeaver.model.data.DBDAttributeBinding)2 DBDAttributeBindingCustom (org.jkiss.dbeaver.model.data.DBDAttributeBindingCustom)2 DBSEntityAssociation (org.jkiss.dbeaver.model.struct.DBSEntityAssociation)2 DBVEntityConstraint (org.jkiss.dbeaver.model.virtual.DBVEntityConstraint)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 java.util (java.util)1 IStatus (org.eclipse.core.runtime.IStatus)1 Color (org.eclipse.swt.graphics.Color)1 ColorDialog (org.eclipse.swt.widgets.ColorDialog)1 Shell (org.eclipse.swt.widgets.Shell)1 NotNull (org.jkiss.code.NotNull)1