Search in sources :

Example 1 with DBPPropertyDescriptor

use of org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor 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 DBPPropertyDescriptor

use of org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor 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 DBPPropertyDescriptor

use of org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor in project dbeaver by serge-rider.

the class DriverDescriptor method setDriverParameter.

public void setDriverParameter(String name, String value, boolean setDefault) {
    DBPPropertyDescriptor prop = getProviderDescriptor().getDriverProperty(name);
    Object valueObject = prop == null ? value : GeneralUtils.convertString(value, prop.getDataType());
    customParameters.put(name, valueObject);
    if (setDefault) {
        defaultParameters.put(name, valueObject);
    }
}
Also used : DBPPropertyDescriptor(org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor)

Example 4 with DBPPropertyDescriptor

use of org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor in project dbeaver by serge-rider.

the class DataFormatterProfile method initDefaultPreferences.

public static void initDefaultPreferences(DBPPreferenceStore store, Locale locale) {
    for (DataFormatterDescriptor formatter : DataFormatterRegistry.getInstance().getDataFormatters()) {
        Map<Object, Object> defaultProperties = formatter.getSample().getDefaultProperties(locale);
        Map<Object, Object> formatterProps = new HashMap<>();
        for (DBPPropertyDescriptor prop : formatter.getProperties()) {
            Object defaultValue = defaultProperties.get(prop.getId());
            if (defaultValue != null) {
                PrefUtils.setPreferenceDefaultValue(store, DATAFORMAT_TYPE_PREFIX + formatter.getId() + "." + prop.getId(), defaultValue);
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) DBPPropertyDescriptor(org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor)

Example 5 with DBPPropertyDescriptor

use of org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor 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)

Aggregations

DBPPropertyDescriptor (org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor)14 PropertyDescriptor (org.jkiss.dbeaver.model.impl.PropertyDescriptor)4 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)4 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 DBPNamedObject (org.jkiss.dbeaver.model.DBPNamedObject)2 DBPSystemObject (org.jkiss.dbeaver.model.DBPSystemObject)2 DBNDatabaseNode (org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)2 DriverPropertyInfo (java.sql.DriverPropertyInfo)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Properties (java.util.Properties)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1