Example usage for org.apache.wicket.protocol.http ClientProperties isBrowserInternetExplorer

List of usage examples for org.apache.wicket.protocol.http ClientProperties isBrowserInternetExplorer

Introduction

In this page you can find the example usage for org.apache.wicket.protocol.http ClientProperties isBrowserInternetExplorer.

Prototype

@Deprecated
public boolean isBrowserInternetExplorer() 

Source Link

Document

Flag indicating that the browser is a derivative of the Microsoft Internet Explorer browser platform.

Usage

From source file:com.pingunaut.wicket.chartjs.core.ChartBehavior.java

License:Apache License

@Override
public void renderHead(Component component, IHeaderResponse response) {
    super.renderHead(component, response);

    // ok, we need jQuery
    response.render(JavaScriptHeaderItem.forReference(JQueryResourceReference.get()));

    ClientProperties clientProperties = ((WebSession) Session.get()).getClientInfo().getProperties();
    boolean isIE = clientProperties.isBrowserInternetExplorer();
    boolean isLowerThan9 = clientProperties.getBrowserVersionMajor() < 9;
    isCanvasSupported = !(isIE && isLowerThan9);
    // ie lower than 9 doesn't know what to do with canvas and some js... so
    // we'll teach him...
    if (!isCanvasSupported) {
        response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(
                AbstractChartPanel.class, "modernizr-2.6.2-respond-1.1.0.min.js")));
        response.render(JavaScriptHeaderItem
                .forReference(new JavaScriptResourceReference(AbstractChartPanel.class, "excanvas.js")));
    }//from  ww w  .  j av a2s .c  o m

    response.render(JavaScriptHeaderItem
            .forReference(new JavaScriptResourceReference(AbstractChartPanel.class, "ChartNew.js")));
    response.render(JavaScriptHeaderItem
            .forReference(new JavaScriptResourceReference(AbstractChartPanel.class, "bridge.js")));

    // chart.js docs describe a problem with initializing canvas context
    // onDomReady in IE < 9. to avoid that, onLoad is used in that case
    // instead
    if (isCanvasSupported) {
        response.render(OnDomReadyHeaderItem.forScript("WicketCharts['" + component.getMarkupId()
                + "']=buildChart('" + component.getMarkupId() + "');"));
    } else {
        response.render(OnLoadHeaderItem.forScript("WicketCharts['" + component.getMarkupId()
                + "']=buildChart('" + component.getMarkupId() + "');"));

    }

    if (component.getParent() instanceof AbstractChartPanel) {
        // another IE crap... animation is deactivated for versions < 9
        // because it's not working anyway
        if (isCanvasSupported) {
            response.render(OnDomReadyHeaderItem
                    .forScript(((AbstractChartPanel) component.getParent()).generateChart()));
        } else {
            ((AbstractChartPanel) component.getParent()).getChart().getOptions().setAnimation(false);
            response.render(
                    OnLoadHeaderItem.forScript(((AbstractChartPanel) component.getParent()).generateChart()));
        }

    }
}

From source file:com.servoy.j2db.server.headlessclient.dataui.WebBaseButton.java

License:Open Source License

@SuppressWarnings("nls")
protected static String instrumentBodyText(CharSequence bodyText, int halign, int valign,
        boolean hasHtmlOrImage, Border border, Insets margin, String cssid, char mnemonic, String elementID,
        String imgURL, Dimension size, boolean isButton, Cursor bodyCursor, boolean isAnchored, int anchors,
        String cssClass, int rotation, boolean isEnabled, ComponentTag openTag) {
    boolean isElementAnchored = anchors != IAnchorConstants.DEFAULT;
    Insets padding = null;/*  w w w .ja  va  2 s.c  o  m*/
    Insets borderMargin = null;
    boolean usePadding = false;
    if (border == null) {
        padding = margin;
    }
    // empty border gets handled as margin
    else if (border instanceof EmptyBorder && !(border instanceof MatteBorder)) {
        usePadding = true;
        padding = ComponentFactoryHelper.getBorderInsetsForNoComponent(border);
    }
    // empty border inside compound border gets handled as margin
    else if (border instanceof CompoundBorder) {
        Border inside = ((CompoundBorder) border).getInsideBorder();
        if (inside instanceof EmptyBorder && !(border instanceof MatteBorder)) {
            usePadding = true;
            padding = ComponentFactoryHelper.getBorderInsetsForNoComponent(inside);
        }
        Border outside = ((CompoundBorder) border).getOutsideBorder();
        if (outside != null) {
            borderMargin = ComponentFactoryHelper.getBorderInsetsForNoComponent(outside);
        }
    } else if (!(border instanceof BevelBorder) && !(border instanceof EtchedBorder)) {
        if (border instanceof TitledBorder) {
            usePadding = true;
            padding = new Insets(5, 7, 5, 7); // margin + border + padding, see beneath
            padding.top += ComponentFactoryHelper.getTitledBorderHeight(border); // add the legend height
        } else {
            padding = ComponentFactoryHelper.getBorderInsetsForNoComponent(border);
        }
    }

    // In order to vertically align the text inside the <button>, we wrap the text inside a <span>, and we absolutely
    // position the <span> in the <button>. However, for centering vertically we drop this absolute positioning and
    // rely on the fact that by default the <button> tag vertically centers its content.
    StringBuffer instrumentedBodyText = new StringBuffer();
    String onFocus = "onfocus=\"this.parentNode.focus()\"";
    if (openTag.getAttribute("onfocus") != null && openTag.getAttribute("onfocus").length() > 0
            && openTag.getName().equals("label"))
        onFocus = "onclick=" + "\"" + openTag.getAttribute("onfocus").replaceFirst("this", "this.parentNode")
                + "\"";
    // the latest browsers (except for IE), do not trigger an onfocus neither on the span nor on the parent label element
    // as a workaround, an onclick is added in the span of label elements that does what the parent onfocus does
    instrumentedBodyText.append("<span " + onFocus + " style='" + //$NON-NLS-1$
            (bodyCursor == null ? ""
                    : "cursor: " + (bodyCursor.getType() == Cursor.HAND_CURSOR ? "pointer" : "default") + "; ")
            + "display: block;");
    int top = 0;
    int bottom = 0;
    int left = 0;
    int right = 0;
    if (padding != null && usePadding) {
        top = padding.top;
        bottom = padding.bottom;
        left = padding.left;
        right = padding.right;
    }

    if (rotation == 0 || size.width >= size.height) {
        // Horizontal alignment and anchoring.
        instrumentedBodyText.append(" left: " + left + "px;"); //$NON-NLS-1$ //$NON-NLS-2$
        instrumentedBodyText.append(" right: " + right + "px;"); //$NON-NLS-1$ //$NON-NLS-2$

        // Vertical alignment and anchoring.
        if (cssid == null) {
            if (valign == ISupportTextSetup.TOP)
                instrumentedBodyText.append(" top: " + top + "px;"); //$NON-NLS-1$ //$NON-NLS-2$
            else if (valign == ISupportTextSetup.BOTTOM)
                instrumentedBodyText.append(" bottom: " + bottom + "px;"); //$NON-NLS-1$ //$NON-NLS-2$
        }

        // Full height.
        if (hasHtmlOrImage && valign != ISupportTextSetup.CENTER && cssid == null)
            instrumentedBodyText.append(" height: 100%;"); //$NON-NLS-1$
        else if ((cssid != null) || (valign != ISupportTextSetup.CENTER))
            instrumentedBodyText.append(" position: absolute;"); //$NON-NLS-1$
        else if (!isButton && !hasHtmlOrImage && imgURL == null) {
            int innerHeight = size.height;
            if (padding != null)
                innerHeight -= padding.top + padding.bottom;
            if (borderMargin != null)
                innerHeight -= borderMargin.top + borderMargin.bottom;
            instrumentedBodyText.append("height: " + innerHeight + "px;line-height: " + innerHeight + "px;");
        }

        if (isAnchored) {
            instrumentedBodyText.append(" position: relative;"); //$NON-NLS-1$
        }
    } else {
        // this is a special case, invert width and height so that text is fully visible when rotated
        int innerWidth = size.height;
        if (padding != null)
            innerWidth -= padding.top + padding.bottom;
        if (borderMargin != null)
            innerWidth -= borderMargin.top + borderMargin.bottom;

        int innerHeight = size.width;
        if (padding != null)
            innerHeight -= padding.left + padding.right;
        if (borderMargin != null)
            innerHeight -= borderMargin.left + borderMargin.right;

        int rotationOffset = (innerWidth - innerHeight) / 2;
        instrumentedBodyText.append(" left: -" + rotationOffset + "px;"); //$NON-NLS-1$ //$NON-NLS-2$
        instrumentedBodyText.append(" top: " + rotationOffset + "px;"); //$NON-NLS-1$ //$NON-NLS-2$
        instrumentedBodyText.append(" position: absolute;");
        instrumentedBodyText.append(" height: " + innerHeight + "px;");
        instrumentedBodyText.append(" width: " + innerWidth + "px;");
        instrumentedBodyText.append("line-height: " + innerHeight + "px;");
    }

    if (!hasHtmlOrImage)
        instrumentedBodyText.append(" overflow: hidden;");

    if (halign == ISupportTextSetup.LEFT)
        instrumentedBodyText.append(" text-align: left;"); //$NON-NLS-1$
    else if (halign == ISupportTextSetup.RIGHT)
        instrumentedBodyText.append(" text-align: right;"); //$NON-NLS-1$
    else
        instrumentedBodyText.append(" text-align: center;"); //$NON-NLS-1$

    if (rotation > 0) {
        String rotationCss = "rotate(" + rotation + "deg)";
        instrumentedBodyText.append(" -ms-transform: " + rotationCss + ";" + " -moz-transform: " + rotationCss //$NON-NLS-1$
                + ";" + " -webkit-transform: " + rotationCss + ";" + " -o-transform: " + rotationCss + ";" + " transform: " + rotationCss + ";");
    }

    if (cssid != null && cssClass == null)
        instrumentedBodyText.append(" visibility: hidden;"); //$NON-NLS-1$

    instrumentedBodyText.append("'"); //$NON-NLS-1$

    if (cssClass != null) {
        instrumentedBodyText.append(" class='"); //$NON-NLS-1$
        instrumentedBodyText.append(cssClass);
        instrumentedBodyText.append("'"); //$NON-NLS-1$
    }

    if (cssid != null) {
        instrumentedBodyText.append(" id='"); //$NON-NLS-1$
        instrumentedBodyText.append(cssid);
        instrumentedBodyText.append("'"); //$NON-NLS-1$
    }

    instrumentedBodyText.append(">"); //$NON-NLS-1$

    //in ie<8 the filter:alpha(opacity=50) applied on the <button> element is not applied to the <img> element
    String IE8filterFIx = "";
    if (!isEnabled) {
        WebClientInfo webClientInfo = new WebClientInfo((WebRequestCycle) RequestCycle.get());
        ClientProperties cp = webClientInfo.getProperties();
        if (cp.isBrowserInternetExplorer() && cp.getBrowserVersionMajor() != -1
                && cp.getBrowserVersionMajor() < 9) {
            IE8filterFIx = "filter:alpha(opacity=50);";
        }
    }
    if (!Strings.isEmpty(bodyText)) {
        CharSequence bodyTextValue = bodyText;
        if (mnemonic > 0 && !hasHtmlOrImage) {
            StringBuffer sbBodyText = new StringBuffer(bodyTextValue);
            int mnemonicIdx = sbBodyText.indexOf(Character.toString(mnemonic));
            if (mnemonicIdx != -1) {
                sbBodyText.insert(mnemonicIdx + 1, "</u>");
                sbBodyText.insert(mnemonicIdx, "<u>");
                bodyTextValue = sbBodyText.toString();
            }
        }

        if (imgURL != null) {

            String onLoadCall = isElementAnchored
                    ? " onload=\"Servoy.Utils.setLabelChildHeight('" + elementID + "', " + valign + ");\""
                    : "";
            StringBuffer sb = new StringBuffer("<img id=\"").append(elementID).append("_img")
                    .append("\" src=\"").append(imgURL)
                    .append("\" style=\"vertical-align: middle;" + IE8filterFIx
                            + (isElementAnchored && (cssClass == null) ? "visibility:hidden;" : "") + "\"")
                    .append(onLoadCall).append("/>");
            sb.append("<span style=\"vertical-align:middle;\">&nbsp;").append(bodyTextValue);
            bodyTextValue = sb.toString();
        }

        instrumentedBodyText.append(bodyTextValue);

        if (imgURL != null) {
            instrumentedBodyText.append("</span>");
        }
    } else if (imgURL != null) {
        instrumentedBodyText.append("<img id=\"");
        instrumentedBodyText.append(elementID).append("_img\"");
        instrumentedBodyText.append("style=\""
                + (isElementAnchored && (cssClass == null) ? " visibility:hidden;" : "") + IE8filterFIx + "\""); // hide it until setLabelChildHeight is calculated
        instrumentedBodyText.append(" src=\"");
        instrumentedBodyText.append(imgURL);
        String onLoadCall = isElementAnchored
                ? " onload=\"Servoy.Utils.setLabelChildHeight('" + elementID + "', " + valign + ");\""
                : "";
        instrumentedBodyText.append("\" align=\"middle\"").append(onLoadCall).append("/>");
    }

    instrumentedBodyText.append("</span>"); //$NON-NLS-1$

    if (border instanceof TitledBorder) {
        instrumentedBodyText = new StringBuffer(getTitledBorderOpenMarkup((TitledBorder) border)
                + instrumentedBodyText.toString() + getTitledBorderCloseMarkup());
    }
    if (border instanceof CompoundBorder) {
        Border outside = ((CompoundBorder) border).getOutsideBorder();
        if (outside != null && outside instanceof TitledBorder) {
            instrumentedBodyText = new StringBuffer(getTitledBorderOpenMarkup((TitledBorder) outside)
                    + instrumentedBodyText.toString() + getTitledBorderCloseMarkup());
        }
    }
    return instrumentedBodyText.toString();
}

From source file:com.servoy.j2db.server.headlessclient.dataui.WebCellBasedView.java

License:Open Source License

/**
 * scroll mode is not supported in Internet Explorer 7 and will always set scroll mode to false in this case
 * @param scrollMode/*from ww w  .j a  va2s .  co  m*/
 */
public void setScrollMode(boolean scrollMode) {
    this.isScrollMode = scrollMode;
    RequestCycle requestCycle = RequestCycle.get();
    if (requestCycle != null) {
        ClientProperties cp = ((WebClientInfo) WebClientSession.get().getClientInfo()).getProperties();
        if (cp.isBrowserInternetExplorer() && cp.getBrowserVersionMajor() != -1
                && cp.getBrowserVersionMajor() < 8) {
            Debug.warn("Cannot set tableview to scroll mode for IE version " + cp.getBrowserVersionMajor() //$NON-NLS-1$
                    + ", UA : " + cp.getNavigatorUserAgent()); //$NON-NLS-1$
            this.isScrollMode = false;
        }
    }
}

From source file:com.servoy.j2db.server.headlessclient.dataui.WebDataLookupField.java

License:Open Source License

private void init() {

    add(new HeaderContributor(new IHeaderContributor() {
        private static final long serialVersionUID = 1L;

        public void renderHead(IHeaderResponse response) {
            response.renderCSSReference(
                    new CompressedResourceReference(WebDataLookupField.class, "servoy_lookupfield.css")); //$NON-NLS-1$
        }/*from   w  ww .j a v a2 s  .co m*/
    }) {
        @Override
        public boolean isEnabled(Component component) {
            return !getScriptObject().isReadOnly() && getScriptObject().isEnabled();
        }
    });

    setOutputMarkupPlaceholderTag(true);

    AutoCompleteSettings behSettings = new AutoCompleteSettings();
    behSettings.setMaxHeightInPx(200);
    behSettings.setPreselect(true);
    behSettings.setShowCompleteListOnFocusGain(true);
    behSettings.setAdjustInputWidth(false);

    ClientProperties clp = (application.getApplicationType() != IApplication.HEADLESS_CLIENT
            ? ((WebClientInfo) Session.get().getClientInfo()).getProperties()
            : null); // in case of batch processors/jsp, we can't get browser info because UI is not given by web client components
    if (clp != null && (!clp.isBrowserInternetExplorer() || clp.getBrowserVersionMajor() >= 8)) {
        // smart positioning doesn't work on IE < 8 (probably because of unreliable clientWidth/clientHeight browser element js properties)
        behSettings.setUseSmartPositioning(true);
        behSettings.setUseHideShowCoveredIEFix(false); // don't know if the problem this setting is for can still be reproduced (I couldn't reproduce it)... this is true by default and makes fields in IE and Opera appear/dissapear if they would be covered by type-ahead popup
    } else {
        behSettings.setUseSmartPositioning(false);
        behSettings.setUseHideShowCoveredIEFix(true);
    }
    behSettings.setThrottleDelay(500);

    IAutoCompleteRenderer<Object> renderer = new IAutoCompleteRenderer<Object>() {
        protected String getTextValue(Object object) {
            String str = ""; //$NON-NLS-1$
            if (object instanceof DisplayString) {
                str = object.toString();
            } else if (object != null && !(object instanceof String)) {
                IConverter con = getConverter(object.getClass());
                if (con != null) {
                    str = con.convertToString(object, getLocale());
                } else {
                    str = object.toString();
                }
            } else if (object != null) {
                str = object.toString();
            }
            if (str == null || str.trim().equals("")) //$NON-NLS-1$
                str = "&nbsp;"; //$NON-NLS-1$
            return str;
        }

        protected void renderChoice(Object object, Response response, String criteria) {
            if (IValueList.SEPARATOR_DESIGN_VALUE.equals(object))
                return;
            String renderedObject = getTextValue(object);
            // escape the markup if it is not html or not just an empty none breaking space (null or empty string object)
            if (!renderedObject.equals("&nbsp;") && !HtmlUtils.hasHtmlTag(renderedObject)) //$NON-NLS-1$
                renderedObject = HtmlUtils.escapeMarkup(renderedObject, true, false).toString();
            response.write(renderedObject);
        }

        /*
         * (non-Javadoc)
         *
         * @see org.apache.wicket.extensions.ajax.markup.html.autocomplete.IAutoCompleteRenderer#render(java.lang.Object, org.apache.wicket.Response,
         * java.lang.String)
         */
        public void render(Object object, Response response, String criteria) {
            String textValue = getTextValue(object);
            if (textValue == null) {
                throw new IllegalStateException(
                        "A call to textValue(Object) returned an illegal value: null for object: "
                                + object.toString());
            }
            textValue = textValue.replaceAll("\\\"", "&quot;");

            response.write("<li textvalue=\"" + textValue + "\"");
            response.write(">");
            renderChoice(object, response, criteria);
            response.write("</li>");
        }

        /*
         * (non-Javadoc)
         *
         * @see org.apache.wicket.extensions.ajax.markup.html.autocomplete.IAutoCompleteRenderer#renderHeader(org.apache.wicket.Response)
         */
        @SuppressWarnings("nls")
        public void renderHeader(Response response) {
            StringBuffer listStyle = new StringBuffer();
            listStyle.append("style=\"");

            String fFamily = "Tahoma, Arial, Helvetica, sans-serif";
            String bgColor = "#ffffff";
            String fgColor = "#000000";
            String fSize = TemplateGenerator.DEFAULT_FONT_SIZE + "px";
            String padding = "2px";
            String margin = "0px";
            if (getFont() != null) {
                Font f = getFont();
                if (f != null) {
                    if (f.getFamily() != null) {
                        fFamily = f.getFamily();
                        if (fFamily.contains(" "))
                            fFamily = "'" + fFamily + "'";
                    }
                    if (f.getName() != null) {
                        String fName = f.getName();
                        if (fName.contains(" "))
                            fName = "'" + fName + "'";
                        fFamily = fName + "," + fFamily;
                    }
                    if (f.isBold())
                        listStyle.append("font-weight:bold; ");
                    if (f.isItalic())
                        listStyle.append("font-style:italic; ");

                    fSize = Integer.toString(f.getSize()) + "px";
                }
            }

            if (getListColor() != null && getListColor().getAlpha() == 255) {
                // background shouldn't be transparent
                bgColor = getWebColor(getListColor().getRGB());
            }
            if (getForeground() != null) {
                fgColor = getWebColor(getForeground().getRGB());
            }
            Insets _padding = getPadding();
            if (getPadding() != null)
                padding = _padding.top + "px " + _padding.right + "px " + _padding.bottom + "px "
                        + _padding.left + "px";

            listStyle.append("font-family:" + fFamily + "; ");
            listStyle.append("background-color: " + bgColor + "; ");
            listStyle.append("color: " + fgColor + "; ");
            listStyle.append("font-size:" + fSize + "; ");
            listStyle.append("min-width:" + (getSize().width - 6) + "px; "); // extract padding and border
            listStyle.append("margin: " + margin + "; ");
            listStyle.append("padding: " + padding + "; ");
            listStyle.append(
                    "text-align:" + TemplateGenerator.getHorizontalAlignValue(getHorizontalAlignment()));
            listStyle.append("\"");

            response.write("<ul " + listStyle + ">");
        }

        /*
         * (non-Javadoc)
         *
         * @see org.apache.wicket.extensions.ajax.markup.html.autocomplete.IAutoCompleteRenderer#renderFooter(org.apache.wicket.Response)
         */
        public void renderFooter(Response response) {
            response.write("</ul>"); //$NON-NLS-1$
        }

        /**
         * Returns web color representation of int rgba color by
         * removing the alpha value
         *
         * @param color int representation of rgba color
         * @return web color of form #rrggbb
         */
        private String getWebColor(int color) {
            String webColor = Integer.toHexString(color);
            int startIdx = webColor.length() - 6;
            if (startIdx < 0)
                startIdx = 0;
            webColor = webColor.substring(startIdx);

            StringBuilder sb = new StringBuilder();
            sb.append('#');
            int nrMissing0 = 6 - webColor.length();
            for (int i = 0; i < nrMissing0; i++) {
                sb.append('0');
            }
            sb.append(webColor);

            return sb.toString();
        }
    };

    AutoCompleteBehavior<Object> beh = new AutoCompleteBehavior<Object>(renderer, behSettings) {
        private static final long serialVersionUID = 1L;

        /**
         * @see org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteBehavior#getChoices(java.lang.String)
         */
        @Override
        protected Iterator<Object> getChoices(String input) {
            String filteredInput = filterInput(input);
            if (changeListener != null)
                dlm.getValueList().removeListDataListener(changeListener);
            try {
                dlm.fill(parentState, getDataProviderID(), filteredInput, false);
                return dlm.iterator();
            } catch (Exception ex) {
                Debug.error(ex);
            } finally {
                if (changeListener != null)
                    dlm.getValueList().addListDataListener(changeListener);
            }
            return Collections.emptyList().iterator();
        }

        /**
         * filters the input in case of masked input (removes the mask)
         */
        private String filterInput(String input) {
            String displayFormat = WebDataLookupField.this.parsedFormat.getDisplayFormat();
            if (displayFormat != null && displayFormat.length() > 0
                    && input.length() == displayFormat.length()) {
                int index = firstBlankSpacePosition(input, displayFormat);
                if (index == -1)
                    return input;
                return input.substring(0, index);
            }
            return input;
        }

        /**
         * Computes the index of the first space char found in the input and is not ' ' nor '*' in the format
         * Example:
         * input  '12 - 3  -  '
         * format '## - ## - #'
         * returns 6
         * @param input
         * @param displayFormat
         * @return The index of the first space char found in the input and is not ' ' nor '*' in the format
         */
        private int firstBlankSpacePosition(String input, String displayFormat) {
            for (int i = 0; i < input.length(); i++) {
                if ((input.charAt(i) == ' ') && (displayFormat.charAt(i) != ' ')
                        && (displayFormat.charAt(i) != '*'))
                    return i;
            }
            return 0;
        }

        /**
         * @see org.apache.wicket.ajax.AbstractDefaultAjaxBehavior#getFailureScript()
         */
        @Override
        protected CharSequence getFailureScript() {
            return "onAjaxError();"; //$NON-NLS-1$
        }

        /**
         * @see org.apache.wicket.ajax.AbstractDefaultAjaxBehavior#getPreconditionScript()
         */
        @Override
        protected CharSequence getPreconditionScript() {
            return "onAjaxCall();" + super.getPreconditionScript(); //$NON-NLS-1$
        }

        // need to set this behavior to true (enterHidesWithNoSelection) because otherwise the onKeyDown events
        // or other events for the component with type ahead would be null in Firefox, and would not execute as
        // expected on the other browsers...
        @Override
        public void renderHead(IHeaderResponse response) {
            settings.setShowListOnEmptyInput(Boolean.TRUE.equals(UIUtils.getUIProperty(getScriptObject(),
                    application, IApplication.TYPE_AHEAD_SHOW_POPUP_WHEN_EMPTY, Boolean.TRUE)));
            settings.setShowListOnFocusGain(Boolean.TRUE.equals(UIUtils.getUIProperty(getScriptObject(),
                    application, IApplication.TYPE_AHEAD_SHOW_POPUP_ON_FOCUS_GAIN, Boolean.TRUE)));
            if (!getScriptObject().isReadOnly() && getScriptObject().isEnabled()) {
                super.renderHead(response);
                response.renderJavascript("Wicket.AutoCompleteSettings.enterHidesWithNoSelection = true;", //$NON-NLS-1$
                        "AutocompleteSettingsID"); //$NON-NLS-1$
            }
        }

        /**
         * @see org.apache.wicket.behavior.AbstractBehavior#isEnabled(org.apache.wicket.Component)
         */
        @Override
        public boolean isEnabled(Component component) {
            IFormUIInternal<?> formui = findParent(IFormUIInternal.class);
            if (formui != null && formui.isDesignMode()) {
                return false;
            }
            return super.isEnabled(component) && WebClientSession.get().useAjax();
        }
    };
    add(beh);
}

From source file:com.servoy.j2db.server.headlessclient.ServoyRequestCycle.java

License:Open Source License

/**
 * @see org.apache.wicket.protocol.http.WebRequestCycle#newClientInfo()
 *//* ww w. j  av  a 2  s  . c om*/
@Override
protected ClientInfo newClientInfo() {
    // We will always do a redirect here. The servoy browser info has to make one.
    WebClientInfo webClientInfo = new WebClientInfo(this);
    ClientProperties cp = webClientInfo.getProperties();
    if (cp.isBrowserInternetExplorer() || cp.isBrowserMozilla() || cp.isBrowserKonqueror()
            || cp.isBrowserOpera() || cp.isBrowserSafari() || cp.isBrowserChrome()) {
        if (cp.isBrowserInternetExplorer() && cp.getBrowserVersionMajor() != -1
                && cp.getBrowserVersionMajor() < 7) {
            // IE6 is no longer supported when anchoring is enabled.
            boolean enableAnchoring = Utils.getAsBoolean(Settings.getInstance()
                    .getProperty("servoy.webclient.enableAnchors", Boolean.TRUE.toString())); //$NON-NLS-1$ 
            if (enableAnchoring) {
                throw new RestartResponseException(new UnsupportedBrowserPage("Internet Explorer 6")); //$NON-NLS-1$
            }
        }
        Page page = getResponsePage();
        if (page != null) {
            throw new RestartResponseAtInterceptPageException(
                    new ServoyBrowserInfoPage(urlFor(page).toString().replaceAll("../", ""))); //$NON-NLS-1$ //$NON-NLS-2$
        } else {
            throw new RestartResponseAtInterceptPageException(new ServoyBrowserInfoPage(getRequest().getURL()));
        }
    }
    return webClientInfo;
}

From source file:org.apache.isis.viewer.wicket.ui.pages.PageAbstract.java

License:Apache License

private boolean isIePre9() {
    final WebClientInfo clientInfo = WebSession.get().getClientInfo();
    final ClientProperties properties = clientInfo.getProperties();
    if (properties.isBrowserInternetExplorer())
        if (properties.getBrowserVersionMajor() < 9)
            return true;
    return false;
}

From source file:org.efaps.ui.wicket.pages.contentcontainer.ContentContainerPage.java

License:Apache License

@Override
public void renderHead(final IHeaderResponse _response) {
    super.renderHead(_response);
    final ClientProperties properties = ((WebClientInfo) getSession().getClientInfo()).getProperties();
    // we use different StyleSheets for different Browsers
    if (properties.isBrowserInternetExplorer()) {
        _response.render(AbstractEFapsHeaderItem.forCss(ContentContainerPage.CSS_IE));
    } else {/* www . j  a v a 2s . c  o  m*/
        _response.render(AbstractEFapsHeaderItem.forCss(ContentContainerPage.CSS));
    }
}

From source file:org.geoserver.web.wicket.CodeMirrorEditor.java

License:Open Source License

private boolean isCodeMirrorSupported() {
    boolean enableCodeMirror = true;
    WebClientInfo clientInfo = (WebClientInfo) WebRequestCycle.get().getClientInfo();
    ClientProperties clientProperties = clientInfo.getProperties();
    if (clientProperties.isBrowserInternetExplorer()) {
        ClientProperties props = extractIEVersion(clientProperties.getNavigatorUserAgent());
        enableCodeMirror = clientProperties.getBrowserVersionMajor() >= 8
                || props.getBrowserVersionMajor() >= 8;
    } else if (clientProperties.isBrowserMozillaFirefox()) {
        ClientProperties props = extractFirefoxVersion(clientProperties.getNavigatorUserAgent());
        enableCodeMirror = clientProperties.getBrowserVersionMajor() >= 3
                || props.getBrowserVersionMajor() >= 3;
    } else if (clientProperties.isBrowserSafari()) {
        ClientProperties props = extractSafariVersion(clientProperties.getNavigatorAppVersion());
        enableCodeMirror = clientProperties.getBrowserVersionMajor() > 5
                || (clientProperties.getBrowserVersionMajor() == 5
                        && clientProperties.getBrowserVersionMinor() >= 2)
                || props.getBrowserVersionMajor() > 5
                || (props.getBrowserVersionMajor() == 5 && props.getBrowserVersionMinor() >= 2);
    } else if (clientProperties.isBrowserOpera()) {
        ClientProperties props = extractOperaVersion(clientProperties.getNavigatorAppVersion());
        enableCodeMirror = clientProperties.getBrowserVersionMajor() >= 9
                || props.getBrowserVersionMajor() >= 9;
    }/* w  w w .j  a v  a2s  .  co  m*/
    return enableCodeMirror;
}