Package org.openfaces.component.input

Examples of org.openfaces.component.input.Slider


        setUpConverter((Slider) component);
        if (AjaxUtil.getSkipExtraRenderingOnPortletsAjax(context))
            return;
        AjaxUtil.prepareComponentForAjax(context, component);
        Components.generateIdIfNotSpecified(component);
        Slider slider = (Slider) component;
        // checkNumericParameters(context, slider);
        String clientId = slider.getClientId(context);
        ResponseWriter writer = context.getResponseWriter();
        encodeRootElementStart(writer, slider);
        writer.writeAttribute("id", clientId, "id");
        Rendering.writeStandardEvents(writer, slider);
        writeAttribute(writer, "onchanging", slider.getOnchanging());
        writeAttribute(writer, "cellpadding", "0");
        writeAttribute(writer, "cellspacing", "0");
        writeAttribute(writer, "border", "0");

        String sliderStyleClass = getSliderStyleClass(context, slider);
        writeAttribute(writer, "class", sliderStyleClass);

        //   String centerCorrection = "";
        //   if (slider.getTicksAlignment().equals(TicksAlignment.CENTER)) {
        //       centerCorrection = slider.getOrientation().equals(Orientation.HORIZONTAL) ? "height:80px;" : "width:80px;";
        //   }
        writeAttribute(writer, "style", slider.getStyle());//centerCorrection + slider.getStyle());

        if (slider.getOrientation().equals(Orientation.HORIZONTAL)) {
            writer.startElement("tr", slider);
        }
        List<String> imagesUrls = getAllImagesList(context, slider);
        Rendering.renderPreloadImagesScript(context, imagesUrls, false);
        encodeContent(context, slider);
View Full Code Here


                "text-align:left;vertical-align:middle;";
    }

    private void encodeTextField(FacesContext context, UIComponent component) throws IOException {
        FacesContext currentInstance = FacesContext.getCurrentInstance();
        Slider slider = (Slider) component;
        ResponseWriter writer = context.getResponseWriter();
        String clientId = slider.getClientId(currentInstance);
        String textFieldId = clientId + DEFAULT_TEXT_FIELD_SUFFIX;
        boolean isHorizontal = slider.getOrientation().equals(Orientation.HORIZONTAL);
        boolean isOff = slider.getTextFieldState().equals(TextFieldState.OFF);
        if (isHorizontal) {
            writer.startElement("td", slider);
        } else {
            writer.startElement("tr", slider);
            writer.startElement("td", slider);
        }
        if (!isOff) {
            writer.writeAttribute("style", "overflow:hidden;border:0 none;margin:0;padding:5px;text-align:center;vertical-align:middle;", null);
            writer.startElement("div", slider);
        } else {
            writer.writeAttribute("style", "display:none;", null);
        }
        writer.startElement("input", slider);
        writer.writeAttribute("id", textFieldId, null);
        writer.writeAttribute("name", textFieldId, null);
        switch (slider.getTextFieldState()) {
            case OFF:
                writeAttribute(writer, "type", "hidden");
                break;
            case READ_ONLY:
                writeAttribute(writer, "class", getTextFieldStyleClass(context, slider));
                writeAttribute(writer, "type", "text");
                writer.writeAttribute("style", slider.getTextFieldStyle() + "cursor: default;", null);
                writer.writeAttribute("readonly", "readonly", null);
                break;
            case WRITE_ENABLED:
                writeAttribute(writer, "class", getTextFieldStyleClass(context, slider));
                writer.writeAttribute("style", slider.getTextFieldStyle(), null);
                writeAttribute(writer, "type", "text");
                break;
        }
        writer.writeAttribute("value", "", null);
        writer.writeAttribute("autocomplete", "off", null);
        if (slider.isDisabled()) {
            writer.writeAttribute("disabled", "disabled", null);
        }
        writer.endElement("input");
        if (!isOff) {
            writer.endElement("div");
        }
        writer.endElement("td");
        if (slider.getOrientation().equals(Orientation.VERTICAL)) {
            writer.endElement("tr");
        }
    }
View Full Code Here

        }
    }

    private void encodeWorkSpace(FacesContext context, UIComponent component) throws IOException {
        FacesContext currentInstance = FacesContext.getCurrentInstance();
        Slider slider = (Slider) component;
        ResponseWriter writer = context.getResponseWriter();
        String clientId = slider.getClientId(currentInstance);
        String workSpaceId = clientId + DEFAULT_WORK_SPACE_SUFFIX;

        if (slider.getOrientation().equals(Orientation.VERTICAL)) {
            writer.startElement("tr", slider);
        }
        writer.startElement("td", slider);

        writer.writeAttribute("style", "margin:auto;", null);

        writer.startElement("div", slider);
        writer.writeAttribute("style", "z-index:50;position:relative;margin:0;padding:0;border:0 none;", null);
        encodeHandle(currentInstance, slider);
        writer.endElement("div");

        writer.startElement("table", slider);
        writer.writeAttribute("id", workSpaceId, null);
        writeAttribute(writer, "cellpadding", "0");
        writeAttribute(writer, "cellspacing", "0");
        writeAttribute(writer, "border", "0");
        writer.startElement("tr", slider);
        if (!slider.getTicksAlignment().equals(TicksAlignment.RIGHT_OR_BOTTOM)) {
            encodeTicks(currentInstance, slider, DEFAULT_LEFT_BOTTOM_TICKS, true);
        }
        if (slider.getOrientation().equals(Orientation.HORIZONTAL)) {
            writer.endElement("tr");
            writer.startElement("tr", slider);
        }
        encodeBar(currentInstance, slider);
        if (slider.getOrientation().equals(Orientation.HORIZONTAL)) {
            writer.endElement("tr");
            writer.startElement("tr", slider);
        }
        if (!slider.getTicksAlignment().equals(TicksAlignment.LEFT_OR_TOP)) {
            encodeTicks(currentInstance, slider, DEFAULT_RIGHT_TOP_TICKS, false);
        }
        writer.endElement("tr");
        writer.endElement("table");
        writer.endElement("td");
        if (slider.getOrientation().equals(Orientation.VERTICAL)) {
            writer.endElement("tr");
        }
    }
View Full Code Here

            writer.endElement("tr");
        }
    }

    private void encodeHandle(FacesContext context, UIComponent component) throws IOException {
        Slider slider = (Slider) component;
        ResponseWriter writer = context.getResponseWriter();
        String clientId = slider.getClientId(context);
        String handleId = clientId + DEFAULT_HANDLE_SUFFIX;
        writer.startElement("div", slider);
        writer.writeAttribute("id", handleId, null);
        writer.writeAttribute("style", "position: absolute;z-index: 100;border:0 none;margin:0;padding:0;", null);
        boolean isDisabled = slider.isDisabled();
        String defaultImageUrl = null;

        switch (slider.getOrientation()) {
            case HORIZONTAL: {
                defaultImageUrl = isDisabled ? DEFAULT_HANDLE_DISABLED_URL : DEFAULT_HANDLE_URL;
                break;
            }
            case VERTICAL:
                defaultImageUrl = isDisabled ? DEFAULT_VERTICAL_HANDLE_DISABLED_URL : DEFAULT_VERTICAL_HANDLE_URL;
                break;
        }
        String handleImageUrl = (String) slider.getAttributes().get(isDisabled ?
                "dragHandleDisabledImageUrl" : "dragHandleImageUrl");
        handleImageUrl = Resources.getURL(context, handleImageUrl, null, defaultImageUrl);
        writer.startElement("img", slider);
        writer.writeAttribute("id", handleId + DEFAULT_ELEMENT_IMAGE_ID, null);
        writer.writeAttribute("style", "display:block;position:absolute;z-index:102;border:0 none;filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + handleImageUrl + "' width:expression(1); height:expression(1); ", null);
View Full Code Here

        }
        return result;
    }

    private void encodeTicks(FacesContext context, UIComponent component, String id, boolean isTopLeft) throws IOException {
        Slider slider = (Slider) component;
        ResponseWriter writer = context.getResponseWriter();
        String clientId = slider.getClientId(context);
        String ticksId = clientId + DEFAULT_TICKS_SUFFIX + id;
        String tickId = ticksId + DEFAULT_A_TICK_SUFFIX;
        boolean isHorizontal = slider.getOrientation().equals(Orientation.HORIZONTAL);

        String defaultMajorImageUrl = isHorizontal ? DEFAULT_MAJOR_TICK_URL : DEFAULT_VERTICAL_MAJOR_TICK_URL;
        String defaultMinorImageUrl = isHorizontal ? DEFAULT_MINOR_TICK_URL : DEFAULT_VERTICAL_MINOR_TICK_URL;
        String majorTicksImageUrl = (String) slider.getAttributes().get("majorTickImageUrl");
        String minorTicksImageUrl = (String) slider.getAttributes().get("minorTickImageUrl");
        majorTicksImageUrl = Resources.getURL(context, majorTicksImageUrl, null, defaultMajorImageUrl);
        minorTicksImageUrl = Resources.getURL(context, minorTicksImageUrl, null, defaultMinorImageUrl);

        String floatStyle = isHorizontal ? "left;" : "none;";

        writer.startElement("td", slider);
        writer.writeAttribute("id", ticksId, null);
        writer.writeAttribute("style", "overflow:visible;border:0 none;padding:0;margin:0;", null);

        String ticksVisibility = !getTicksAndLabelVisibility(slider, true, isTopLeft) ? "hidden;" : null;
        String ticksLabelsVisibility = !getTicksAndLabelVisibility(slider, false, isTopLeft) ? "hidden;" : null;

        boolean isFromStart = slider.getFillDirection().equals(FillDirection.FROM_START);

        String labelValue;

        double minValue = slider.getMinValue().doubleValue();
        double maxValue = slider.getMaxValue().doubleValue();
        double minTick = slider.getMinorTickSpacing().doubleValue();
        double maxTick = slider.getMajorTickSpacing().doubleValue();
        NumberFormat format = NumberFormat.getInstance(context.getViewRoot().getLocale());
        format.setMinimumFractionDigits(0);
        format.setMaximumFractionDigits(2);
        NumberConverter converter = getNumberConverter(context, slider);

        double curTick = minValue;
        if (slider.isTicksLabelsVisible() || slider.isTicksVisible()) {
            for (int counterTicks = 0; curTick <= maxValue; counterTicks++) {
                writer.startElement("div", slider);
                writer.writeAttribute("id", tickId + counterTicks, null);
                writer.writeAttribute("style", "position:relative;z-index:1;border:0 none;padding:0;margin:0; float: " + floatStyle + "font-size:6pt;", null);
                if (isHorizontal) {
                    labelValue = format.format(isFromStart ? (curTick) : (maxValue - curTick + minValue));
                } else {
                    labelValue = format.format(!isFromStart ? (curTick) : (maxValue - curTick + minValue));
                }
                writer.writeAttribute("title", labelValue, null);
                if (slider.isTicksLabelsVisible()) {
                    if (Math.round(curTick / maxTick * 10000) % 10000 == 0) {
                        encodeLabelTick(writer, slider, labelValue, ticksLabelsVisibility, tickId + counterTicks + DEFAULT_ELEMENT_TEXT_ID);
                    }
                }

                if (slider.isTicksVisible()) {
                    encodeTickImage(writer, slider, minorTicksImageUrl, ticksVisibility, tickId + counterTicks + DEFAULT_ELEMENT_IMAGE_ID, isHorizontal);
                }
                curTick = Math.round(100000 * (curTick + minTick)) / 100000.;
                writer.endElement("div");
                if (!isHorizontal) {
View Full Code Here

        writer.endElement("div");
    }

    private void encodeBar(FacesContext context, UIComponent component) throws IOException {
        FacesContext currentInstance = FacesContext.getCurrentInstance();
        Slider slider = (Slider) component;
        ResponseWriter writer = context.getResponseWriter();
        String clientId = slider.getClientId(currentInstance);
        String barId = clientId + DEFAULT_BAR_SUFFIX;

        boolean isDisabled = slider.isDisabled();
        boolean isHorizontal = slider.getOrientation().equals(Orientation.HORIZONTAL);
        String defaultImageUrl = isHorizontal ?
                (isDisabled ? DEFAULT_BAR_DISABLED_URL : DEFAULT_BAR_URL) :
                (isDisabled ? DEFAULT_VERTICAL_BAR_DISABLED_URL : DEFAULT_VERTICAL_BAR_URL);
        String defaultStartImageUrl = isHorizontal ?
                (isDisabled ? DEFAULT_BAR_START_DISABLED_URL : DEFAULT_BAR_START_URL) :
                (isDisabled ? DEFAULT_VERTICAL_BAR_START_DISABLED_URL : DEFAULT_VERTICAL_BAR_START_URL);
        String defaultEndImageUrl = isHorizontal ?
                (isDisabled ? DEFAULT_BAR_END_DISABLED_URL : DEFAULT_BAR_END_URL) :
                (isDisabled ? DEFAULT_VERTICAL_BAR_END_DISABLED_URL : DEFAULT_VERTICAL_BAR_END_URL);

        String barImageUrl = (String) slider.getAttributes().get(isDisabled ? "barDisabledImageUrl" : "barImageUrl");
        barImageUrl = Resources.getURL(context, barImageUrl, null, defaultImageUrl);

        String barStartImageUrl = (String) slider.getAttributes().get(isDisabled ? "barStartDisabledImageUrl" : "barStartImageUrl");
        barStartImageUrl = Resources.getURL(context, barStartImageUrl, null, defaultStartImageUrl);

        String barEndImageUrl = (String) slider.getAttributes().get(isDisabled ? "barEndDisabledImageUrl" : "barEndImageUrl");
        barEndImageUrl = Resources.getURL(context, barEndImageUrl, null, defaultEndImageUrl);

        writer.startElement("td", slider);
        writer.startElement("table", slider);
        writeAttribute(writer, "cellpadding", "0");
View Full Code Here

    private void encodeButton(FacesContext context, UIComponent component, String defaultSuffix,
                              String defaultDisabledUrl, String defaultUrl,
                              String defaultDisabledUrl_vertical, String defaultUrl_vertical, boolean isLT) throws IOException {
        FacesContext currentInstance = FacesContext.getCurrentInstance();
        Slider slider = (Slider) component;
        ResponseWriter writer = context.getResponseWriter();
        String buttonId = slider.getClientId(currentInstance) + defaultSuffix;
        String defaultImageUrl = null;
        boolean isHorizontal = slider.getOrientation().equals(Orientation.HORIZONTAL);
        if (isHorizontal) {
            writer.startElement("td", slider);
            writer.writeAttribute("align", "center", null);
        } else {
            writer.startElement("tr", slider);
            writer.startElement("td", slider);
        }

        writer.writeAttribute("style", "border:0 none;margin:0;padding:5px;overflow:hidden;" + getElementPositioning(slider), null);
        writer.startElement("div", slider);
        writer.writeAttribute("id", buttonId, null);
        boolean isDisabled = slider.isDisabled();
        boolean isInverted = slider.getFillDirection().equals(FillDirection.FROM_END);
        String title = "";
        switch (slider.getOrientation()) {
            case HORIZONTAL: {
                defaultImageUrl = isDisabled ? defaultDisabledUrl : defaultUrl;
                title = isLT ? (!isInverted ? "decrease button" : "increase button") :
                        (isInverted ? "decrease button" : "increase button");
                break;
            }
            case VERTICAL:
                defaultImageUrl = isDisabled ? defaultDisabledUrl_vertical : defaultUrl_vertical;
                title = !isLT ? (!isInverted ? "decrease button" : "increase button") :
                        (isInverted ? "decrease button" : "increase button");
                break;
        }
        writer.writeAttribute("title", title, null);
        String buttonImageUrl;
        if (isLT) {
            buttonImageUrl = (String) slider.getAttributes().get(isDisabled ? "leftTopButtonDisabledImageUrl" :
                    "leftTopButtonImageUrl");
        } else {
            buttonImageUrl = (String) slider.getAttributes().get(isDisabled ? "rightBottomButtonDisabledImageUrl" :
                    "rightBottomButtonImageUrl");
        }
        buttonImageUrl = Resources.getURL(context, buttonImageUrl, null, defaultImageUrl);
        writer.startElement("img", slider);
        writer.writeAttribute("id", buttonId + DEFAULT_ELEMENT_IMAGE_ID, null);
        writer.writeAttribute("style", "padding:0;margin:0;border:0 none;display:block;filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + buttonImageUrl + "' width:expression(1); height:expression(1); ", null);
        writer.writeAttribute("src", buttonImageUrl, null);
        writer.endElement("img");
        writer.endElement("div");
        writer.endElement("td");
        if (slider.getOrientation().equals(Orientation.VERTICAL)) {
            writer.endElement("tr");
        }
    }
View Full Code Here

        return imagesUrls;
    }

    protected void encodeInitScript(FacesContext context, UIComponent component) throws IOException {
        Slider slider = (Slider) component;
        boolean isHorizontal = slider.getOrientation().equals(Orientation.HORIZONTAL);
        String rolloverAEStyle = (String) slider.getAttributes().get("activeElementRolloverStyle");
        String rolloverAEClass = (String) slider.getAttributes().get("activeElementRolloverClass");
        String activeElementRolloverStyleClass = Styles.getCSSClass(context, slider, rolloverAEStyle, StyleGroup.rolloverStyleGroup(), rolloverAEClass, DEFAULT_ACTIVE_ELEMENT_ROLLOVER_CLASS);

        String handleImageUrl = (String) slider.getAttributes().get("dragHandleImageUrl");
        handleImageUrl = Resources.getURL(context, handleImageUrl, null, isHorizontal ? DEFAULT_HANDLE_URL : DEFAULT_VERTICAL_HANDLE_URL);

        String handleImageUrl_rollover = (String) slider.getAttributes().get("dragHandleRolloverImageUrl");
        handleImageUrl_rollover = Resources.getURL(context, handleImageUrl_rollover, null, isHorizontal ? DEFAULT_HANDLE_ROLLOVER_URL : DEFAULT_VERTICAL_HANDLE_ROLLOVER_URL);

        String leftTopButtonImageUrl = (String) slider.getAttributes().get("leftTopButtonImageUrl");
        leftTopButtonImageUrl = Resources.getURL(context, leftTopButtonImageUrl, null, isHorizontal ? DEFAULT_LT_BUTTON_URL : DEFAULT_VERTICAL_LT_BUTTON_URL);

        String leftTopButtonImageUrl_rollover = (String) slider.getAttributes().get("leftTopButtonRolloverImageUrl");
        leftTopButtonImageUrl_rollover = Resources.getURL(context, leftTopButtonImageUrl_rollover, null, isHorizontal ? DEFAULT_LT_BUTTON_ROLLOVER_URL : DEFAULT_VERTICAL_LT_BUTTON_ROLLOVER_URL);

        String rightBottomImageUrl = (String) slider.getAttributes().get("rightBottomButtonImageUrl");
        rightBottomImageUrl = Resources.getURL(context, rightBottomImageUrl, null, isHorizontal ? DEFAULT_RB_BUTTON_URL : DEFAULT_VERTICAL_RB_BUTTON_URL);

        String rightBottomImageUrl_rollover = (String) slider.getAttributes().get("rightBottomButtonRolloverImageUrl");
        rightBottomImageUrl_rollover = Resources.getURL(context, rightBottomImageUrl_rollover, null, isHorizontal ? DEFAULT_RB_BUTTON_ROLLOVER_URL : DEFAULT_VERTICAL_RB_BUTTON_ROLLOVER_URL);


        JSONObject options;

        try {
            options = createFormatOptions(context, slider);
        } catch (JSONException e) {
            throw new FacesException(e);
        }

        Script initScript = new ScriptBuilder().initScript(context, slider, "O$.Slider._init",
                slider.getValue(), slider.getMinValue(), slider.getMaxValue(),
                slider.getMinorTickSpacing(), slider.getMajorTickSpacing(),
                slider.getOrientation(), slider.getFillDirection(),
                slider.isDisabled(), slider.isTooltipEnabled(),
                slider.isBarCanChangeValue(), slider.isBarVisible(),
                slider.getTextFieldState(), slider.isSnapToTicks(),
                slider.getOnchange(), slider.getOnchanging(),
                getTextFieldStyleClass(context, slider),
                getTooltipStyleClass(context, slider),
                isIntegerTooltipType(context, slider),
                getSliderStyleClass(context, slider),
                getSliderFocusedStyleClass(context, slider),
                activeElementRolloverStyleClass,
                slider.getBarAutoRepeatClickDelay(),
                options,
                slider.getTransitionPeriod(),
                handleImageUrl, handleImageUrl_rollover,
                leftTopButtonImageUrl, leftTopButtonImageUrl_rollover,
                rightBottomImageUrl, rightBottomImageUrl_rollover
        );
View Full Code Here

        return Rendering.convertFromString(context, (Slider) component, (String) value);
    }

    public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
        ResponseWriter writer = context.getResponseWriter();
        Slider slider = (Slider) component;

        if (slider.getOrientation().equals(Orientation.HORIZONTAL)) {
            writer.endElement("tr");
        }

        encodeRootElementEnd(writer);
        writer.flush();
View Full Code Here

    }

    @Override
    public void decode(FacesContext context, UIComponent component) {
        Map<String, String> requestMap = context.getExternalContext().getRequestParameterMap();
        Slider slider = (Slider) component;
        String fieldId = slider.getClientId(context) + DEFAULT_TEXT_FIELD_SUFFIX;
        String value = requestMap.get(fieldId);
        if (null != value) {
            slider.setValue(value);
        }
    }
View Full Code Here

TOP

Related Classes of org.openfaces.component.input.Slider

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.