Examples of MutableStyleSheet


Examples of nextapp.echo2.app.MutableStyleSheet

        ApplicationInstance.setActive(app);
       
        app.doInit();
        assertTrue(app.getLabel().isRegistered());
       
        MutableStyleSheet styleSheet = new MutableStyleSheet();

        MutableStyle alphaButtonStyle = new MutableStyle();
        alphaButtonStyle.setProperty(Button.PROPERTY_BORDER, TestConstants.BORDER_THICK_ORANGE);
        alphaButtonStyle.setProperty(Button.PROPERTY_BACKGROUND, Color.YELLOW);
        styleSheet.addStyle(Button.class, "alpha", alphaButtonStyle);

        MutableStyle bravoButtonStyle = new MutableStyle();
        bravoButtonStyle.setProperty(Button.PROPERTY_BORDER, TestConstants.BORDER_THIN_YELLOW);
        bravoButtonStyle.setProperty(Button.PROPERTY_BACKGROUND, Color.GREEN);
        styleSheet.addStyle(Button.class, "bravo", bravoButtonStyle);

        MutableStyle bravoLabelStyle = new MutableStyle();
        bravoLabelStyle.setProperty(Label.PROPERTY_FOREGROUND, Color.RED);
        styleSheet.addStyle(Label.class, "bravo", bravoLabelStyle);
       
        app.setStyleSheet(styleSheet);

        assertNull(app.getLabel().getRenderProperty(Label.PROPERTY_FOREGROUND));
        app.getLabel().setStyleName("charlie");
View Full Code Here

Examples of nextapp.echo2.app.MutableStyleSheet

* Unit test(s) for <code>nextapp.echo2.app.StyleSheet</code>.
*/
public class StyleSheetTest extends TestCase {
   
    public void testBasicOperation() {
        MutableStyleSheet styleSheet = new MutableStyleSheet();
       
        MutableStyle alphaButtonStyle = new MutableStyle();
        alphaButtonStyle.setProperty(Button.PROPERTY_BORDER, TestConstants.BORDER_THICK_ORANGE);
        alphaButtonStyle.setProperty(Button.PROPERTY_BACKGROUND, Color.YELLOW);
        styleSheet.addStyle(Button.class, "alpha", alphaButtonStyle);
       
        assertEquals(alphaButtonStyle, styleSheet.getStyle(Button.class, "alpha"));
        assertNull(styleSheet.getStyle(Button.class, "bravo"));
       
        MutableStyle bravoButtonStyle = new MutableStyle();
        bravoButtonStyle.setProperty(Button.PROPERTY_BORDER, TestConstants.BORDER_THIN_YELLOW);
        bravoButtonStyle.setProperty(Button.PROPERTY_BACKGROUND, Color.GREEN);
        styleSheet.addStyle(Button.class, "bravo", bravoButtonStyle);

        assertEquals(alphaButtonStyle, styleSheet.getStyle(Button.class, "alpha"));
        assertEquals(bravoButtonStyle, styleSheet.getStyle(Button.class, "bravo"));
       
        MutableStyle bravoLabelStyle = new MutableStyle();
        bravoLabelStyle.setProperty(Label.PROPERTY_FOREGROUND, Color.RED);
        styleSheet.addStyle(Label.class, "bravo", bravoLabelStyle);

        assertEquals(alphaButtonStyle, styleSheet.getStyle(Button.class, "alpha"));
        assertEquals(bravoButtonStyle, styleSheet.getStyle(Button.class, "bravo"));
        assertEquals(bravoLabelStyle, styleSheet.getStyle(Label.class, "bravo"));
    }
View Full Code Here

Examples of nextapp.echo2.app.MutableStyleSheet

       
        PropertyLoader propertyLoader = PropertyLoader.forClassLoader(classLoader);

        Map namedStyleMap = new HashMap();
       
        MutableStyleSheet styleSheet = new MutableStyleSheet();
        Element styleSheetElement = document.getDocumentElement();
        Element[] styleElements = DomUtil.getChildElementsByTagName(styleSheetElement, "style");
       
        // First pass, load style information.
        for (int i = 0; i < styleElements.length; ++i) {
            String name = styleElements[i].getAttribute("name");
            if (!styleElements[i].hasAttribute("type")) {
                throw new ComponentXmlException("Component type not specified in style: " + name, null);
            }
            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;
            }
           
            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")) {
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.