Package com.volantis.mcs.protocols.widgets.attributes

Examples of com.volantis.mcs.protocols.widgets.attributes.TimerAttributes


        // Initialise superclass.
        super(WidgetElements.TIMER, context);

        // Create an instance of DigitalClockContent attributes.
        // It'll be initialised later in initialiseAttributes() method.
        protocolAttributes = new TimerAttributes();
    }
View Full Code Here


    // Javadoc inherited
    protected void initialiseElementSpecificAttributes(XDIMEContextInternal context, XDIMEAttributes attributes)
        throws XDIMEException {
       
        TimerAttributes timerAttributes = (TimerAttributes) protocolAttributes;
        //default values are 0;
        Integer start = new Integer(0);
        Integer stop = new Integer(0);
       
        String start_string = attributes.getValue("", "start-time");
        String stop_string = attributes.getValue("", "stop-time");
       
        //check if start-time attribute is correct
        if (start_string!=null){
            try {
                start = new Integer(start_string);
            }catch (NumberFormatException e){
                throw new XDIMEException(exceptionLocalizer.format(
                        "widget-unexpected-attributes-type",
                        "int"), e);
            }
           
            if (start.intValue()<0){
                throw new XDIMEException(exceptionLocalizer.format(
                        "attribute-value-incorrect",
                        new Object[]{"start-time","start-time >= 0"}));
            }
        }

        //check if stop-time attribute is correct
        if (stop_string != null){
            try {
                stop = new Integer(stop_string);
            }catch (NumberFormatException e){
                throw new XDIMEException(exceptionLocalizer.format(
                        "widget-unexpected-attributes-type",
                        "int"), e);
            }
           
            if (stop.intValue()<0){
                throw new XDIMEException(exceptionLocalizer.format(
                        "attribute-value-incorrect",
                        new Object[]{"stop-time","stop-time >= 0"}));
            }  
        }
       
        if (start.intValue() < stop.intValue()){
            throw new XDIMEException(exceptionLocalizer.format(
                    "attribute-value-incorrect",
                    new Object[]{"start-time","start-time >= stop-time "}));
        }
       
        //attributes are ok
        timerAttributes.setStartTime(start);
        timerAttributes.setStopTime(stop);
    }
View Full Code Here

        if(!isWidgetSupported(protocol)) {
            return;
        }               

        TimerAttributes timerAttributes = (TimerAttributes)attributes;

        // require AJAX script module
        if ( timerAttributes.getLoadAttributes() != null ) {
            require(WidgetScriptModules.BASE_AJAX, protocol, attributes);
       

        protocol.writeCloseSpan(timerSpanAttributes);
       
        // retrive list of attributes of clock content element which are
        // within the timer element.
        List contentAttributes = timerAttributes.getContentAttributes();
       
        // create ClockContentHandler to merge contents
        ClockContextHandler clockContextHandler = new ClockContextHandler();
       
        clockContextHandler.mergeContentAttributes(contentAttributes);
       
        String[] digits = clockContextHandler.getClockContentIds("digits");
        String[] separators = clockContextHandler.getClockContentIds("separators");
       
        Styles styles = timerAttributes.getStyles();
       
        StylesExtractor stylesExtractor = createStylesExtractor(
                protocol, styles);
       
        String dateTimeFormat =
            getDateTimeFormat(stylesExtractor.getDateTimeFormat(),specialMarks);

       
        LoadAttributes loadAttributes = timerAttributes.getLoadAttributes();
       
        StringBuffer textLoadAttr = new StringBuffer();
        if(loadAttributes != null) {
            textLoadAttr.append(", load_src: ")
            .append(createJavaScriptString(loadAttributes.getSrc()));
        }
       
        StringBuffer startStopAttr = new StringBuffer();
        Integer start = timerAttributes.getStartTime();
        Integer stop = timerAttributes.getStopTime();
        if(start!= null && stop !=null) {
            startStopAttr.append(", start_time: '")
            .append(timerAttributes.getStartTime().toString()).append("', ")
            .append("stop_time: '")
            .append(timerAttributes.getStopTime().toString()).append("'");
        }

        StringBuffer textBuffer = new StringBuffer();
       
        textBuffer.append(createJavaScriptWidgetRegistrationOpening(timerAttributes.getId()))
                .append("new Widget.Timer(")
                .append(createJavaScriptString(timerSpanAttributes.getId()))
                .append(", {")
                .append("start_time: '").append(""+timerAttributes.getStartTime()).append("', ")
                .append("stop_time: '").append(""+timerAttributes.getStopTime()).append("', ")
                .append("format: [").append(dateTimeFormat).append("], ")
                .append("digits: [").append(splitIds(digits)).append("], ")
                .append("separators: [")
                .append(splitIds(separators)).append("]")
                .append(textLoadAttr)
View Full Code Here

TOP

Related Classes of com.volantis.mcs.protocols.widgets.attributes.TimerAttributes

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.