Example usage for java.util ResourceBundle getBundle

List of usage examples for java.util ResourceBundle getBundle

Introduction

In this page you can find the example usage for java.util ResourceBundle getBundle.

Prototype

@CallerSensitive
public static ResourceBundle getBundle(String baseName, Module module) 

Source Link

Document

Gets a resource bundle using the specified base name and the default locale on behalf of the specified module.

Usage

From source file:com.autentia.tnt.bean.reports.ReportParameterDefinition.java

private String getTraslateValue(String value) {
    String traslateValue = "";
    try {// w w  w.j  av a2  s  . c o  m
        ResourceBundle resource = ResourceBundle.getBundle("com.autentia.tnt.resources.report",
                FacesUtils.getViewLocale());
        traslateValue = resource.getString(value.trim());
    } catch (MissingResourceException ex) {
        log.error(ex.getMessage());
    }
    return traslateValue;
}

From source file:mb.MbAdministrator.java

public void saveGameScore() {
    Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale();
    if (!StringUtils.isNumeric(homeGoals) || !StringUtils.isNumeric(awayGoals)) {
        JsfUtil.addErrorMessage(ResourceBundle.getBundle("localization.messages", locale)
                .getString("AdministratorGameEdit_failureMessage"));
        return;/*w  w w.j  a  v  a 2  s .co m*/
    }
    selectedGame.setScore(homeGoals.trim() + ":" + awayGoals.trim());
    try {
        getEjbGame().edit(selectedGame);
        JsfUtil.addSuccessMessage(ResourceBundle.getBundle("localization.messages", locale)
                .getString("AdministratorGameEdit_successMessage"));
    } catch (Exception e) {
        JsfUtil.addErrorMessage(ResourceBundle.getBundle("localization.messages", locale)
                .getString("AdministratorGameEdit_failureMessage"));
    }
}

From source file:es.pode.empaquetador.presentacion.agregar.personales.AgregarPersonalesControllerImpl.java

/**
 * @see es.pode.empaquetador.presentacion.agregar.personales.AgregarPersonalesController#submit(org.apache.struts.action.ActionMapping, es.pode.empaquetador.presentacion.agregar.personales.SubmitForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 *///from w  w w  .j  a  v  a  2 s  .  c o m
public final void submit(ActionMapping mapping,
        es.pode.empaquetador.presentacion.agregar.personales.SubmitForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    java.util.Locale locale = (Locale) request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE);
    ResourceBundle i18n = ResourceBundle.getBundle("application-resources", locale);

    String accion = form.getAction();
    String identificador = form.getIdODE();
    if (accion.equals(i18n.getString("portal_empaquetado_gestorSubman_agregarLocal.aceptar"))) {
        if ((identificador == null) || (identificador.equals(""))) {
            throw new ValidatorException("{exportar.subirArchivo}");
        }

    }
}

From source file:com.sonicle.webtop.core.app.ReportManager.java

private ResourceBundle loadResourceBundle(AbstractReport report) throws WTException {
    if (report.getConfig().getLocale() == null)
        throw new WTException("Locale is required if /'HasResourceBundle/' is set to true");
    String path = report.getPath() + report.getResourceBundleName();
    return ResourceBundle.getBundle(path, report.getConfig().getLocale());
}

From source file:es.pode.empaquetador.presentacion.previsualizar.PrevisualizarControllerImpl.java

@Override
public String submit(ActionMapping mapping, SubmitForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    GestorSesion gs = new GestorSesion();
    boolean esAvanzado = gs.esAvanzado();
    String action = form.getAction();
    String result = "Aceptar";
    if (logger.isDebugEnabled())
        logger.debug("submit con parametros action=" + action + " tipoVisualizador = "
                + form.getTipoVisualizador() + " esAvanzado = " + esAvanzado);
    java.util.Locale locale = (Locale) request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE);
    ResourceBundle i18n = ResourceBundle.getBundle("application-resources", locale);
    if (i18n.getString("comunes.cancelar").equalsIgnoreCase(action)) {
        // Ha pulsado Cancelar
        if (esAvanzado)
            result = "CancelarAvanzado";
        else/* w  ww  .  jav a 2 s. co  m*/
            result = "CancelarBasico";
    }
    if (logger.isDebugEnabled())
        logger.debug("Retorno de submit = " + result);
    return result;
}

From source file:es.pode.empaquetador.presentacion.avanzado.organizaciones.elementos.crearelemento.CrearElementoControllerImpl.java

public final void submit01(ActionMapping mapping,
        es.pode.empaquetador.presentacion.avanzado.organizaciones.elementos.crearelemento.Submit01Form form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    CrearElementoSession sesElem = this.getCrearElementoSession(request);

    java.util.Locale locale = (Locale) request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE);
    ResourceBundle i18n = ResourceBundle.getBundle("application-resources", locale);

    String tipo = form.getReferenciado();
    String titulo = form.getTitle();
    String[] selectPresentation = form.getSelectPresentation();
    String completionThreshold = form.getCompletionThreshold();
    String dataFromLMS = form.getDataFromLMS();
    String timeLimitAction = form.getTimeLimitAction();
    Boolean isVisible = form.getIsVisible();
    String accion = form.getAction();
    logger.debug("Datos del form tras el paso 01 de crear elemento : title = " + form.getTitle() + " : tipo = "
            + form.getReferenciado());/*from  w  ww . j a  v  a 2s .  c o  m*/
    if (accion.equals(i18n.getString("portal_empaquetado_crearElemento.continuar"))) {
        sesElem.setReferenciado(tipo);

        if (form.getTitle() == null || form.getTitle().trim().equals("")) {
            throw new ValidatorException("{portal_empaquetado_crearElemento.exception}");
        } else {
            sesElem.setTitle(titulo);
        }

        sesElem.setSelectPresentation(selectPresentation);
        Double content = null;
        if (!completionThreshold.equals("")) {
            //                 Pattern pattern = Pattern.compile("^[0-9]*(.[0-9]*)?$");
            Pattern pattern = Pattern.compile("^((0+(\\.[0-9]+)?)|(0*1(\\.0+)?))$");
            Matcher matcher = pattern.matcher(completionThreshold);

            if (matcher.find()) {
                content = new Double(completionThreshold);
            } else {
                throw new ValidatorException("{portal_empaquetado_crearElemento.exceptionCompletion}");
            }
        }
        sesElem.setCompletionThreshold(content);
        sesElem.setDataFromLMS(dataFromLMS);
        sesElem.setTimeLimitAction(timeLimitAction);
        sesElem.setSelectPresentation(selectPresentation);
        sesElem.setIsVisible(isVisible);
    }
}

From source file:es.pode.visualizador.presentacion.descargas.DescargasControllerImpl.java

public String submit(ActionMapping mapping, SubmitForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    String sId = form.getIdentificador();

    if (logger.isDebugEnabled())
        logger.debug("Descargas: Submit con parametros identificador = " + sId);
    Locale locale = (Locale) request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE);
    ResourceBundle i18n = ResourceBundle.getBundle("application-resources", locale);
    Long id = Long.valueOf(sId);
    DescargaVO descarga = getSrvDescargas().obtenerDescarga(id);

    String url = "/" + descarga.getPath();
    //URLs tipo host/agrega
    url = "http://" + LdapUserDetailsUtils.getHost() + LdapUserDetailsUtils.getSubdominio() + url;
    if (logger.isDebugEnabled())
        logger.debug("Descargando a : " + url);
    response.sendRedirect(url);/*from  w  ww . j a va 2s .c  o  m*/

    return "Descargar";
}

From source file:edu.ku.brc.specify.prefs.SystemPrefs.java

/**
 * Constructor./*w w  w .  j  ava  2  s.c o m*/
 */
public SystemPrefs() {
    createForm("Preferences", "System");

    JButton clearCache = form.getCompById("clearcache");

    clearCache.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            clearCache();
        }
    });

    ValBrowseBtnPanel browse = form.getCompById("7");
    if (browse != null) {
        oldSplashPath = localPrefs.get(SPECIFY_BG_IMG_PATH, null);
        browse.setValue(oldSplashPath, null);
    }

    final ValComboBox localeCBX = form.getCompById("5");
    localeCBX.getComboBox().setRenderer(new LocaleRenderer());
    localeCBX.setEnabled(false);

    SwingWorker workerThread = new SwingWorker() {
        protected int inx = -1;

        @Override
        public Object construct() {

            Vector<Locale> locales = new Vector<Locale>();
            Collections.addAll(locales, Locale.getAvailableLocales());
            Collections.sort(locales, new Comparator<Locale>() {
                public int compare(Locale o1, Locale o2) {
                    return o1.getDisplayName().compareTo(o2.getDisplayName());
                }
            });

            int i = 0;
            String language = AppPreferences.getLocalPrefs().get("locale.lang",
                    Locale.getDefault().getLanguage());
            String country = AppPreferences.getLocalPrefs().get("locale.country",
                    Locale.getDefault().getCountry());
            String variant = AppPreferences.getLocalPrefs().get("locale.var", Locale.getDefault().getVariant());

            Locale prefLocale = new Locale(language, country, variant);

            int justLangIndex = -1;
            Locale cachedLocale = Locale.getDefault();
            for (Locale l : locales) {
                try {
                    Locale.setDefault(l);
                    ResourceBundle rb = ResourceBundle.getBundle("resources", l);

                    boolean isOK = (l.getLanguage().equals("en") && StringUtils.isEmpty(l.getCountry()))
                            || (l.getLanguage().equals("pt") && l.getCountry().equals("PT"));

                    if (isOK && rb.getKeys().hasMoreElements()) {
                        if (l.getLanguage().equals(prefLocale.getLanguage())) {
                            justLangIndex = i;
                        }
                        if (l.equals(prefLocale)) {
                            inx = i;
                        }
                        localeCBX.getComboBox().addItem(l);
                        i++;
                    }

                } catch (MissingResourceException ex) {
                }
            }

            if (inx == -1 && justLangIndex > -1) {
                inx = justLangIndex;
            }
            Locale.setDefault(cachedLocale);

            return null;
        }

        @Override
        public void finished() {
            UIValidator.setIgnoreAllValidation("SystemPrefs", true);
            localeCBX.setEnabled(true);
            localeCBX.getComboBox().setSelectedIndex(inx);
            JTextField loadingLabel = form.getCompById("6");
            if (loadingLabel != null) {
                loadingLabel.setText(UIRegistry.getResourceString("LOCALE_RESTART_REQUIRED"));
            }
            UIValidator.setIgnoreAllValidation("SystemPrefs", false);
        }
    };

    // start the background task
    workerThread.start();

    ValCheckBox chk = form.getCompById("2");
    chk.setValue(localPrefs.getBoolean(VERSION_CHECK, true), "true");

    chk = form.getCompById("3");
    chk.setValue(remotePrefs.getBoolean(SEND_STATS, true), "true");

    chk = form.getCompById("9");
    chk.setValue(remotePrefs.getBoolean(SEND_ISA_STATS, true), "true");
    chk.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Collection collection = AppContextMgr.getInstance().getClassObject(Collection.class);
            if (collection != null) {
                String isaNumber = collection.getIsaNumber();
                if (StringUtils.isNotEmpty(isaNumber) && !((JCheckBox) e.getSource()).isSelected()) {
                    UIRegistry.showLocalizedMsg("ISA_STATS_WARNING");
                }
            }
        }
    });

    // Not sure why the form isn't picking up the pref automatically
    /* remove if worldwind is broken*/ValCheckBox useWWChk = form.getCompById(USE_WORLDWIND);
    /* remove if worldwind is broken*/ValCheckBox hasOGLChk = form.getCompById(SYSTEM_HasOpenGL);

    /* remove if worldwind is broken*/useWWChk.setValue(localPrefs.getBoolean(USE_WORLDWIND, false), null);
    /* remove if worldwind is broken*/hasOGLChk.setValue(localPrefs.getBoolean(SYSTEM_HasOpenGL, false), null);
    /* remove if worldwind is broken*/hasOGLChk.setEnabled(false);

    //ValCheckBox askCollChk = form.getCompById(ALWAYS_ASK_COLL);
    //askCollChk.setValue(localPrefs.getBoolean(ALWAYS_ASK_COLL, false), null);
}

From source file:es.pode.administracion.presentacion.adminusuarios.bajaUsuario.BajaUsuarioControllerImpl.java

private ResourceBundle getFicherRecursos(Locale locale) {

    ResourceBundle ficheroRecursos = null;
    ficheroRecursos = ResourceBundle.getBundle("application-resources", locale);
    return ficheroRecursos;
}

From source file:es.pode.empaquetador.presentacion.avanzado.organizaciones.crear.CrearOrganizacionControllerImpl.java

public final java.lang.String selectAction(ActionMapping mapping,
        es.pode.empaquetador.presentacion.avanzado.organizaciones.crear.SelectActionForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    /*//  www  . jav a 2 s  .com
    * Metodo de decision para el action. Analiza los parametros
    * actionSubmit (value de los botones submit) para redirigir al caso de uso
    * correspondiente. El actionSubmit llegara
    * internacionalizado, por lo que es necesario acceder al ResouceBundle
    * para obtener el valor correcto en la comparacion.
    */

    String result = null;
    String actionSubmit = form.getAction();
    java.util.Locale locale = (Locale) request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE);
    ResourceBundle i18n = ResourceBundle.getBundle("application-resources", locale);

    if (form.getAction() == (null)) {
        throw new ValidatorException("{portal_empaquetado.exception}");
    }

    else if (actionSubmit.equals(i18n.getString("portal_empaquetado_crearOrganizaciones.aceptar"))) {
        result = "Aceptar";
    } else if (actionSubmit.equals(i18n.getString("portal_empaquetado_crearOrganizaciones.cancelar"))) {
        result = "Cancelar";
    }

    else if (actionSubmit.equals(i18n.getString("portal_empaquetado_crearOrganizaciones.metadatos"))) {
        result = "Metadatos";
    }
    Logger.getLogger(this.getClass())
            .error("El valor del submit no es correcto (actionSubmit = " + actionSubmit + ";");

    return result;
}