Examples of DerivedMutableStyle


Examples of nextapp.echo2.app.DerivedMutableStyle

        MutableStyle baseStyle = new MutableStyle();
        baseStyle.setIndexedProperty("alpha", 1, "a");
        baseStyle.setIndexedProperty("bravo", 2"b");
        baseStyle.setIndexedProperty("bravo", 1"b3");
       
        DerivedMutableStyle derivedStyle = new DerivedMutableStyle(baseStyle);
        derivedStyle.setIndexedProperty("bravo", 2, "b2");
        derivedStyle.setIndexedProperty("charlie", 3, "c");

        assertEquals("b", baseStyle.getIndexedProperty("bravo", 2));
       
        assertEquals("b2", derivedStyle.getIndexedProperty("bravo", 2));
        assertEquals("c", derivedStyle.getIndexedProperty("charlie", 3));
       
        assertEquals("a", derivedStyle.getIndexedProperty("alpha", 1));
        assertEquals("b3", derivedStyle.getIndexedProperty("bravo", 1));
       
        assertTrue(derivedStyle.isIndexedPropertySet("alpha", 1));
        assertFalse(derivedStyle.isIndexedPropertySet("alpha", 2));
        assertFalse(derivedStyle.isIndexedPropertySet("bravo", 0));
        assertTrue(derivedStyle.isIndexedPropertySet("bravo", 1));
        assertTrue(derivedStyle.isIndexedPropertySet("bravo", 2));
        assertFalse(derivedStyle.isIndexedPropertySet("bravo", 3));
    }
View Full Code Here

Examples of nextapp.echo2.app.DerivedMutableStyle

    public void testSimple() {
        MutableStyle baseStyle = new MutableStyle();
        baseStyle.setProperty("alpha", "a");
        baseStyle.setProperty("bravo", "b");
       
        DerivedMutableStyle derivedStyle = new DerivedMutableStyle(baseStyle);
        baseStyle.setProperty("bravo", "b2");
        baseStyle.setProperty("charlie", "c");
       
        assertEquals("a", derivedStyle.getProperty("alpha"));
        assertEquals("b2", derivedStyle.getProperty("bravo"));
        assertEquals("c", derivedStyle.getProperty("charlie"));
    }
View Full Code Here

Examples of nextapp.echo2.app.DerivedMutableStyle

                // StyleSheet contains reference to Component which does not exist in this ClassLoader,
                // and thus should be ignored.
                continue;
            }
           
            DerivedMutableStyle style  = new DerivedMutableStyle();
           
            Element propertiesElement = DomUtil.getChildElementByTagName(styleElements[i], "properties");
            Style propertyStyle = propertyLoader.createStyle(propertiesElement, type);
            style.addStyleContent(propertyStyle);

            Map classToStyleMap = (Map) namedStyleMap.get(name);
            if (classToStyleMap == null) {
                classToStyleMap = new HashMap();
                namedStyleMap.put(name, classToStyleMap);
            }
            classToStyleMap.put(componentClass, style);
           
            styleSheet.addStyle(componentClass, name, style);
        }
       
        // Second pass, bind derived styles to base styles where applicable.
        for (int i = 0; i < styleElements.length; ++i) {
            if (styleElements[i].hasAttribute("base-name")) {
                String name = styleElements[i].getAttribute("name");
                String type = styleElements[i].getAttribute("type");
                Class componentClass;
                try {
                    componentClass = Class.forName(type, true, classLoader);
                } catch (ClassNotFoundException ex) {
                    // StyleSheet contains reference to Component which does not exist in this ClassLoader,
                    // and thus should be ignored.
                    continue;
                }

                Map classToStyleMap = (Map) namedStyleMap.get(name);
                DerivedMutableStyle style = (DerivedMutableStyle) classToStyleMap.get(componentClass);
               
                String baseName = styleElements[i].getAttribute("base-name");
               
                classToStyleMap = (Map) namedStyleMap.get(baseName);
                if (classToStyleMap == null) {
                    throw new ComponentXmlException("Invalid base style name for style name " + name + ".", null);
                }
                Style baseStyle = (Style) classToStyleMap.get(componentClass);
                while (baseStyle == null && componentClass != Object.class) {
                    componentClass = componentClass.getSuperclass();
                    baseStyle = (Style) classToStyleMap.get(componentClass);
                }
                if (baseStyle == null) {
                    throw new ComponentXmlException("Invalid base style name for style name " + name + ".", null);
                }
               
                style.setParentStyle(baseStyle);
            }
        }
   
        return styleSheet;
    }
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.