Example usage for java.util ResourceBundle getString

List of usage examples for java.util ResourceBundle getString

Introduction

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

Prototype

public final String getString(String key) 

Source Link

Document

Gets a string for the given key from this resource bundle or one of its parents.

Usage

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

public final java.lang.String selectAction02(ActionMapping mapping,
        es.pode.empaquetador.presentacion.avanzado.organizaciones.elementos.crearelemento.SelectAction02Form form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    /*/*from  ww  w .  j  a v a2 s.  c  o m*/
    * 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_crearElemento.cancelar2"))) {
        result = "Cancelar";
    } else if (actionSubmit.equals(i18n.getString("portal_empaquetado_crearElemento.aceptar2"))) {
        result = "Aceptar";
    }

    Logger.getLogger(this.getClass())
            .error("El valor del submit no es correcto (actionSubmit = " + actionSubmit + ";");

    return result;
}

From source file:cz.muni.fi.javaseminar.kafa.bookregister.gui.MainWindow.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.//w  w  w.ja v  a2  s.co  m
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    authorsPanel = new javax.swing.JPanel();
    authorsLabel = new javax.swing.JLabel();
    authorsScrollPane = new javax.swing.JScrollPane();
    authorsTable = new javax.swing.JTable();
    booksPanel = new javax.swing.JPanel();
    booksScrollPane = new javax.swing.JScrollPane();
    booksTable = new javax.swing.JTable();
    booksLabel = new javax.swing.JLabel();
    mainMenuBar = new javax.swing.JMenuBar();
    fileMenu = new javax.swing.JMenu();
    newAuthorMenuItem = new javax.swing.JMenuItem();
    newBookMenuItem = new javax.swing.JMenuItem();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("Book Register 1.0");
    setMinimumSize(new java.awt.Dimension(1024, 480));
    setPreferredSize(new java.awt.Dimension(1024, 640));
    getContentPane().setLayout(new java.awt.GridLayout(2, 1));

    authorsPanel.setLayout(new java.awt.BorderLayout());

    java.util.ResourceBundle bundle = java.util.ResourceBundle
            .getBundle("cz/muni/fi/javaseminar/kafa/bookregister/gui/Bundle"); // NOI18N
    authorsLabel.setText(bundle.getString("Table.authors.title")); // NOI18N
    authorsPanel.add(authorsLabel, java.awt.BorderLayout.PAGE_START);

    authorsTable.setModel(authorsTableModel);
    authorsTable.setMinimumSize(new java.awt.Dimension(480, 640));
    authorsScrollPane.setViewportView(authorsTable);

    authorsPanel.add(authorsScrollPane, java.awt.BorderLayout.CENTER);

    getContentPane().add(authorsPanel);

    booksPanel.setLayout(new java.awt.BorderLayout());

    booksTable.setModel(booksTableModel);
    booksScrollPane.setViewportView(booksTable);

    booksPanel.add(booksScrollPane, java.awt.BorderLayout.CENTER);

    booksLabel.setText(bundle.getString("Table.books.title")); // NOI18N
    booksPanel.add(booksLabel, java.awt.BorderLayout.PAGE_START);

    getContentPane().add(booksPanel);

    fileMenu.setText(bundle.getString("Menu.file")); // NOI18N

    newAuthorMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A,
            java.awt.event.InputEvent.CTRL_MASK));
    newAuthorMenuItem.setText(bundle.getString("Menu.file.newAuthor")); // NOI18N
    newAuthorMenuItem.setMnemonic(KeyEvent.VK_N);
    newAuthorMenuItem.setAction(spawnNewAuthorWindowAction);
    newAuthorMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_DOWN_MASK));
    fileMenu.add(newAuthorMenuItem);

    newBookMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_B,
            java.awt.event.InputEvent.CTRL_MASK));
    newBookMenuItem.setText(bundle.getString("Menu.file.newBook")); // NOI18N
    newBookMenuItem.setMnemonic(KeyEvent.VK_B);
    newBookMenuItem.setAction(spawnNewBookWindowAction);
    newBookMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, KeyEvent.CTRL_DOWN_MASK));

    newBookMenuItem.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            JMenuItem m = (JMenuItem) e.getSource();
            if (!m.isEnabled())
                JOptionPane.showMessageDialog(MainWindow.this, "You have to create an author first.");
        }
    });
    fileMenu.add(newBookMenuItem);

    fileMenu.setMnemonic(KeyEvent.VK_F);

    mainMenuBar.add(fileMenu);

    setJMenuBar(mainMenuBar);

    pack();
}

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

public final java.lang.String selectAction01(ActionMapping mapping,
        es.pode.empaquetador.presentacion.avanzado.organizaciones.elementos.crearelemento.SelectAction01Form form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    /*//w  w w .j  a va 2s  . c  o  m
    * 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_crearElemento.cancelar"))) {
        result = "Cancelar";
    } else if (actionSubmit.equals(i18n.getString("portal_empaquetado_crearElemento.continuar"))) {
        result = "Continuar";
    } else if (actionSubmit.equals(i18n.getString("portal_empaquetado_crearElemento.metadatos"))) {
        result = "Metadatos";
    } else {

        logger.error("El valor del submit no es correcto (actionSubmit = " + actionSubmit + ";");
    }
    return result;
}

From source file:es.pode.empaquetador.presentacion.avanzado.organizaciones.elementos.gestor.GestorElementosControllerImpl.java

public final void submit(ActionMapping mapping,
        es.pode.empaquetador.presentacion.avanzado.organizaciones.elementos.gestor.SubmitForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {

    EmpaquetadorSession sesEmpaq = this.getEmpaquetadorSession(request);
    List identificadores = form.getIdentifierRowSelection();
    java.util.Locale locale = (Locale) request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE);
    ResourceBundle i18n = ResourceBundle.getBundle(APPLICATION_RESOURCES, locale);
    String accion = form.getAction();
    if ((accion.equals(i18n.getString(ELIMINAR_ACTION))) || (accion.equals(i18n.getString(COPIAR_ACTION)))
            || (accion.equals(i18n.getString(CORTAR_ACTION)))) {
        if ((identificadores == null) || (identificadores.size() == 0)) {
            throw new ValidatorException(PORTAL_EMPAQUETADO_EXCEPTION);
        } else {//ww w  . j  a v a2s  .  c o m
            form.setIdentificadores(identificadores);
        }
    } else if ((accion.equals(i18n.getString(PEGAR_ACTION)))) {
        if ((sesEmpaq.getPortapapeles() == null) || (sesEmpaq.getPortapapeles().size() == 0)) {
            throw new ValidatorException(PORTAL_EMPAQUETADO_EXCEPTION);
        }
    }

}

From source file:com.stratelia.silverpeas.silvertrace.SilverTrace.java

/**
 * Reset all modules, messages, appenders and all set debug levels.
 *//* w ww .  j a  v  a 2  s.  c  o  m*/
static public void resetAll() {

    availableModules.clear();
    // Reset all appenders and debug levels
    Logger.getRootLogger().getLoggerRepository().resetConfiguration();
    Logger.getRootLogger().setAdditivity(true);
    Logger.getRootLogger().setLevel(Level.ERROR);
    ResourceBundle resources = FileUtil.loadBundle("org.silverpeas.silvertrace.settings.silverTrace",
            Locale.ROOT);
    String pathFiles = resources.getString("pathSilverTrace");
    String languageMessage = resources.getString("language");
    errorDir = resources.getString("ErrorDir");
    // Load the available messages
    traceMessages.initFromProperties(pathFiles, languageMessage);
    // Get available modules
    List<File> theFiles = traceMessages.getPropertyFiles(pathFiles, "");
    for (File theFile : theFiles) {
        InputStream is = null;
        try {
            is = new FileInputStream(theFile);
            Properties currentFileProperties = new Properties();
            currentFileProperties.load(is);
            initFromProperties(currentFileProperties);
        } catch (IOException e) {
            if (initFinished) {
                SilverTrace.error("silvertrace", "SilverTrace.resetAll()",
                        "silvertrace.ERR_INIT_TRACE_FROM_PROP", "File:[" + theFile.getAbsolutePath() + "]", e);
            } else {
                emergencyTrace("Error in SilverTrace initialization : Cant load property file : '"
                        + theFile.getAbsolutePath() + "'", e);
            }
        } finally {
            IOUtils.closeQuietly(is);
        }
    }
}

From source file:edu.toronto.cs.phenotips.measurements.internal.DefaultMeasurementsChartConfigurationsFactory.java

/**
 * Read and return a setting from the configuration, parsing it as a positive {@code double} number, falling back on
 * the provided default value./*from  ww w.  j ava2 s . co m*/
 * 
 * @param settingName the name of the setting to read
 * @param defaultValue the default value to use when there's no value specified in the configuration, or the
 *            specified value is not a valid double number
 * @param configuration the configuration bundle with all the settings
 * @return the configured value, if one is configured as a valid {@code double} number, or the default value
 *         otherwise
 */
private double getPositiveDoubleSetting(String settingName, double defaultValue, ResourceBundle configuration) {
    double result = getDoubleSetting(settingName, defaultValue, configuration);
    if (result < 0) {
        this.logger.warn("Invalid chart settings for [{}]: value should be positive, was [{}]", settingName,
                configuration.getString(settingName));
        result = defaultValue;
    }
    return result;
}

From source file:es.pode.modificador.presentacion.configurar.objetos.resultados.ResultadosBuscarObjetoControllerImpl.java

/**
 * @see es.pode.modificador.presentacion.configurar.objetos.resultados.ResultadosBuscarObjetoController#selectAction(org.apache.struts.action.ActionMapping,
 *      es.pode.modificador.presentacion.configurar.objetos.resultados.SelectActionForm,
 *      javax.servlet.http.HttpServletRequest,
 *      javax.servlet.http.HttpServletResponse)
 *///from  ww w . java 2  s. co m
public final java.lang.String selectAction(ActionMapping mapping,
        es.pode.modificador.presentacion.configurar.objetos.resultados.SelectActionForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    java.util.Locale locale = (java.util.Locale) request.getSession()
            .getAttribute(ConstantesAgrega.DEFAULT_LOCALE);
    ResourceBundle i18n = ResourceBundle.getBundle("application-resources", locale);

    String cancelar = "Cancelar";
    String seleccionar = "Seleccionar";
    String volver = "Volver";
    String selecTodos = "SeleccionarTodos";

    String action = form.getAction();
    if (action == null) {
        return volver;
    }

    if (action.equals(i18n.getString("comun.cancelar")))
        return cancelar;
    else if (action.equals(seleccionar))
        return seleccionar;
    else if (action.equals(i18n.getString("comun.seleccionarTodos")))
        return selecTodos;
    else if (action.equals(i18n.getString("comun.volver")))
        return volver;

    return null;
}

From source file:com.exxeta.iss.sonar.esql.test.CheckListTest.java

/**
 * Enforces that each check has test, name and description.
 *//*from ww w. java 2 s .co m*/
@Test
public void test() {
    List<Class> checks = CheckList.getChecks();
    for (Class cls : checks) {
        String testName = '/' + cls.getName().replace('.', '/') + "Test.class";
        assertThat(getClass().getResource(testName))
                .overridingErrorMessage("No test for " + cls.getSimpleName()).isNotNull();
    }
    ResourceBundle resourceBundle = ResourceBundle.getBundle("org.sonar.l10n.esql", Locale.ENGLISH);
    Set<String> keys = Sets.newHashSet();
    ActiveRules activeRules = (new ActiveRulesBuilder()).build();
    CheckFactory checkFactory = new CheckFactory(activeRules);
    Collection<Rule> rules = checkFactory.<Rule>create("repositoryKey")
            .addAnnotatedChecks(CheckList.getChecks()).all();
    for (Rule rule : rules) {
        assertThat(keys).as("Duplicate key " + rule.getKey()).excludes(rule.getKey());
        keys.add(rule.getKey());
        resourceBundle.getString("rule." + CheckList.REPOSITORY_KEY + "." + rule.getKey() + ".name");
        assertThat(getClass().getResource("/org/sonar/l10n/esql/rules/esql/" + rule.getKey() + ".html"))
                .overridingErrorMessage("No description for " + rule.getKey()).isNotNull();
        assertThat(rule.getDescription())
                .overridingErrorMessage("Description of " + rule.getKey() + " should be in separate file")
                .isNull();
        for (RuleParam param : rule.getParams()) {
            resourceBundle.getString(
                    "rule." + CheckList.REPOSITORY_KEY + "." + rule.getKey() + ".param." + param.getKey());
            assertThat(param.getDescription()).overridingErrorMessage("Description for param " + param.getKey()
                    + " of " + rule.getKey() + " should be in separate file").isEmpty();
        }
    }
}

From source file:com.inkubator.hrm.web.recruitment.RecruitMppApplyFormController.java

public void handleFileUpload(FileUploadEvent fileUploadEvent) {
    Map<String, String> results = uploadFilesUtil.checkUploadFileSizeLimit(fileUploadEvent.getFile());
    if (StringUtils.equals(results.get("result"), "true")) {
        mppApplyFile = fileUploadEvent.getFile();
        recruitMppApplyModel.setRecruitMppApplyFileName(mppApplyFile.getFileName());

    } else {//from  www . j  av  a2s  .  c  om
        ResourceBundle messages = ResourceBundle.getBundle("Messages",
                new Locale(FacesUtil.getSessionAttribute(HRMConstant.BAHASA_ACTIVE).toString()));
        String errorMsg = messages.getString("global.file_size_should_not_bigger_than") + " "
                + results.get("sizeMax");
        MessagesResourceUtil.setMessagesFromException(FacesMessage.SEVERITY_ERROR, "global.error", errorMsg,
                FacesUtil.getSessionAttribute(HRMConstant.BAHASA_ACTIVE).toString());
    }
}

From source file:edu.ku.brc.af.core.expresssearch.ExpressResultsTableInfo.java

/**
 * Fill the current object with the info from the DOM depending on the LOAD_TYPE
 * @param tableElement the DOM4J element used to fill the object
 */// w  w  w. ja v  a 2 s . c om
public void fill(final Element tableElement, final ResourceBundle resBundle) {
    id = tableElement.attributeValue("id"); //$NON-NLS-1$
    tableId = tableElement.attributeValue("tableid"); //$NON-NLS-1$
    name = tableElement.attributeValue("name"); //$NON-NLS-1$
    color = UIHelper.parseRGB(tableElement.attributeValue("color")); //$NON-NLS-1$

    if (isExpressSearch) {
        title = resBundle.getString(name);
        if (StringUtils.isEmpty(title)) {
            log.error("Express Search with name[" + name //$NON-NLS-1$
                    + "] is missing it's title in the expressearch properties file."); //$NON-NLS-1$
        }
        description = resBundle.getString(name + "_desc"); //$NON-NLS-1$
        if (StringUtils.isEmpty(description)) {
            log.error("Express Search with name[" + name //$NON-NLS-1$
                    + "] is missing it's description in the expressearch properties file."); //$NON-NLS-1$
        }
    } else {
        DBTableInfo tblInfo = getTableInfo();
        if (tblInfo != null) {
            title = tblInfo.getTitle();
        }
    }

    if (StringUtils.isEmpty(title)) {
        title = getResourceString("ExpressResultsTableInfo.NOTITLE"); // XXX This should never happen! //$NON-NLS-1$
    }

    Element viewElement = (Element) tableElement.selectSingleNode("detailView"); //$NON-NLS-1$
    Element sqlElement = (Element) viewElement.selectSingleNode("sql"); //$NON-NLS-1$

    isFieldNameOnlyForSQL = getAttr(sqlElement, "fieldnameonly", false); //$NON-NLS-1$
    viewSql = StringUtils.strip(sqlElement.getText());
    iconName = viewElement.attributeValue("icon"); //$NON-NLS-1$

    List<?> captionItems = viewElement.selectNodes("captions/caption"); //$NON-NLS-1$
    if (captionItems.size() > 0) {
        int captionCount = captionItems.size();
        captionInfo = new Vector<ERTICaptionInfo>(captionCount);
        int i = 0;
        for (Iterator<?> capIter = captionItems.iterator(); capIter.hasNext();) {
            Element captionElement = (Element) capIter.next();
            ERTICaptionInfo capInfo = new ERTICaptionInfo(captionElement, resBundle);

            if (capInfo.isVisible()) {
                captionInfo.add(capInfo);
                capInfo.setPosIndex(i);
                if (capInfo.getColName() == null && capInfo.getColInfoList().size() > 0) {
                    i += capInfo.getColInfoList().size() - 1;
                }
            } else {
                capInfo.setPosIndex(-1);
            }
            i++;
        }

        if (captionInfo.size() != captionCount) {
            // Create mappings of visible items
            visibleCaptionInfo = new Vector<ERTICaptionInfo>(captionInfo.size());
            for (ERTICaptionInfo c : captionInfo) {
                visibleCaptionInfo.add(c);
            }
        }

    } else {
        throw new RuntimeException("No Captions!"); //$NON-NLS-1$
    }

    List<?> joinColItems = tableElement.selectNodes("joins/join"); //$NON-NLS-1$
    if (joinColItems != null && joinColItems.size() > 0) {
        joinCols = new ERTIJoinColInfo[joinColItems.size()];
        for (int i = 0; i < joinColItems.size(); i++) {
            joinCols[i] = new ERTIJoinColInfo((Element) joinColItems.get(i));
        }
    }
}