Package org.jboss.dashboard

Examples of org.jboss.dashboard.LocaleManager


        return new ShowPanelPage(panel, request, pageId);
    }

    public Map getTextShownByInstance(PanelInstance instance) {
        Map m = new HashMap();
        LocaleManager localeManager = LocaleManager.lookup();
        String[] langs = localeManager.getPlatformAvailableLangs();
        for (int i = 0; i < langs.length; i++) {
            String lang = langs[i];
            String before = instance.getParameterValue(PanelInstance.PARAMETER_HTML_BEFORE, lang);
            String panelBody = getPanelHTMLContent(instance, lang);
            String after = instance.getParameterValue(PanelInstance.PARAMETER_HTML_AFTER, lang);
View Full Code Here


    public void setPanelParams(Set<PanelParameter> panelParams) {
        this.panelParams = panelParams;
    }

    public Map getTitle() {
        LocaleManager localeManager = LocaleManager.lookup();
        final String[] langs = localeManager.getPlatformAvailableLangs();
        Map title = new AbstractMap() {
            public Set entrySet() {
                return new AbstractSet() {
                    public int size() {
                        return langs.length;
View Full Code Here

        };
        return title;
    }

    public String getTitle(String language) {
        LocaleManager localeManager = LocaleManager.lookup();
        return (String) localeManager.localize(getTitle());
    }
View Full Code Here

    protected PanelDriver getDriver() {
        return getProvider().getDriver();
    }

    protected String getDefaultLang() {
        LocaleManager localeManager = LocaleManager.lookup();
        return localeManager.getDefaultLang();
    }
View Full Code Here

     * @param request
     * @return true if the language has changed.
     */
    protected boolean localeChanged(CommandRequest request) {
        String localeLangParm = request.getRequestObject().getParameter("localeLang");
        LocaleManager lManager = LocaleManager.lookup();
        if (localeLangParm != null && !localeLangParm.equals("") && !localeLangParm.equals(lManager.getCurrentLang())) {
            lManager.setCurrentLang(localeLangParm);
            return true;
        }
        return false;
    }
View Full Code Here

            List<Section> sectionList = new ArrayList<Section>(sections.keySet());
            Collections.sort(sectionList);
            int sectionCount = sectionList.size();
            for (Section section : sectionList) {
                Map children = (Map) sections.get(section);
                LocaleManager localeManager = LocaleManager.lookup();

                String sectionTitle = StringUtil.replaceAll(localeManager.localize(section.getTitle()).toString(), "\\", "\\\\");
                sectionTitle = StringUtil.replaceAll(sectionTitle, "'", "\\'");
                result += "['" + sectionTitle + "', '" + section.getId() + "_" + section.getPosition() + "_" + (sectionCount - 1) + "'";

                if (children != null && !children.isEmpty()) {
                    result += ", ";
View Full Code Here

        NavigationManager navigationManager = NavigationManager.lookup();
        UserStatus userStatus = UserStatus.lookup();
        RequestContext requestContext = RequestContext.lookup();

        // ---- Apply locale information, --------------
        LocaleManager localeManager = LocaleManager.lookup();
        // First check if a locale parameter is present in the URI query string.
        Locale localeToSet = null;
        String localeParam = request.getParameter(LOCALE_PARAMETER);
        if (localeParam != null && localeParam.trim().length() > 0)  {
            localeToSet = localeManager.getLocaleById(localeParam);
            if (localeToSet != null) {
                localeManager.setCurrentLocale(localeToSet);
            }
        }

        // No friendly -> nothing to do.
        if (!servletPath.startsWith(FRIENDLY_MAPPING)) return true;

        String contextPath = request.getContextPath();
        requestContext.consumeURIPart(FRIENDLY_MAPPING);
        navigationManager.setShowingConfig(false);
        String requestUri = request.getRequestURI();
        String relativeUri = requestUri.substring(contextPath == null ? 0 : (contextPath.length()));
        relativeUri = relativeUri.substring(servletPath == null ? 0 : (servletPath.length()));

        // Empty URI -> nothing to do.
        if (StringUtils.isBlank(relativeUri)) return true;

        /*
        * Check if the locale information is in the URI value in order to consume it.
        * Locale information is expected in the URI after "/workspace".
        * Examples:
        * - /workspace/en/....
        * - /workspace/es/....
        * - /workspace/en_ES/....
        * NOTES:
        * - Available locales matched in the URI parameter are obtained from JVM available locales.
        * - If the locale is found as platform available, the locale is set.
        * - Otherwise, do nothing, the locale used will be the last one set or default.
        * - In both cases URI locale parameter will be consumed.
        */
        int startLocaleUri = relativeUri.indexOf("/");
        int endLocaleUri = relativeUri.indexOf("/", startLocaleUri + 1);
        endLocaleUri = endLocaleUri > 0 ? endLocaleUri : relativeUri.length();
        String localeUri = relativeUri.substring(startLocaleUri + 1, endLocaleUri);
        Locale uriLocale = localeManager.getLocaleById(localeUri);
        if (uriLocale != null) {
            requestContext.consumeURIPart("/" + localeUri);
            relativeUri = relativeUri.substring(localeUri.length() + 1);
            // Use the locale specified in the URI value only if no locale specified in the qeury string.
            if (localeToSet == null) localeManager.setCurrentLocale(uriLocale);
        }

        // Tokenize the friendly URI.
        StringTokenizer tokenizer = new StringTokenizer(relativeUri, "/", false);
        List tokens = new ArrayList();
View Full Code Here

        return currentEditLocale;
    }

    public void setCurrentEditLocale(Locale l) {
        // Reset the locale to the default one.
        LocaleManager lm = LocaleManager.lookup();
        currentEditLocale = lm.getDefaultLocale();

        // Check the target locale is available.
        // Avoid setting a non supported locale.
        Locale platformLocale = lm.getPlatformLocale(l);
        if (platformLocale != null) {
            currentLocale = platformLocale;
        }
    }
View Full Code Here

        return currentLocale;
    }

    public void setCurrentLocale(Locale l) {
        // Reset the current locale to the default one.
        LocaleManager lm = LocaleManager.lookup();
        currentLocale = lm.getDefaultLocale();

        // Check the target locale is available.
        // Avoid setting a non supported locale.
        Locale platformLocale = lm.getPlatformLocale(l);
        if (platformLocale != null) {
            currentLocale = platformLocale;
        }
    }
View Full Code Here

        // First check if a locale parameter is present in the URI query string.
        String localeParam = request.getParameter(LOCALE_PARAMETER);

        if (localeParam != null && localeParam.trim().length() > 0) {
            LocaleManager localeManager = LocaleManager.lookup();
            Locale localeToSet = localeManager.getLocaleById(localeParam);
            if (localeToSet != null) {
                localeManager.setCurrentLocale(localeToSet);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.jboss.dashboard.LocaleManager

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.