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

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

Introduction

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

Prototype

@Deprecated
public boolean isBrowserSafari() 

Source Link

Document

Flag indicating that the browser is a derivative of the Apple Safari browser platform.

Usage

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

License:Open Source License

public WebTabPanel(IApplication application, final RuntimeTabPanel scriptable, String name, int orient,
        boolean oneTab) {
    super(name);/*w  w  w.  ja  v a  2s. c  o  m*/
    this.application = application;
    this.orient = orient;

    final boolean useAJAX = Utils.getAsBoolean(application.getRuntimeProperties().get("useAJAX")); //$NON-NLS-1$
    setOutputMarkupPlaceholderTag(true);

    if (orient != TabPanel.SPLIT_HORIZONTAL && orient != TabPanel.SPLIT_VERTICAL)
        add(new Label("webform", new Model<String>("")));//temporary add, in case the tab panel does not contain any tabs //$NON-NLS-1$ //$NON-NLS-2$

    // TODO check ignore orient and oneTab??
    IModel<Integer> tabsModel = new AbstractReadOnlyModel<Integer>() {
        private static final long serialVersionUID = 1L;

        @Override
        public Integer getObject() {
            return Integer.valueOf(allTabs.size());
        }
    };

    if (orient != TabPanel.HIDE && orient != TabPanel.SPLIT_HORIZONTAL && orient != TabPanel.SPLIT_VERTICAL
            && !(orient == TabPanel.DEFAULT_ORIENTATION && oneTab)) {
        add(new Loop("tablinks", tabsModel) //$NON-NLS-1$
        {
            private static final long serialVersionUID = 1L;

            private String focusedItem;

            @Override
            protected void populateItem(final LoopItem item) {
                final WebTabHolder holder = allTabs.get(item.getIteration());
                MarkupContainer link = null;
                link = new ServoySubmitLink("tablink", useAJAX) //$NON-NLS-1$
                {
                    private static final long serialVersionUID = 1L;

                    /**
                     * @see wicket.ajax.markup.html.AjaxFallbackLink#onClick(wicket.ajax.AjaxRequestTarget)
                     */
                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        Page page = findPage();
                        if (page != null) {
                            setActiveTabPanel(holder.getPanel());
                            if (target != null) {
                                relinkAtTabPanel(WebTabPanel.this);
                                focusedItem = item.getId();
                                WebEventExecutor.generateResponse(target, page);
                            }
                        }
                    }

                    private void relinkAtForm(WebForm form) {
                        form.visitChildren(WebTabPanel.class, new IVisitor<WebTabPanel>() {
                            public Object component(WebTabPanel wtp) {
                                relinkAtTabPanel(wtp);
                                return IVisitor.CONTINUE_TRAVERSAL;
                            }
                        });
                    }

                    private void relinkAtTabPanel(WebTabPanel wtp) {
                        wtp.relinkFormIfNeeded();
                        wtp.visitChildren(WebForm.class, new IVisitor<WebForm>() {
                            public Object component(WebForm form) {
                                relinkAtForm(form);
                                return IVisitor.CONTINUE_TRAVERSAL;
                            }
                        });
                    }

                    @Override
                    protected void disableLink(final ComponentTag tag) {
                        // if the tag is an anchor proper
                        if (tag.getName().equalsIgnoreCase("a") || tag.getName().equalsIgnoreCase("link") //$NON-NLS-1$//$NON-NLS-2$
                                || tag.getName().equalsIgnoreCase("area")) //$NON-NLS-1$
                        {
                            // Remove any href from the old link
                            tag.remove("href"); //$NON-NLS-1$
                            tag.remove("onclick"); //$NON-NLS-1$
                        }
                    }

                };

                if (item.getId().equals(focusedItem)) {
                    IRequestTarget currentRequestTarget = RequestCycle.get().getRequestTarget();
                    if (currentRequestTarget instanceof AjaxRequestTarget) {
                        ((AjaxRequestTarget) currentRequestTarget).focusComponent(link);
                    }
                    focusedItem = null;
                }

                if (holder.getTooltip() != null) {
                    link.setMetaData(TooltipAttributeModifier.TOOLTIP_METADATA, holder.getTooltip());
                }

                TabIndexHelper.setUpTabIndexAttributeModifier(link, tabSequenceIndex);
                link.add(TooltipAttributeModifier.INSTANCE);

                if (item.getIteration() == 0)
                    link.add(new AttributeModifier("firsttab", true, new Model<Boolean>(Boolean.TRUE))); //$NON-NLS-1$
                link.setEnabled(holder.isEnabled() && WebTabPanel.this.isEnabled());

                String text = holder.getText();
                if (holder.getDisplayedMnemonic() > 0) {
                    final String mnemonic = Character.toString((char) holder.getDisplayedMnemonic());
                    link.add(new SimpleAttributeModifier("accesskey", mnemonic)); //$NON-NLS-1$
                    if (text != null && text.contains(mnemonic) && !HtmlUtils.hasUsefulHtmlContent(text)) {
                        StringBuffer sbBodyText = new StringBuffer(text);
                        int mnemonicIdx = sbBodyText.indexOf(mnemonic);
                        if (mnemonicIdx != -1) {
                            sbBodyText.insert(mnemonicIdx + 1, "</u>"); //$NON-NLS-1$
                            sbBodyText.insert(mnemonicIdx, "<u>"); //$NON-NLS-1$
                            text = sbBodyText.toString();
                        }
                    }
                }
                ServoyTabIcon tabIcon = new ServoyTabIcon("icon", holder, scriptable); //$NON-NLS-1$
                link.add(tabIcon);

                Label label = new Label("linktext", new Model<String>(text)); //$NON-NLS-1$
                label.setEscapeModelStrings(false);
                link.add(label);
                item.add(link);
                IModel<String> selectedOrDisabledClass = new AbstractReadOnlyModel<String>() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public String getObject() {
                        if (!holder.isEnabled() || !WebTabPanel.this.isEnabled()) {
                            if (currentForm == holder.getPanel()) {
                                return "disabled_selected_tab"; //$NON-NLS-1$
                            }
                            return "disabled_tab"; //$NON-NLS-1$
                        } else {
                            if (currentForm == holder.getPanel()) {
                                return "selected_tab"; //$NON-NLS-1$
                            }
                            return "deselected_tab"; //$NON-NLS-1$
                        }
                    }
                };
                item.add(new AttributeModifier("class", true, selectedOrDisabledClass)); //$NON-NLS-1$
                label.add(new StyleAppendingModifier(new Model<String>() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public String getObject() {
                        String style = "white-space: nowrap;"; //$NON-NLS-1$
                        if (foreground != null) {
                            style += " color:" + PersistHelper.createColorString(foreground); //$NON-NLS-1$
                        }
                        if (holder.getIcon() != null) {
                            style += "; padding-left: 3px"; //$NON-NLS-1$
                        }
                        return style;
                    }
                }));
            }
        });

        // All tab panels get their tabs rearranged after they make it to the browser.
        // On Chrome & Safari the tab rearrangement produces an ugly flicker effect, because
        // initially the tabs are not visible and then they are made visible. By
        // sending the tab as invisible and turning it to visible only after the tabs
        // are arranged, this jumping/flickering effect is gone. However a small delay can now be
        // noticed in Chrome & Safari, which should also be eliminated somehow.
        // The tab panel is set to visible in function "rearrageTabsInTabPanel" from "servoy.js".
        add(new StyleAppendingModifier(new Model<String>() {
            private static final long serialVersionUID = 1L;

            @Override
            public String getObject() {
                return "visibility: hidden;overflow:hidden"; //$NON-NLS-1$
            }
        }));

        add(new AbstractServoyDefaultAjaxBehavior() {

            @Override
            protected void respond(AjaxRequestTarget target) {
            }

            @Override
            public void renderHead(IHeaderResponse response) {
                super.renderHead(response);
                boolean dontRearrangeHere = false;

                if (!(getRequestCycle().getRequestTarget() instanceof AjaxRequestTarget)
                        && Utils.getAsBoolean(((MainPage) getPage()).getController().getApplication()
                                .getRuntimeProperties().get("enableAnchors"))) //$NON-NLS-1$
                {
                    Component parentForm = getParent();
                    while ((parentForm != null) && !(parentForm instanceof WebForm))
                        parentForm = parentForm.getParent();
                    if (parentForm != null) {
                        int anch = ((WebForm) parentForm).getAnchors(WebTabPanel.this.getMarkupId());
                        if (anch != 0 && anch != IAnchorConstants.DEFAULT)
                            dontRearrangeHere = true;
                    }
                }
                if (!dontRearrangeHere) {
                    String jsCall = "rearrageTabsInTabPanel('" + WebTabPanel.this.getMarkupId() + "');"; //$NON-NLS-1$ //$NON-NLS-2$
                    // Safari and Konqueror have some problems with the "domready" event, so for those
                    // browsers we'll use the "load" event. Otherwise use "domready", it reduces the flicker
                    // effect when rearranging the tabs.
                    ClientProperties clp = ((WebClientInfo) Session.get().getClientInfo()).getProperties();
                    if (clp.isBrowserKonqueror() || clp.isBrowserSafari())
                        response.renderOnLoadJavascript(jsCall);
                    else
                        response.renderOnDomReadyJavascript(jsCall);
                }
            }

            @Override
            public boolean isEnabled(Component component) {
                return WebClientSession.get().useAjax();
            }

        });
    }
    add(StyleAttributeModifierModel.INSTANCE);
    add(TooltipAttributeModifier.INSTANCE);
    this.scriptable = scriptable;
    ((ChangesRecorder) scriptable.getChangesRecorder()).setDefaultBorderAndPadding(null,
            TemplateGenerator.DEFAULT_LABEL_PADDING);
}

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

License:Open Source License

/**
 * @see org.apache.wicket.protocol.http.WebRequestCycle#newClientInfo()
 */// w  w  w.ja  v  a2s.  com
@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:de.tudarmstadt.ukp.clarin.webanno.webapp.home.page.ApplicationPageBase.java

License:Apache License

@SuppressWarnings({ "serial" })
private void commonInit() {
    //        getSession().setLocale(Locale.ENGLISH);

    logoutPanel = new LogoutPanel("logoutPanel");
    feedbackPanel = new FeedbackPanel("feedbackPanel");
    feedbackPanel.setOutputMarkupId(true);
    feedbackPanel.add(new AttributeModifier("class", "error"));
    feedbackPanel.setFilter(new IFeedbackMessageFilter() {
        @Override/*from ww  w. jav a 2 s . c  o  m*/
        public boolean accept(FeedbackMessage aMessage) {
            Authentication auth = SecurityContextHolder.getContext().getAuthentication();
            String username = auth != null ? auth.getName() : "SYSTEM";
            if (aMessage.isFatal()) {
                LOG.fatal(username + ": " + aMessage.getMessage());
            } else if (aMessage.isError()) {
                LOG.error(username + ": " + aMessage.getMessage());
            } else if (aMessage.isWarning()) {
                LOG.warn(username + ": " + aMessage.getMessage());
            } else if (aMessage.isInfo()) {
                LOG.info(username + ": " + aMessage.getMessage());
            } else if (aMessage.isDebug()) {
                LOG.debug(username + ": " + aMessage.getMessage());
            }
            return true;
        }
    });

    versionLabel = new Label("version", SettingsUtil.getVersionString());

    embeddedDbWarning = new Label("embeddedDbWarning", "USE THIS INSTALLATION FOR TESTING ONLY -- "
            + "AN EMBEDDED DATABASE IS NOT RECOMMENDED FOR PRODUCTION USE");
    embeddedDbWarning.setVisible(false);
    try {
        String driver = repository.getDatabaseDriverName();
        embeddedDbWarning.setVisible(StringUtils.contains(driver.toLowerCase(Locale.US), "hsql"));
    } catch (Throwable e) {
        LOG.warn("Unable to determine which database is being used", e);
    }

    // Override warning about embedded database.
    Properties settings = SettingsUtil.getSettings();
    if ("false".equalsIgnoreCase(settings.getProperty("warnings.embeddedDatabase"))) {
        embeddedDbWarning.setVisible(false);
    }

    // Display a warning when using an unsupported browser
    RequestCycle requestCycle = RequestCycle.get();
    WebClientInfo clientInfo;
    if (Session.exists()) {
        WebSession session = WebSession.get();
        clientInfo = session.getClientInfo();
    } else {
        clientInfo = new WebClientInfo(requestCycle);
    }
    ClientProperties clientProperties = clientInfo.getProperties();

    browserWarning = new Label("browserWarning",
            "THIS BROWSER IS NOT SUPPORTED -- " + "PLEASE USE CHROME OR SAFARI");
    browserWarning.setVisible(!clientProperties.isBrowserSafari() && !clientProperties.isBrowserChrome());

    // Override warning about browser.
    if ("false".equalsIgnoreCase(settings.getProperty("warnings.unsupportedBrowser"))) {
        browserWarning.setVisible(false);
    }

    boolean helpAvailable;
    try {
        Application.get().getResourceSettings().getLocalizer().getString("page.help.link", this);
        Application.get().getResourceSettings().getLocalizer().getString("page.help", this);
        helpAvailable = true;
    } catch (MissingResourceException e) {
        helpAvailable = false;
    }

    add(helpLink = new ExternalLink("helpLink", new ResourceModel("page.help.link", ""),
            new ResourceModel("page.help", "")));
    helpLink.setPopupSettings(new PopupSettings("_blank"));
    helpLink.setVisible(helpAvailable);

    add(logoutPanel);
    add(feedbackPanel);
    add(versionLabel);
    add(embeddedDbWarning);
    add(browserWarning);
}

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  .java  2 s. c o m*/
    return enableCodeMirror;
}