Example #1
0
 protected void readConfig(Configuration config) {
   listenersEnabled = false;
   try {
     useSsl.setSelected(config.getChild("ssl").getValueAsBoolean(false));
     mailServer.setValue(config.getChild("smtp-host").getValue("localhost"));
     smtpPortField.setNumber(new Integer(config.getChild("smtp-port").getValueAsInteger(25)));
     username.setText(config.getChild("username").getValue(""));
     password.setText(config.getChild("password").getValue(""));
   } finally {
     listenersEnabled = true;
   }
 }
Example #2
0
  /**
   * @throws RaplaException when the resource-file is missing or can't be accessed or can't be
   *     parsed
   */
  public I18nBundleImpl(RaplaContext context, Configuration config, Logger logger)
      throws RaplaException {
    enableLogging(logger);
    Locale locale;
    try {
      m_localeSelector = (LocaleSelectorImpl) context.lookup(LocaleSelector.class);
    } catch (RaplaContextException ex) {
    }
    if (m_localeSelector != null) {
      m_localeSelector.addLocaleChangeListenerFirst(this);
      locale = m_localeSelector.getLocale();

    } else {
      locale = Locale.getDefault();
    }
    String filePath = config.getChild("file").getValue(null);
    try {
      InputStream resource;
      if (filePath == null) {
        className = config.getChild("classname").getValue(null);
        if (className == null) {
          className = config.getAttribute("id");
        } else {
          className = className.trim();
        }
        String resourceFile = "" + className.replaceAll("\\.", "/") + ".xml";
        resource = getClass().getClassLoader().getResourceAsStream(resourceFile);
        dictionaryFile = resource != null ? resourceFile : null;
      } else {
        File file = new File(filePath);
        getLogger().info("getting lanaguageResources  from " + file.getCanonicalPath());
        resource = new FileInputStream(file);
        dictionaryFile = filePath;
      }
      if (resource != null) {
        dict = new TranslationParser().parse(resource);
        resource.close();
      } else {
        dict = new RaplaDictionary(locale.getLanguage());
      }
    } catch (Exception ex) {
      throw new RaplaException(ex);
    }
    setLocale(locale);
    try {
      parentId = getPack(locale).getString(TranslationParser.PARENT_BUNDLE_IDENTIFIER);
    } catch (MissingResourceException ex) {
    }
  }