Package org.apache.pivot.beans

Examples of org.apache.pivot.beans.BeanAdapter


        if (parent == null) {
            throw new IllegalArgumentException("Invalid path.");
        }

        Map<String, T> adapter = (Map<String, T>) (parent instanceof java.util.Map ? new MapAdapter<String, T>((java.util.Map<String, T>) parent) :
                (parent instanceof org.apache.pivot.collections.Map ? ((org.apache.pivot.collections.Map<String, T>) parent): new BeanAdapter(parent)));

        Object previousValue;
        if (adapter.containsKey(key)) {
            previousValue = adapter.put(key, value);
        } else if (parent instanceof Sequence<?>) {
View Full Code Here


        boolean containsKey;
        if (parent == null) {
            containsKey = false;
        } else {
            Map<String, T> adapter = (Map<String, T>) (parent instanceof java.util.Map ? new MapAdapter<String, T>((java.util.Map<String, T>) parent) :
                    (parent instanceof org.apache.pivot.collections.Map ? ((org.apache.pivot.collections.Map<String, T>) parent): new BeanAdapter(parent)));
            containsKey = adapter.containsKey(key);

            if (!containsKey) {
                if (parent instanceof Sequence<?>) {
                    Sequence<Object> sequence = (Sequence<Object>)parent;
View Full Code Here

            Class<?> sourceType = source.getClass();
            HashMap<Class<?>, List<String>> declaringClassPartitions =
                new HashMap<Class<?>, List<String>>(classComparator);

            // Partition the properties by their declaring class
            BeanAdapter beanAdapter = new BeanAdapter(source);
            for (String propertyName : beanAdapter) {
                if (beanMonitor.isNotifying(propertyName)
                    && !beanAdapter.isReadOnly(propertyName)) {
                    Method method = BeanAdapter.getGetterMethod(sourceType, propertyName);
                    Class<?> declaringClass = method.getDeclaringClass();

                    List<String> propertyNames = declaringClassPartitions.get(declaringClass);
                    if (propertyNames == null) {
                        propertyNames = new ArrayList<String>(nameComparator);
                        declaringClassPartitions.put(declaringClass, propertyNames);
                    }

                    propertyNames.add(propertyName);
                }
            }

            // Add the controls
            for (Class<?> declaringClass : declaringClassPartitions) {
                Form.Section section = new Form.Section();
                section.setHeading(declaringClass.getSimpleName());
                sections.add(section);

                List<String> propertyNames = declaringClassPartitions.get(declaringClass);
                for (String propertyName : propertyNames) {
                    Class<?> type = beanAdapter.getType(propertyName);
                    addControl(beanAdapter, propertyName, type, section);
                }
            }
        }
    }
View Full Code Here

            Class<?> sourceType = source.getClass();
            HashMap<Class<?>, List<String>> declaringClassPartitions =
                new HashMap<Class<?>, List<String>>(classComparator);

            // Partition the properties by their declaring class
            BeanAdapter beanAdapter = new BeanAdapter(source);
            for (String propertyName : beanAdapter) {
                if (beanMonitor.isNotifying(propertyName)
                    && !beanAdapter.isReadOnly(propertyName)) {
                    Method method = BeanAdapter.getGetterMethod(sourceType, propertyName);
                    Class<?> declaringClass = method.getDeclaringClass();

                    List<String> propertyNames = declaringClassPartitions.get(declaringClass);
                    if (propertyNames == null) {
                        propertyNames = new ArrayList<String>(nameComparator);
                        declaringClassPartitions.put(declaringClass, propertyNames);
                    }

                    propertyNames.add(propertyName);
                }
            }

            // Add the controls
            for (Class<?> declaringClass : declaringClassPartitions) {
                Form.Section section = new Form.Section();
                section.setHeading(declaringClass.getSimpleName());
                sections.add(section);

                List<String> propertyNames = declaringClassPartitions.get(declaringClass);
                for (String propertyName : propertyNames) {
                    Class<?> type = beanAdapter.getType(propertyName);
                    addControl(beanAdapter, propertyName, type, section);
                }
            }
        }
    }
View Full Code Here

        if (this.skin != null) {
            throw new IllegalStateException("Skin is already installed.");
        }

        this.skin = skin;
        styles = new BeanAdapter(skin);
        skin.install(this);

        // Apply any defined type styles
        LinkedList<Class<?>> styleTypes = new LinkedList<Class<?>>();
View Full Code Here

                break;
            }

            String key = keys.get(i);

            Map<String, T> adapter = (Map<String, T>) (value instanceof java.util.Map ? new MapAdapter<String, T>((java.util.Map<String, T>) value) : new BeanAdapter(value));
            if (adapter.containsKey(key)) {
                value = adapter.get(key);
            } else if (value instanceof Sequence<?>) {
                Sequence<Object> sequence = (Sequence<Object>)value;
                value = sequence.get(Integer.parseInt(key));
View Full Code Here

        Object parent = get(root, keys);
        if (parent == null) {
            throw new IllegalArgumentException("Invalid path.");
        }

        Map<String, T> adapter = (Map<String, T>) (parent instanceof java.util.Map ? new MapAdapter<String, T>((java.util.Map<String, T>) parent) : new BeanAdapter(parent));

        Object previousValue;
        if (adapter.containsKey(key)) {
            previousValue = adapter.put(key, value);
        } else if (parent instanceof Sequence<?>) {
View Full Code Here

        boolean containsKey;
        if (parent == null) {
            containsKey = false;
        } else {
            Map<String, T> adapter = (Map<String, T>) (parent instanceof java.util.Map ? new MapAdapter<String, T>((java.util.Map<String, T>) parent) : new BeanAdapter(parent));
            containsKey = adapter.containsKey(key);

            if (!containsKey) {
                if (parent instanceof Sequence<?>) {
                    Sequence<Object> sequence = (Sequence<Object>)parent;
View Full Code Here

        // skin, so use similar logic to BXMLSerializer
        DefaultProperty defaultProperty = container.getClass().getAnnotation(DefaultProperty.class);
        if (defaultProperty != null) {
            TreeBranch branch = new TreeBranch(nameForObject(container));
            String defaultPropertyName = defaultProperty.value();
            BeanAdapter beanAdapter = new BeanAdapter(container);
            if (!beanAdapter.containsKey(defaultPropertyName)) {
                throw new IllegalStateException("default property " + defaultPropertyName
                    + " not found on " + container);
            }
            Object defaultPropertyValue = beanAdapter.get(defaultPropertyName);
            if (defaultPropertyValue != null) {
                if (defaultPropertyValue instanceof Component) {
                    TreeNode childBranch = analyseObjectTree(defaultPropertyValue);
                    branch.add(childBranch);
                }
View Full Code Here

        if (this.skin != null) {
            throw new IllegalStateException("Skin is already installed.");
        }

        this.skin = skin;
        styles = new BeanAdapter(skin);
        skin.install(this);

        // Apply any defined type styles
        LinkedList<Class<?>> styleTypes = new LinkedList<Class<?>>();
View Full Code Here

TOP

Related Classes of org.apache.pivot.beans.BeanAdapter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.