Examples of MutableStyle


Examples of nextapp.echo2.app.MutableStyle

        style.removeIndexedProperty("alpha", 1);
        assertFalse(style.isIndexedPropertySet("alpha", 1));
    }
   
    public void testSet1Set2Remove2Set2() {
        MutableStyle style = new MutableStyle();
        style.setProperty("golf", "hotel");
        style.setProperty("alpha", "bravo");
        assertEquals("hotel", style.getProperty("golf"));
        assertEquals("bravo", style.getProperty("alpha"));
        style.setProperty("alpha", null);
        assertEquals("hotel", style.getProperty("golf"));
        assertEquals(null, style.getProperty("alpha"));
        style.setProperty("alpha", "bravo");
        assertEquals("hotel", style.getProperty("golf"));
        assertEquals("bravo", style.getProperty("alpha"));
    }
View Full Code Here

Examples of nextapp.echo2.app.MutableStyle

     * @return a style representing the retrieved property names and values
     * @throws ComponentXmlException
     */
    public Style createStyle(Element propertiesElement, String type)
    throws ComponentXmlException {
        MutableStyle propertyStyle = new MutableStyle();
       
        if (propertiesElement == null) {
            // No properties.
            return new MutableStyle();
        }
       
        ComponentIntrospector ci;
        try {
            ci = ComponentIntrospector.forName(type, classLoader);
        } catch (ClassNotFoundException ex) {
            throw new ComponentXmlException("Unable to introspect component: " + type, ex);
        }
       
        Element[] propertyElements = DomUtil.getChildElementsByTagName(propertiesElement, "property");
        for (int i = 0; i < propertyElements.length; ++i) {
            String propertyName = propertyElements[i].getAttribute("name");
            Class propertyClass;
            if (propertyElements[i].hasAttribute("type")) {
                try {
                    propertyClass = Class.forName(propertyElements[i].getAttribute("type"));
                } catch (ClassNotFoundException ex) {
                    throw new ComponentXmlException("Custom property class not found: "
                            + propertyElements[i].getAttribute("type"), ex);
                }
            } else {
                propertyClass = ci.getPropertyClass(propertyName);
            }
           
            if (propertyClass == null) {
                throw new ComponentXmlException("Property does not exist: " + propertyName, null);
            }
           
            Object propertyValue = getPropertyValue(ci.getObjectClass(), propertyClass, propertyElements[i]);
           
            if (ci.isIndexedProperty(propertyName)) {
                try {
                    int index = Integer.parseInt(propertyElements[i].getAttribute("index"));
                    propertyStyle.setIndexedProperty(propertyName, index, propertyValue);
                } catch (NumberFormatException ex) {
                    throw new ComponentXmlException("Index not set.", ex);
                }
            } else {
                propertyStyle.setProperty(propertyName, propertyValue);
            }
        }
       
        return propertyStyle;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.