Search in sources :

Example 1 with PropertyDescriptor

use of org.jkiss.dbeaver.model.impl.PropertyDescriptor in project dbeaver by serge-rider.

the class ConnectionPropertiesControl method loadCustomProperties.

private void loadCustomProperties(DBPDriver driver, Map<Object, Object> properties) {
    // Collect all driver (and all other) properties
    Set<String> propNames = new TreeSet<>();
    List<DBPPropertyDescriptor> allProperties = getAllProperties(driver, false);
    for (DBPPropertyDescriptor prop : allProperties) {
        propNames.add(CommonUtils.toString(prop.getId()));
    }
    customProperties = new ArrayList<>();
    // Find prop values which are not from driver
    for (Object propId : properties.keySet()) {
        final String propName = propId.toString();
        if (!propNames.contains(propName)) {
            customProperties.add(new PropertyDescriptor(USER_PROPERTIES_CATEGORY, propName, propName, null, String.class, false, null, null, true));
        }
    }
    Collections.sort(customProperties, PROPERTIES_COMPARATOR);
}
Also used : DBPPropertyDescriptor(org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor) PropertyDescriptor(org.jkiss.dbeaver.model.impl.PropertyDescriptor) DBPPropertyDescriptor(org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor)

Example 2 with PropertyDescriptor

use of org.jkiss.dbeaver.model.impl.PropertyDescriptor in project dbeaver by serge-rider.

the class JDBCDataSourceProvider method readDriverProperties.

private Collection<DBPPropertyDescriptor> readDriverProperties(DBPConnectionConfiguration connectionInfo, Driver driver) throws DBException {
    Properties driverProps = new Properties();
    //driverProps.putAll(connectionInfo.getProperties());
    DriverPropertyInfo[] propDescs;
    try {
        propDescs = driver.getPropertyInfo(connectionInfo.getUrl(), driverProps);
    } catch (Throwable e) {
        //$NON-NLS-1$
        log.debug("Cannot obtain driver's properties", e);
        return null;
    }
    if (propDescs == null) {
        return null;
    }
    List<DBPPropertyDescriptor> properties = new ArrayList<>();
    for (DriverPropertyInfo desc : propDescs) {
        if (desc == null || DBConstants.DATA_SOURCE_PROPERTY_USER.equals(desc.name) || DBConstants.DATA_SOURCE_PROPERTY_PASSWORD.equals(desc.name)) {
            // Skip user/password properties
            continue;
        }
        desc.value = getConnectionPropertyDefaultValue(desc.name, desc.value);
        properties.add(new PropertyDescriptor(ModelMessages.model_jdbc_driver_properties, desc.name, desc.name, desc.description, String.class, desc.required, desc.value, desc.choices, true));
    }
    return properties;
}
Also used : DBPPropertyDescriptor(org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor) PropertyDescriptor(org.jkiss.dbeaver.model.impl.PropertyDescriptor) ArrayList(java.util.ArrayList) Properties(java.util.Properties) DriverPropertyInfo(java.sql.DriverPropertyInfo) DBPPropertyDescriptor(org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor)

Example 3 with PropertyDescriptor

use of org.jkiss.dbeaver.model.impl.PropertyDescriptor in project dbeaver by serge-rider.

the class PostgrePlanNode method getPropertyDescriptors2.

@Override
public DBPPropertyDescriptor[] getPropertyDescriptors2() {
    DBPPropertyDescriptor[] props = new DBPPropertyDescriptor[attributes.size()];
    int index = 0;
    for (Map.Entry<String, String> attr : attributes.entrySet()) {
        props[index++] = new PropertyDescriptor("Source", attr.getKey(), attr.getKey(), null, String.class, false, null, null, false);
    }
    return props;
}
Also used : DBPPropertyDescriptor(org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor) PropertyDescriptor(org.jkiss.dbeaver.model.impl.PropertyDescriptor) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) DBPPropertyDescriptor(org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor)

Example 4 with PropertyDescriptor

use of org.jkiss.dbeaver.model.impl.PropertyDescriptor in project dbeaver by serge-rider.

the class WMIPropertySource method getPropertyDescriptors2.

@Override
public DBPPropertyDescriptor[] getPropertyDescriptors2() {
    try {
        WMIQualifiedObject qualifiedObject = getQualifiedObject();
        if (qualifiedObject == null) {
            return EMPTY_PROPERTIES;
        }
        Collection<WMIQualifier> qualifiers = qualifiedObject.getQualifiers();
        DBPPropertyDescriptor[] result = new DBPPropertyDescriptor[qualifiers.size()];
        int index = 0;
        for (WMIQualifier qualifier : qualifiers) {
            String name = qualifier.getName();
            PropertyDescriptor prop = new PropertyDescriptor("WMI", name, name, null, null, false, null, null, false);
            result[index++] = prop;
        }
        return result;
    } catch (WMIException e) {
        log.error(e);
        return EMPTY_PROPERTIES;
    }
}
Also used : WMIException(org.jkiss.wmi.service.WMIException) DBPPropertyDescriptor(org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor) PropertyDescriptor(org.jkiss.dbeaver.model.impl.PropertyDescriptor) WMIQualifiedObject(org.jkiss.wmi.service.WMIQualifiedObject) WMIQualifier(org.jkiss.wmi.service.WMIQualifier) DBPPropertyDescriptor(org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor)

Example 5 with PropertyDescriptor

use of org.jkiss.dbeaver.model.impl.PropertyDescriptor in project dbeaver by serge-rider.

the class PropertySourceAbstract method addProperty.

public synchronized void addProperty(@Nullable String category, Object id, String name, Object value) {
    props.add(new PropertyDescriptor(category, id, name, null, value == null ? null : value.getClass(), false, null, null, false));
    propValues.put(id, value);
}
Also used : DBPPropertyDescriptor(org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor) PropertyDescriptor(org.jkiss.dbeaver.model.impl.PropertyDescriptor)

Aggregations

PropertyDescriptor (org.jkiss.dbeaver.model.impl.PropertyDescriptor)5 DBPPropertyDescriptor (org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor)5 DriverPropertyInfo (java.sql.DriverPropertyInfo)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Properties (java.util.Properties)1 WMIException (org.jkiss.wmi.service.WMIException)1 WMIQualifiedObject (org.jkiss.wmi.service.WMIQualifiedObject)1 WMIQualifier (org.jkiss.wmi.service.WMIQualifier)1