Search in sources :

Example 1 with CachingStrategy

use of cern.gp.nodes.cache.CachingStrategy in project ACS by ACS-Community.

the class BeanNode method computeProperties.

/** 
   * Computes a descriptor for properties from a bean info.
   * @param bean bean to create properties for
   * @param info about the bean
   * @param ignoreHiddenProperties true if hidden property should be ignored completely
   * @param propertyInfo extra information of some properties (possibly null)
   * @return three property lists
   */
private static Descriptor computeProperties(Object bean, BeanInfo info, boolean ignoreHiddenProperties, Boolean nodePropertiesCacheable, PropertyInfo[] propertyInfo) {
    java.util.List property = null;
    java.util.List expert = null;
    java.util.List hidden = null;
    PropertyDescriptor[] propertyDescriptor = info.getPropertyDescriptors();
    int k = propertyDescriptor.length;
    for (int i = 0; i < k; i++) {
        if (propertyDescriptor[i].getPropertyType() == null)
            continue;
        String propName = propertyDescriptor[i].getName();
        // we first update the PropertyDescriptor with the PropertyInfo
        // that update may make non hidden a property that was hidden
        PropertyInfo propInfo = findPropertyInfoByName(propertyInfo, propName);
        if (propInfo != null)
            propInfo.updatePropertyDescriptor(propertyDescriptor[i]);
        // after the update we can test whether the property is hidden or not
        if (ignoreHiddenProperties && propertyDescriptor[i].isHidden()) {
            continue;
        }
        CachingStrategy strategy = createCachingStrategy(nodePropertiesCacheable, BeanTagger.isCacheable(propertyDescriptor[i]));
        Node.Property prop;
        if (propertyDescriptor[i] instanceof IndexedPropertyDescriptor) {
            prop = createIndexedNodeProperty(bean, (IndexedPropertyDescriptor) propertyDescriptor[i], strategy);
        } else {
            prop = createNodeProperty(bean, propertyDescriptor[i], strategy);
        }
        if (prop == null)
            continue;
        if (propertyDescriptor[i].isHidden()) {
            if (hidden == null)
                hidden = new java.util.ArrayList();
            hidden.add(prop);
        } else if (propertyDescriptor[i].isExpert()) {
            if (expert == null)
                expert = new java.util.ArrayList();
            expert.add(prop);
        } else {
            if (property == null)
                property = new java.util.ArrayList();
            property.add(prop);
        }
    }
    // for    
    return new Descriptor(property, expert, hidden);
}
Also used : IndexedPropertyDescriptor(java.beans.IndexedPropertyDescriptor) PropertyDescriptor(java.beans.PropertyDescriptor) Node(org.openide.nodes.Node) CachingStrategy(cern.gp.nodes.cache.CachingStrategy) TimeLimitedCachingStrategy(cern.gp.nodes.cache.TimeLimitedCachingStrategy) StickyCachingStrategy(cern.gp.nodes.cache.StickyCachingStrategy) NoCachingStrategy(cern.gp.nodes.cache.NoCachingStrategy) IndexedPropertyDescriptor(java.beans.IndexedPropertyDescriptor) PropertyDescriptor(java.beans.PropertyDescriptor) IndexedPropertyDescriptor(java.beans.IndexedPropertyDescriptor) PropertyInfo(cern.gp.beans.PropertyInfo)

Aggregations

PropertyInfo (cern.gp.beans.PropertyInfo)1 CachingStrategy (cern.gp.nodes.cache.CachingStrategy)1 NoCachingStrategy (cern.gp.nodes.cache.NoCachingStrategy)1 StickyCachingStrategy (cern.gp.nodes.cache.StickyCachingStrategy)1 TimeLimitedCachingStrategy (cern.gp.nodes.cache.TimeLimitedCachingStrategy)1 IndexedPropertyDescriptor (java.beans.IndexedPropertyDescriptor)1 PropertyDescriptor (java.beans.PropertyDescriptor)1 Node (org.openide.nodes.Node)1