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:dpfmanager.shell.modules.messages.MessagesModule.java

private void askForCloseConformances() {
    ResourceBundle bundle = DPFManagerProperties.getBundle();
    Platform.runLater(new Runnable() {
        @Override/*from  w ww. jav a2  s  .com*/
        public void run() {
            Alert alert = AlertsManager.createAskAlert(bundle.getString("askAlertConformances"),
                    bundle.getString("askAlertConformancesContent"));
            Optional<ButtonType> result = alert.showAndWait();
            if (result.get().getButtonData().equals(ButtonBar.ButtonData.YES)) {
                closeNow();
            }
        }
    });
}

From source file:dpfmanager.shell.modules.messages.MessagesModule.java

private void askForCloseThreading() {
    ResourceBundle bundle = DPFManagerProperties.getBundle();
    Platform.runLater(new Runnable() {
        @Override//from w w  w.j a v  a  2s . com
        public void run() {
            Alert alert = AlertsManager.createAskAlert(bundle.getString("askAlertRunning"),
                    bundle.getString("askAlertQuestion"));
            Optional<ButtonType> result = alert.showAndWait();
            if (result.get().getButtonData().equals(ButtonBar.ButtonData.YES)) {
                context.send(GuiConfig.PERSPECTIVE_PERIODICAL + "." + GuiConfig.COMPONENT_PERIODICAL,
                        new CloseMessage(CloseMessage.Type.PERIODICAL));
            }
        }
    });
}

From source file:JAXRQuery.java

/**
     * Establishes a connection to a registry.
     */*ww w .j  av  a2s . com*/
     * @param queryUrl        the URL of the query registry
     * @param publishUrl        the URL of the publish registry
     */
    public void makeConnection(String queryUrl, String publishUrl) {
        /*
         * Specify proxy information in case you
         *  are going beyond your firewall.
         */
        ResourceBundle registryBundle = ResourceBundle.getBundle("JAXRExamples");
        String httpProxyHost = registryBundle.getString("http.proxyHost");
        String httpProxyPort = registryBundle.getString("http.proxyPort");

        /*
         * Define connection configuration properties.
         * For simple queries, you need the query URL.
         */
        Properties props = new Properties();
        props.setProperty("javax.xml.registry.queryManagerURL", queryUrl);
        props.setProperty("com.sun.xml.registry.http.proxyHost", httpProxyHost);
        props.setProperty("com.sun.xml.registry.http.proxyPort", httpProxyPort);

        try {
            // Create the connection, passing it the 
            // configuration properties
            ConnectionFactory factory = ConnectionFactory.newInstance();
            factory.setProperties(props);
            connection = factory.createConnection();
            System.out.println("Created connection to registry");
        } catch (Exception e) {
            e.printStackTrace();

            if (connection != null) {
                try {
                    connection.close();
                } catch (JAXRException je) {
                }
            }
        }
    }

From source file:Unicode.java

/** Convenience routine to make a Menu */
public Menu mkMenu(ResourceBundle b, String name) {
    String menuLabel;/*w w  w.j  a va 2 s  .  co m*/
    try {
        menuLabel = b.getString(name + ".label");
    } catch (MissingResourceException e) {
        menuLabel = name;
    }
    return new Menu(menuLabel);
}

From source file:net.sf.yal10n.analyzer.ExploratoryEncodingTest.java

/**
 * Test to load a resource bundle from a BOM encoded file that starts with a comment.
 * @throws Exception any error//www . jav  a 2 s  .  co m
 */
@Test
public void testResourceBundleWithBOMandComment() throws Exception {
    ResourceBundle bundle = PropertyResourceBundle.getBundle("UTF8BOMwithComment", Locale.ROOT);
    Assert.assertEquals(4, bundle.keySet().size());

    Assert.assertEquals("", bundle.getString("\u00ef\u00bb\u00bf#abc"));
    Assert.assertEquals("first key", bundle.getString("testkey1"));
    Assert.assertEquals("second key", bundle.getString("testkey2"));
    // note: utf-8 read as iso-8859-1
    Assert.assertEquals("This file is encoded as UTF-8 with BOM \u00c3\u00a4.",
            bundle.getString("description"));
}

From source file:com.stratelia.webactiv.kmelia.FileImport.java

/**
 * Write import report into a log file//from  w  ww  .  ja va  2s  . com
 *
 */
public void writeImportToLog(ImportReport importReport, ResourcesWrapper resource) {
    if (importReport != null) {
        String reportLogFile = settings.getString("importExportLogFile");
        ResourceBundle resources = FileUtil
                .loadBundle("com.stratelia.silverpeas.silvertrace.settings.silverTrace", new Locale("", ""));
        String reportLogPath = resources.getString("ErrorDir");
        File file = new File(reportLogPath + separator + reportLogFile);
        Writer fileWriter = null;
        try {
            if (!file.exists()) {
                file.createNewFile();
            }
            fileWriter = new OutputStreamWriter(new FileOutputStream(file.getPath(), true), UTF_8);
            fileWriter.write(importReport.writeToLog(resource));
        } catch (IOException ex) {
            SilverTrace.error("kmelia", "FileImport.writeImportToLog()", "root.EX_CANT_WRITE_FILE", ex);
        } finally {
            IOUtils.closeQuietly(fileWriter);
        }
    }
}

From source file:es.pode.empaquetador.presentacion.avanzado.recursos.crear.tipo.CrearRecursoAvanzadoTipoControllerImpl.java

public final java.lang.String selectAction(ActionMapping mapping,
        es.pode.empaquetador.presentacion.avanzado.recursos.crear.tipo.SelectActionForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    /*//from   ww  w.  j ava  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}");
    }
    // Cancelar
    else if (actionSubmit.equals(i18n.getString("portalempaquetado.avanzado.recursos.crear.paso1.cancelar"))) {
        result = "Cancelar";
    }
    // Aceptar
    else if (actionSubmit.equals(i18n.getString("portalempaquetado.avanzado.recursos.crear.paso1.continuar"))) {
        result = "Continuar";
    }
    // Aceptar
    else if (actionSubmit
            .equals(i18n.getString("portalempaquetado.avanzado.recursos.crear.paso1.anadirmetadatos"))) {
        result = "Metadato";
    } else {
        Logger.getLogger(this.getClass())
                .error("El valor del submit no es correcto (actionSubmit = " + actionSubmit + ";");
    }
    return result;
}

From source file:JAXRQueryByNAICSClassification.java

/**
     * Establishes a connection to a registry.
     *//from w  ww.  j a  va  2 s  .  co  m
     * @param queryUrl        the URL of the query registry
     * @param publishUrl        the URL of the publish registry
     */
    public void makeConnection(String queryUrl, String publishUrl) {
        /*
         * Specify proxy information in case you
         *  are going beyond your firewall.
         */
        ResourceBundle bundle = ResourceBundle.getBundle("JAXRExamples");
        String httpProxyHost = bundle.getString("http.proxyHost");
        String httpProxyPort = bundle.getString("http.proxyPort");
        String httpsProxyHost = bundle.getString("https.proxyHost");
        String httpsProxyPort = bundle.getString("https.proxyPort");

        /*
         * Define connection configuration properties.
         * For simple queries, you need the query URL.
         * To use a life cycle manager, you need the publish URL.
         */
        Properties props = new Properties();
        props.setProperty("javax.xml.registry.queryManagerURL", queryUrl);
        props.setProperty("javax.xml.registry.lifeCycleManagerURL", publishUrl);

        props.setProperty("com.sun.xml.registry.http.proxyHost", httpProxyHost);
        props.setProperty("com.sun.xml.registry.http.proxyPort", httpProxyPort);
        props.setProperty("com.sun.xml.registry.https.proxyHost", httpsProxyHost);
        props.setProperty("com.sun.xml.registry.https.proxyPort", httpsProxyPort);

        try {
            // Create the connection, passing it the 
            // configuration properties
            ConnectionFactory factory = ConnectionFactory.newInstance();
            factory.setProperties(props);
            connection = factory.createConnection();
            System.out.println("Created connection to registry");
        } catch (Exception e) {
            e.printStackTrace();

            if (connection != null) {
                try {
                    connection.close();
                } catch (JAXRException je) {
                }
            }
        }
    }

From source file:JAXRQueryByWSDLClassification.java

/**
     * Establishes a connection to a registry.
     *// w w  w.  j a  v a 2  s .c o m
     * @param queryUrl        the URL of the query registry
     * @param publishUrl        the URL of the publish registry
     */
    public void makeConnection(String queryUrl, String publishUrl) {
        /*
         * Specify proxy information in case you
         *  are going beyond your firewall.
         */
        ResourceBundle bundle = ResourceBundle.getBundle("JAXRExamples");
        String httpProxyHost = bundle.getString("http.proxyHost");
        String httpProxyPort = bundle.getString("http.proxyPort");
        String httpsProxyHost = bundle.getString("https.proxyHost");
        String httpsProxyPort = bundle.getString("https.proxyPort");

        /*
         * Define connection configuration properties.
         * For simple queries, you need the query URL.
         * To use a life cycle manager, you need the publish URL.
         */
        Properties props = new Properties();
        props.setProperty("javax.xml.registry.queryManagerURL", queryUrl);
        props.setProperty("javax.xml.registry.lifeCycleManagerURL", publishUrl);
        props.setProperty("com.sun.xml.registry.http.proxyHost", httpProxyHost);
        props.setProperty("com.sun.xml.registry.http.proxyPort", httpProxyPort);
        props.setProperty("com.sun.xml.registry.https.proxyHost", httpsProxyHost);
        props.setProperty("com.sun.xml.registry.https.proxyPort", httpsProxyPort);

        try {
            // Create the connection, passing it the 
            // configuration properties
            ConnectionFactory factory = ConnectionFactory.newInstance();
            factory.setProperties(props);
            connection = factory.createConnection();
            System.out.println("Created connection to registry");
        } catch (Exception e) {
            e.printStackTrace();

            if (connection != null) {
                try {
                    connection.close();
                } catch (JAXRException je) {
                }
            }
        }
    }

From source file:es.pode.catalogadorWeb.presentacion.importar.ImportarControllerImpl.java

public String submit(ActionMapping mapping, SubmitForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    String resultado = "";
    String action = form.getAccion();

    //String idiomaLocale=((Locale)request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE)).getLanguage();
    ResourceBundle i18n = I18n.getInstance().getResource("application-resources",
            (Locale) request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE));

    if (action != null) {
        if (action.equals(i18n.getString("catalogadorAvanzado.importar.aceptar"))) {
            resultado = "Aceptar";
            if (form.getFichero() == null || form.getFichero().getFileName().equals("")
                    || form.getFichero().getFileSize() == 0)
                throw new ValidatorException("{catalogadorAvanzado.importar.error.ficherovacio}");

            //crear el datahandler
            InternetHeaders ih = new InternetHeaders();
            MimeBodyPart mbp = null;/*from   w w w.java 2  s .  c  om*/
            DataSource source = null;
            DataHandler dh = null;
            try {
                FormFile ff = (FormFile) form.getFichero();
                mbp = new MimeBodyPart(ih, ff.getFileData());
                source = new MimePartDataSource(mbp);
                dh = new DataHandler(source);
            } catch (Exception e) {
                if (logger.isDebugEnabled()) {
                    logger.debug("error al crear el datahandler");
                }
                throw new ValidatorException("{catalogadorAvanzado.importar.error}");
            }

            //validar el fichero
            Boolean valido = new Boolean(false);
            try {
                valido = this.getSrvValidadorService().obtenerValidacionLomes(dh);
            } catch (Exception e) {
                if (logger.isDebugEnabled()) {
                    logger.debug("error al llamar al servicio de validacin");
                }
                throw new ValidatorException("{catalogadorAvanzado.importar.error.novalido}");
            }

            if (!valido.booleanValue())
                throw new ValidatorException("{catalogadorAvanzado.importar.error.novalido}");

            //agregar el datahandler a sesion
            this.getCatalogadorAvSession(request).setLomesImportado(dh);

        } else if (action.equals(i18n.getString("catalogadorAvanzado.importar.cancelar")))
            resultado = "Cancelar";
    }
    return resultado;
}