Search in sources :

Example 1 with PropertySourceMap

use of org.jkiss.dbeaver.runtime.properties.PropertySourceMap in project dbeaver by dbeaver.

the class PropertyPageStandard method getPropertySource.

@Override
public IPropertySource getPropertySource(Object object) {
    if (object == null || object.getClass().isPrimitive() || object instanceof CharSequence || object instanceof Number || object instanceof Boolean) {
        // Just for better performance
        return null;
    }
    // (get prop source from adapter, load props, load lazy props -> refresh -> get prop source from adapter, etc).
    if (!ArrayUtils.isEmpty(curSelection)) {
        for (PropertySourceCache cache : curSelection) {
            if (cache.object == object) {
                if (!cache.cached) {
                    cache.propertySource = RuntimeUtils.getObjectAdapter(object, IPropertySource.class);
                    cache.cached = true;
                }
                return cache.propertySource;
            }
        }
    }
    if (object instanceof Collection) {
        return new PropertySourceDelegate(new PropertySourceCollection((Collection<?>) object));
    } else if (object instanceof Map) {
        return new PropertySourceDelegate(new PropertySourceMap((Map<String, ?>) object));
    }
    return RuntimeUtils.getObjectAdapter(object, IPropertySource.class);
}
Also used : PropertySourceDelegate(org.jkiss.dbeaver.ui.properties.PropertySourceDelegate) Collection(java.util.Collection) PropertySourceCollection(org.jkiss.dbeaver.runtime.properties.PropertySourceCollection) PropertySourceMap(org.jkiss.dbeaver.runtime.properties.PropertySourceMap) PropertySourceMap(org.jkiss.dbeaver.runtime.properties.PropertySourceMap) Map(java.util.Map) PropertySourceCollection(org.jkiss.dbeaver.runtime.properties.PropertySourceCollection)

Example 2 with PropertySourceMap

use of org.jkiss.dbeaver.runtime.properties.PropertySourceMap in project dbeaver by serge-rider.

the class PropertyPageStandard method getPropertySource.

@Override
public IPropertySource getPropertySource(Object object) {
    if (object == null || object.getClass().isPrimitive() || object instanceof CharSequence || object instanceof Number || object instanceof Boolean) {
        // Just for better performance
        return null;
    }
    // (get prop source from adapter, load props, load lazy props -> refresh -> get prop source from adapter, etc).
    if (!ArrayUtils.isEmpty(curSelection)) {
        for (PropertySourceCache cache : curSelection) {
            if (cache.object == object) {
                if (!cache.cached) {
                    cache.propertySource = RuntimeUtils.getObjectAdapter(object, IPropertySource.class);
                    cache.cached = true;
                }
                return cache.propertySource;
            }
        }
    }
    if (object instanceof Collection) {
        return new PropertySourceDelegate(new PropertySourceCollection((Collection<?>) object));
    } else if (object instanceof Map) {
        return new PropertySourceDelegate(new PropertySourceMap((Map<String, ?>) object));
    }
    return RuntimeUtils.getObjectAdapter(object, IPropertySource.class);
}
Also used : PropertySourceDelegate(org.jkiss.dbeaver.ui.properties.PropertySourceDelegate) Collection(java.util.Collection) PropertySourceCollection(org.jkiss.dbeaver.runtime.properties.PropertySourceCollection) PropertySourceMap(org.jkiss.dbeaver.runtime.properties.PropertySourceMap) PropertySourceMap(org.jkiss.dbeaver.runtime.properties.PropertySourceMap) Map(java.util.Map) PropertySourceCollection(org.jkiss.dbeaver.runtime.properties.PropertySourceCollection)

Aggregations

Collection (java.util.Collection)2 Map (java.util.Map)2 PropertySourceCollection (org.jkiss.dbeaver.runtime.properties.PropertySourceCollection)2 PropertySourceMap (org.jkiss.dbeaver.runtime.properties.PropertySourceMap)2 PropertySourceDelegate (org.jkiss.dbeaver.ui.properties.PropertySourceDelegate)2