private boolean _loadResourceBundle() {
    String f_strMethod = "_loadResourceBundle()";

    /* MEMO: trim() not necessary
     */
    try {
      String strValue = null;

      // TEXTS
      strValue = _s_rbeResources.getString("text_this");
      setText(strValue);
      strValue = _s_rbeResources.getString("text_left");
      this._mimLeft.setText(strValue);
      strValue = _s_rbeResources.getString("text_center");
      this._mimCenter.setText(strValue);
      strValue = _s_rbeResources.getString("text_right");
      this._mimRight.setText(strValue);
    } catch (java.util.MissingResourceException excMissingResource) {
      excMissingResource.printStackTrace();
      MySystem.s_printOutError(
          this, f_strMethod, "excMissingResource caught," + _f_s_strBundleFileLong);
      return false;
    }

    return true;
  }
Example #2
0
  public static void main(final String[] args) {
    if (args.length >= 2) {
      final String localeSetting = args[0];
      System.out.println("Setting Locale to " + localeSetting + "\n");
      Locale.setDefault(new Locale(localeSetting));

      final String timezoneSetting = args[1];
      System.out.println("Setting TimeZone to " + timezoneSetting + "\n");
      TimeZone.setDefault(TimeZone.getTimeZone(timezoneSetting));
    }

    final Locale locale = Locale.getDefault();
    System.out.println("Locale");
    System.out.println("Code: " + locale.toString());
    try {
      System.out.println("Country: " + locale.getISO3Country());
    } catch (final MissingResourceException e) {
      System.out.println("Country: " + e.getMessage());
    }
    try {
      System.out.println("Language: " + locale.getISO3Language());
    } catch (final MissingResourceException e) {
      System.out.println("Language: " + e.getMessage());
    }

    System.out.println("\nTimezone");
    final TimeZone timezone = TimeZone.getDefault();
    System.out.println("Code: " + timezone.getID());
    System.out.println("Name: " + timezone.getDisplayName());
    System.out.println("Offset: " + timezone.getRawOffset() / (1000 * 60 * 60));
    System.out.println("DST: " + timezone.getDSTSavings() / (1000 * 60 * 60));
  }
Example #3
0
  /**
   * Loads the language for the GUI window.
   *
   * @throws IOException It can't be loaded the requested File
   */
  public ResourceBundle loadWindowLanguageStringsResource(String fileName, Locale displayLanguage)
      throws LanguageExecption {
    if (localeLang == null) {
      throw new LanguageExecption("It isn't set a display language (No Locale class is set).");
    }

    try {
      // Nur laden, wenn von einem anderen Fenster etwas geladen werden soll
      if (!fileName.equals(guiElement)) {
        languageResource =
            PropertyResourceBundle.getBundle(BUNDLE_BASENANE + fileName, displayLanguage);
      }
    } catch (MissingResourceException e2) {
      System.err.println("Cannot load the file with name: " + BUNDLE_BASENANE + fileName);
      e2.printStackTrace();
      throw new LanguageExecption(
          "(MissingResourceException) Cannot load the file with name: "
              + BUNDLE_BASENANE
              + fileName);
    } catch (NullPointerException e1) {
      System.err.println("The Inputstream is empty");
      e1.printStackTrace();
      throw new LanguageExecption("(NullPointerException) The Inputstream is empty");
    }
    return languageResource;
  }
 /**
  * The resource is a list of objects. Gets the value(s) of the specified property of one or more
  * objects in the list. The objects in the list are identified by their index in the list (from 1
  * to n). The key used to find the asked value(s) is composed first by the list identifier, an
  * underscore separator, then by the index of the object in the list, a dot separator, and finally
  * ends with the object's property name.<br>
  * For example : <code>
  *   <ul>
  *   <li>User_1.Name=firstName</li>
  *   <li>User_2.Name=lastName</li>
  *   <li>...</li>
  *   </ul>
  * </code> If the computed key isn't defined in the bundle, then no {@link
  * MissingResourceException} exception is thrown (for compatibility reason with Silverpeas
  * versions lesser than 6).
  *
  * @param list the identifier of the list in the bundle.
  * @param property the object's property for which the value will be fetch.
  * @param max the maximum number of objects to read from 1 to n. If max is -1 then the list is
  *     iterated up to find an object whose the property is set. If max is >= 1 then the specified
  *     property of the first max objects are read (if the property isn't set for an object, it is
  *     set to an empty string).
  * @return an array of string with one property value (if max is 1) or with several values (if max
  *     = -1 or > 1). If the property of an object to read exists but isn't set, then an empty
  *     string is set in the array.
  * @throws MissingResourceException if the bundle doesn't exist.
  */
 default SilverpeasBundleList getStringList(String list, String property, int max)
     throws MissingResourceException {
   int i = 1;
   SilverpeasBundleList finalList = SilverpeasBundleList.with();
   while ((i <= max) || (max == -1)) {
     try {
       String key = list + "_" + Integer.toString(i) + "." + property;
       String s = getString(key);
       if (s == null) {
         throw new MissingResourceException(getBaseBundleName(), getClass().getName(), key);
       }
       finalList.add(s);
     } catch (MissingResourceException ex) {
       if (ex.getKey() == null || ex.getKey().trim().isEmpty()) {
         throw ex;
       }
       if (max == -1) {
         max = i;
       } else {
         finalList.add("");
       }
     }
     i++;
   }
   return finalList;
 }
 static {
   try {
     resources = ResourceBundle.getBundle("org.apache.ws.security.conversation.errors");
   } catch (MissingResourceException e) {
     throw new RuntimeException(e.getMessage(), e);
   }
 }
Example #6
0
  private static String getMessageFromResourceBundle(String key, Locale locale) {
    ResourceBundle bundle;
    String message = "";

    if (locale == null) {
      locale = FacesContext.getCurrentInstance().getViewRoot().getLocale();
    }

    try {
      bundle = ResourceBundle.getBundle(BUNDLE_NAME, locale, getCurrentLoader(BUNDLE_NAME));
      if (bundle == null) {
        return NOT_FOUND;
      }
    } catch (MissingResourceException e) {
      LOGGER.log(Level.INFO, e.getMessage(), e);
      return NOT_FOUND;
    }

    try {
      message = bundle.getString(key);
    } catch (Exception e) {
      LOGGER.log(Level.INFO, e.getMessage(), e);
    }
    return message;
  }
Example #7
0
 public void setLocale(Locale locale) {
   this.locale = locale;
   getLogger().debug("Locale changed to " + locale);
   try {
     getPack(locale);
   } catch (MissingResourceException ex) {
     getLogger().error(ex.getMessage(), ex);
   }
 }
Example #8
0
 /** The constructor. */
 public ErlideUIPlugin() {
   super();
   plugin = this;
   try {
     resourceBundle = ResourceBundle.getBundle("org.erlide.ui.ErlideUIPluginResources");
   } catch (final MissingResourceException x) {
     x.printStackTrace();
     resourceBundle = null;
   }
 }
Example #9
0
 public ComparePlugin() {
   super();
   plugin = this;
   try {
     resourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE);
   } catch (MissingResourceException x) {
     resourceBundle = null;
     x.printStackTrace();
   }
 }
 public void contextInitialized(ServletContextEvent sce) {
   try {
     // ServletContext sc=sce.getServletContext();
     BatchTareaAutomathicExecuter bckAuto = new BatchTareaAutomathicExecuter();
     bckAuto.startAutomathicExecuter();
     log.debug("Bachero listener inicializado!!!");
   } catch (MissingResourceException mre) {
     System.err.println("Exception:" + mre.toString());
   }
 }
 public void TestBadLocaleError() {
   try {
     DurationFormat df = DurationFormat.getInstance(new ULocale("und"));
     df.format(new Date());
     logln("Should have thrown err.");
     errln("failed, should have thrown err.");
   } catch (MissingResourceException mre) {
     logln("PASS: caught missing resource exception on locale 'und'");
     logln(mre.toString());
   }
 }
 /**
  * Constructs a RuleBasedBreakIterator using the given rule data.
  *
  * @throws MissingResourceException if the rule data is invalid or corrupted
  */
 public RuleBasedBreakIterator(String ruleFile, byte[] ruleData) {
   ByteBuffer bb = ByteBuffer.wrap(ruleData);
   try {
     validateRuleData(ruleFile, bb);
     setupTables(ruleFile, bb);
   } catch (BufferUnderflowException bue) {
     MissingResourceException e;
     e = new MissingResourceException("Corrupted rule data file", ruleFile, "");
     e.initCause(bue);
     throw e;
   }
 }
Example #13
0
 /**
  * the key should start with %, we will remove the %, then try to get the NLS resource string
  * based on the key w/o %
  *
  * @param nlsKey - should start with %
  * @return - nls resource string
  */
 public static String getFormattingProfileNLSString(String nlsKey) {
   // remove the leading %
   if (nlsKey.startsWith(FormatProfileRootHelper.NLSKEY_LEADINGCHAR))
     nlsKey = nlsKey.substring(nlsKey.indexOf(FormatProfileRootHelper.NLSKEY_LEADINGCHAR) + 1);
   if (nlsKey.length() > 0) {
     try {
       return FormatProfileRootHelper.bundleForConstructedKeys.getString(nlsKey);
     } catch (MissingResourceException e) {
       e.printStackTrace();
       return nlsKey;
     }
   } else return nlsKey;
 }
  static {
    final String f_strWhere =
        "com.google.code.p.keytooliui.shared.swing.menu.METextAlignmentEditorText";

    try {
      _s_rbeResources =
          java.util.ResourceBundle.getBundle(
              _f_s_strBundleFileShort, java.util.Locale.getDefault());
    } catch (java.util.MissingResourceException excMissingResource) {
      excMissingResource.printStackTrace();
      MySystem.s_printOutExit(f_strWhere, _f_s_strBundleFileLong + "excMissingResource caught");
    }
  }
Example #15
0
  public static String tr(String input) {
    String text = input;
    try {
      text = resb.getString(input);

    } catch (java.util.MissingResourceException e) {
      e.printStackTrace();
      // appendProperties("c:/lang_zh_CN.properties",input,text);
      // writeProperties("c:/lang_zh_CN.properties",input,text);
    }
    // writeProperties("c:/lang_zh_CN.properties",input,text);
    return text;
  }
 /**
  * Return the value against the given key if found, else an empty String.
  *
  * @param bundle the bundle that the string is in.
  * @param key the key to get the value for.
  * @return String, the associated value.
  */
 public static String getString(int bundle, String key) {
   String value = "";
   try {
     switch (bundle) {
       case UI_GENERAL_BUNDLE:
         value = uiBundle.getString(key);
         break;
       case MENUS_BUNDLE:
         value = menusBundle.getString(key);
         break;
       case POPUPS_BUNDLE:
         value = popupsBundle.getString(key);
         break;
       case TOOLBARS_BUNDLE:
         value = toolbarsBundle.getString(key);
         break;
       case DIALOGS_BUNDLE:
         value = dialogsBundle.getString(key);
         break;
       case PANELS_BUNDLE:
         value = panelsBundle.getString(key);
         break;
       case TAGS_BUNDLE:
         value = tagsBundle.getString(key);
         break;
       case STENCILS_BUNDLE:
         value = stencilsBundle.getString(key);
         break;
       case EDITS_BUNDLE:
         value = editsBundle.getString(key);
         break;
       case LINKGROUPS_BUNDLE:
         value = linkgroupsBundle.getString(key);
         break;
       case MEETING_BUNDLE:
         value = meetingBundle.getString(key);
         break;
       case IO_BUNDLE:
         value = ioBundle.getString(key);
         break;
       case MOVIE_BUNDLE:
         value = movieBundle.getString(key);
         break;
     }
   } catch (MissingResourceException mre) {
     log.info(mre.getMessage());
     value = "UNKNOWN STRING";
   }
   return value;
 }
Example #17
0
  /**
   * @param propertiesFileName
   * @param key
   * @return a String containg the message for the key passed.
   */
  public static String fetchMessage(String propertiesFileName, String key) {
    String errorMessage = null;
    try {
      if (propertiesFileName != null && key != null) {
        errorMessage = fetchMessage(getResourceBundle(propertiesFileName), key);
      } else {
        errorMessage = "No key/properties file name has been passed";
      }
    } catch (java.util.MissingResourceException mre) {
      mre.printStackTrace();
    } /*catch(E){

      }*/
    return errorMessage;
  }
 protected String getText(String key, Locale locale, String defaultValue) {
   String result = null;
   ResourceBundle bundle = getBundle(locale);
   if (bundle != null) {
     try {
       result = bundle.getString(key);
     } catch (MissingResourceException e) {
       LOG.debug(e.getMessage());
     }
   }
   if (result == null) {
     result = defaultValue;
   }
   return result;
 }
  /**
   * Returns the current value for the data source.
   *
   * @param runtime the expression runtime that is used to evaluate formulas and expressions when
   *     computing the value of this filter.
   * @param element
   * @return the value.
   */
  public Object getValue(final ExpressionRuntime runtime, final ReportElement element) {
    if (runtime == null) {
      return null;
    }
    final String resourceId;
    if (resourceIdentifier != null) {
      resourceId = resourceIdentifier;
    } else {
      resourceId =
          runtime
              .getConfiguration()
              .getConfigProperty(ResourceBundleFactory.DEFAULT_RESOURCE_BUNDLE_CONFIG_KEY);
    }

    if (resourceId == null) {
      return null;
    }

    try {
      final ResourceBundleFactory resourceBundleFactory = runtime.getResourceBundleFactory();
      final ResourceBundle bundle = resourceBundleFactory.getResourceBundle(resourceId);

      // update the format string, if neccessary ...
      if (ObjectUtilities.equal(formatKey, appliedFormatKey) == false) {
        final String newFormatString = bundle.getString(formatKey);
        messageFormatSupport.setFormatString(newFormatString);
        appliedFormatKey = formatKey;
      }

      messageFormatSupport.setLocale(resourceBundleFactory.getLocale());
      return messageFormatSupport.performFormat(runtime.getDataRow());
    } catch (MissingResourceException mre) {
      if (logger.isDebugEnabled()) {
        logger.debug(
            "Failed to format the value for resource-id "
                + resourceId
                + ", was '"
                + mre.getMessage()
                + "'");
      }
      return null;
    } catch (Exception e) {
      if (logger.isDebugEnabled()) {
        logger.debug("Failed to format the value for resource-id " + resourceId, e);
      }
      return null;
    }
  }
Example #20
0
 private String tr(String key) {
   String übersetzt;
   try {
     übersetzt = dialogRB.getString(key);
   } catch (MissingResourceException e) {
     System.err.println(
         "Schluesselwort + "
             + key
             + " nicht gefunden fuer "
             + locale.toString()
             + " ; "
             + e.toString());
     return key;
   }
   return übersetzt;
 }
Example #21
0
  public void test_getISO3Language() {
    // Empty language code.
    assertEquals("", new Locale("", "US").getISO3Language());

    // Invalid language code.
    try {
      assertEquals("", new Locale("xx", "US").getISO3Language());
      fail();
    } catch (MissingResourceException expected) {
      assertEquals("FormatData_xx_US", expected.getClassName());
      assertEquals("ShortLanguage", expected.getKey());
    }

    // Valid language code.
    assertEquals("eng", new Locale("en", "").getISO3Language());
    assertEquals("eng", new Locale("en", "CA").getISO3Language());
    assertEquals("eng", new Locale("en", "XX").getISO3Language());
  }
Example #22
0
  public void test_getISO3Country() {
    // Empty country code.
    assertEquals("", new Locale("en", "").getISO3Country());

    // Invalid country code.
    try {
      assertEquals("", new Locale("en", "XX").getISO3Country());
      fail();
    } catch (MissingResourceException expected) {
      assertEquals("FormatData_en_XX", expected.getClassName());
      assertEquals("ShortCountry", expected.getKey());
    }

    // Valid country code.
    assertEquals("CAN", new Locale("", "CA").getISO3Country());
    assertEquals("CAN", new Locale("en", "CA").getISO3Country());
    assertEquals("CAN", new Locale("xx", "CA").getISO3Country());
  }
  /**
   * Carga un mensaje de error del archivo de recursos en el idioma especificiado.
   *
   * @param locale Código de localización con el idioma especificado.
   * @return El mensaje de error mencionado.
   */
  public String getExtendedMessage(Locale locale) {

    String msg = null;
    ResourceBundle resBundle;

    if (errorCode != 0) {
      try {
        resBundle = ResourceBundle.getBundle(getMessagesFile(), locale);
        msg = resBundle.getString(new Long(errorCode).toString());
      } catch (MissingResourceException mre) {
        msg = null;
        mre.printStackTrace(System.err);
      } catch (Exception exc) {
        msg = null;
        exc.printStackTrace(System.err);
      }
    }
    return msg;
  }
 /**
  * Return a MessageFormat for the given bundle basename, message code, and Locale.
  *
  * @param basename the basename of the bundle
  * @param code the message code to retrieve
  * @param locale the Locale to resolve for
  * @return the resulting MessageFormat
  */
 protected MessageFormat resolve(String basename, String code, Locale locale) {
   try {
     ResourceBundle bundle =
         ResourceBundle.getBundle(
             basename, locale, Thread.currentThread().getContextClassLoader());
     try {
       return getMessageFormat(bundle, code);
     } catch (MissingResourceException ex) {
       // assume key not found
       // -> do NOT throw the exception to allow for checking parent message source
       return null;
     }
   } catch (MissingResourceException ex) {
     logger.warn(
         "ResourceBundle [" + basename + "] not found for MessageSource: " + ex.getMessage());
     // assume bundle not found
     // -> do NOT throw the exception to allow for checking parent message source
     return null;
   }
 }
Example #25
0
 public ImageIcon getIcon(String key) throws MissingResourceException {
   String iconfile;
   try {
     iconfile = getString(key);
   } catch (MissingResourceException ex) {
     getLogger().debug(ex.getMessage()); // BJO
     throw ex;
   }
   try {
     ImageIcon icon = (ImageIcon) iconCache.get(iconfile);
     if (icon == null) {
       icon = new ImageIcon(loadResource(iconfile), key);
       iconCache.put(iconfile, icon);
     } // end of if ()
     return icon;
   } catch (Exception ex) {
     String message = "Icon " + iconfile + " can't be created: " + ex.getMessage();
     getLogger().error(message);
     throw new MissingResourceException(message, className, key);
   }
 }
Example #26
0
  public void init() throws ServletException {
    // Create the info object that can be used by the entire application.
    info = new Info();

    localInit(); // Typically descendent controller will override this method. Sets the application
                 // name.

    // create the Log4jLog object using the application name just set.
    setLog();

    // get the event values and save them into events
    ResourceBundle bundle = null;
    try {
      bundle = ResourceBundle.getBundle(APPLICATION_NAME);
    } catch (java.util.MissingResourceException mre) {
      log.fatal("Can't get actions from properties file: " + mre.getMessage());
      throw new ServletException("Can't get actions from properties file. Can't start servlet. ");
    }

    Enumeration e = bundle.getKeys();
    log.info("init. Loading events...");
    while (e.hasMoreElements()) {
      String key = (String) e.nextElement();
      String value = bundle.getString(key);

      log.info(key + "=" + value);
      try {
        HandlerBase event = (HandlerBase) Class.forName(value).newInstance();
        if (!events.containsValue(event)) events.put(key, event);
      } catch (Exception exc) {
        log.fatal(":event:" + key + "  NO HANDLER FOUND! " + value);
      }
    }

    // Load URLS into static class for all to access
    // TODO - This may not be right. One instance for the entire JVM!
    DispatchUrls U = DispatchUrls.getInstance();
    U.load(APPLICATION_NAME + "-Urls");
  }
 /**
  * Return a ResourceBundle for the given basename and code, fetching already generated
  * MessageFormats from the cache.
  *
  * @param basename the basename of the ResourceBundle
  * @param locale the Locale to find the ResourceBundle for
  * @return the resulting ResourceBundle, or {@code null} if none found for the given basename and
  *     Locale
  */
 protected ResourceBundle getResourceBundle(String basename, Locale locale) {
   if (getCacheMillis() >= 0) {
     // Fresh ResourceBundle.getBundle call in order to let ResourceBundle
     // do its native caching, at the expense of more extensive lookup steps.
     return doGetBundle(basename, locale);
   } else {
     // Cache forever: prefer locale cache over repeated getBundle calls.
     synchronized (this.cachedResourceBundles) {
       Map<Locale, ResourceBundle> localeMap = this.cachedResourceBundles.get(basename);
       if (localeMap != null) {
         ResourceBundle bundle = localeMap.get(locale);
         if (bundle != null) {
           return bundle;
         }
       }
       try {
         ResourceBundle bundle = doGetBundle(basename, locale);
         if (localeMap == null) {
           localeMap = new HashMap<>();
           this.cachedResourceBundles.put(basename, localeMap);
         }
         localeMap.put(locale, bundle);
         return bundle;
       } catch (MissingResourceException ex) {
         if (logger.isWarnEnabled()) {
           logger.warn(
               "ResourceBundle ["
                   + basename
                   + "] not found for MessageSource: "
                   + ex.getMessage());
         }
         // Assume bundle not found
         // -> do NOT throw the exception to allow for checking parent message source.
         return null;
       }
     }
   }
 }
Example #28
0
  /**
   * @param orgNode Processed node
   * @param propertyName which property used for editing
   * @param inputType input type for editing: TEXT, TEXTAREA, WYSIWYG
   * @param cssClass class name for CSS, should implement: cssClass, [cssClass]Title Edit[cssClass]
   *     as relative css Should create the function:
   *     InlineEditor.presentationRequestChange[cssClass] to request the rest-service
   * @param isGenericProperty set as true to use generic javascript function, other wise, must
   *     create the correctspond function InlineEditor.presentationRequestChange[cssClass]
   * @param arguments Extra parameter for Input component (toolbar, width, height,.. for
   *     CKEditor/TextArea)
   * @return String that can be put on groovy template
   * @throws Exception
   * @author vinh_nguyen
   */
  public static String getInlineEditingField(
      Node orgNode,
      String propertyName,
      String defaultValue,
      String inputType,
      String idGenerator,
      String cssClass,
      boolean isGenericProperty,
      String... arguments)
      throws Exception {
    HashMap<String, String> parsedArguments = parseArguments(arguments);
    String height = parsedArguments.get(HEIGHT);
    String bDirection = parsedArguments.get(BUTTON_DIR);
    String publishLink = parsedArguments.get(FAST_PUBLISH_LINK);

    Locale locale = WebuiRequestContext.getCurrentInstance().getLocale();
    String language = locale.getLanguage();
    ResourceBundleService resourceBundleService =
        WCMCoreUtils.getService(ResourceBundleService.class);
    ResourceBundle resourceBundle;
    resourceBundle = resourceBundleService.getResourceBundle(LOCALE_WEBUI_DMS, locale);

    PortletRequestContext portletRequestContext = WebuiRequestContext.getCurrentInstance();
    String draft = INLINE_DRAFT;
    String published = INLINE_PUBLISHED;
    try {
      draft =
          portletRequestContext.getApplicationResourceBundle().getString("PublicationStates.draft");
      published =
          portletRequestContext
              .getApplicationResourceBundle()
              .getString("PublicationStates.published");
    } catch (MissingResourceException ex) {
      if (LOG.isWarnEnabled()) {
        LOG.warn(ex.getMessage());
      }
    }

    String portletRealID =
        org.exoplatform.wcm.webui.Utils.getRealPortletId(
            (PortletRequestContext) WebuiRequestContext.getCurrentInstance());
    StringBuffer sb = new StringBuffer();
    StringBuffer actionsb = new StringBuffer();
    String repo =
        ((ManageableRepository) orgNode.getSession().getRepository()).getConfiguration().getName();
    String workspace = orgNode.getSession().getWorkspace().getName();
    String uuid = orgNode.getUUID();
    String strSuggestion = "";
    String acceptButton = "";
    String cancelButton = "";
    portletRealID = portletRealID.replace('-', '_');
    String showBlockId = "Current" + idGenerator + "_" + portletRealID;
    String editBlockEditorID = "Edit" + idGenerator + "_" + portletRealID;
    String editFormID = "Edit" + idGenerator + "Form_" + portletRealID;
    String newValueInputId = "new" + idGenerator + "_" + portletRealID;
    String currentValueID = "old" + idGenerator + "_" + portletRealID;
    String siteName =
        org.exoplatform.portal.webui.util.Util.getPortalRequestContext().getPortalOwner();
    String currentValue = StringUtils.replace(defaultValue, "{portalName}", siteName);
    try {
      strSuggestion = resourceBundle.getString("UIPresentation.label.EditingSuggestion");
      acceptButton = resourceBundle.getString("UIPresentation.title.AcceptButton");
      cancelButton = resourceBundle.getString("UIPresentation.title.CancelButton");
    } catch (MissingResourceException e) {
      if (LOG.isWarnEnabled()) {
        LOG.warn(e.getMessage());
      }
    }
    actionsb.append(" return InlineEditor.presentationRequestChange");

    if (isGenericProperty) {
      actionsb
          .append("Property")
          .append("('")
          .append("/property?', '")
          .append(propertyName)
          .append("', '");
    } else {
      actionsb.append(cssClass).append("('");
    }
    actionsb
        .append(currentValueID)
        .append("', '")
        .append(newValueInputId)
        .append("', '")
        .append(repo)
        .append("', '")
        .append(workspace)
        .append("', '")
        .append(uuid)
        .append("', '")
        .append(editBlockEditorID)
        .append("', '")
        .append(showBlockId)
        .append("', '")
        .append(siteName)
        .append("', '")
        .append(language);

    if (inputType.equals(INPUT_WYSIWYG)) {
      actionsb.append("', 1);");
    } else {
      actionsb.append("');");
    }
    String strAction = actionsb.toString();

    if (orgNode.hasProperty(propertyName)) {
      try {
        if (propertyName.equals(EXO_TITLE))
          return ContentReader.getXSSCompatibilityContent(
              orgNode.getProperty(propertyName).getString());
        if (org.exoplatform.wcm.webui.Utils.getCurrentMode().equals(WCMComposer.MODE_LIVE))
          return StringUtils.replace(
              orgNode.getProperty(propertyName).getString(), "{portalName}", siteName);
        else
          return "<div class=\"WCMInlineEditable\" contenteditable=\"true\" propertyName=\""
              + propertyName
              + "\" repo=\""
              + repo
              + "\" workspace=\""
              + workspace
              + "\""
              + " uuid=\""
              + uuid
              + "\" siteName=\""
              + siteName
              + "\" publishedMsg=\""
              + published
              + "\" draftMsg=\""
              + draft
              + "\" fastpublishlink=\""
              + publishLink
              + "\" language=\""
              + language
              + "\" >"
              + orgNode.getProperty(propertyName).getString()
              + "</div>";
      } catch (Exception e) {
        if (org.exoplatform.wcm.webui.Utils.getCurrentMode().equals(WCMComposer.MODE_LIVE))
          return currentValue;
        else
          return "<div class=\"WCMInlineEditable\" contenteditable=\"true\" propertyName=\""
              + propertyName
              + "\" repo=\""
              + repo
              + "\" workspace=\""
              + workspace
              + "\" "
              + "uuid=\""
              + uuid
              + "\" siteName=\""
              + siteName
              + "\" publishedMsg=\""
              + published
              + "\" draftMsg=\""
              + draft
              + "\" fastpublishlink=\""
              + publishLink
              + "\" language=\""
              + language
              + "\" >"
              + defaultValue
              + "</div>";
      }
    }

    sb.append("<div class=\"InlineEditing\" >\n");
    sb.append("\n<div rel=\"tooltip\" data-placement=\"bottom\" id=\"")
        .append(showBlockId)
        .append("\" Class=\"")
        .append(cssClass)
        .append("\"");
    sb.append("title=\"").append(strSuggestion).append("\"");
    sb.append(" onClick=\"InlineEditor.presentationSwitchBlock('")
        .append(showBlockId)
        .append("', '")
        .append(editBlockEditorID)
        .append("');\"");

    sb.append("onmouseout=\"this.className='")
        .append(cssClass)
        .append("';\" onblur=\"this.className='")
        .append(cssClass)
        .append("';\" onfocus=\"this.className='")
        .append(cssClass)
        .append("Hover")
        .append("';\" onmouseover=\"this.className='")
        .append(cssClass)
        .append("Hover';\">")
        .append(currentValue)
        .append("</div>\n");
    sb.append("\t<div id=\"")
        .append(editBlockEditorID)
        .append("\" class=\"Edit")
        .append(cssClass)
        .append("\">\n");
    sb.append("\t\t<form name=\"")
        .append(editFormID)
        .append("\" id=\"")
        .append(editFormID)
        .append("\" onSubmit=\"")
        .append(strAction)
        .append("\">\n");
    sb.append("<DIV style=\"display:none; visible:hidden\" id=\"")
        .append(currentValueID)
        .append("\" name=\"")
        .append(currentValueID)
        .append("\">")
        .append(currentValue)
        .append("</DIV>");

    if (bDirection != null && bDirection.equals(LEFT2RIGHT)) {
      sb.append("\t\t<a href=\"#\" rel=\"tooltip\" data-placement=\"bottom\"")
          .append(" class =\"AcceptButton\" style=\"float:left\" onclick=\"")
          .append(strAction)
          .append("\" title=\"" + acceptButton + "\">&nbsp;</a>\n");
      sb.append(
              "\t\t<a href=\"#\" rel=\"tooltip\" data-placement=\"bottom\" class =\"CancelButton\" style=\"float:left\" ")
          .append("onClick=\"InlineEditor.presentationSwitchBlock('");
      sb.append(editBlockEditorID)
          .append("', '")
          .append(showBlockId)
          .append("');\" title=\"" + cancelButton + "\">&nbsp;</a>\n");
    } else {
      sb.append(
              "\t\t<a href=\"#\" rel=\"tooltip\" data-placement=\"bottom\" class =\"CancelButton\" ")
          .append("onClick=\"InlineEditor.presentationSwitchBlock('");
      sb.append(editBlockEditorID)
          .append("', '")
          .append(showBlockId)
          .append("');\" title=\"" + cancelButton + "\">&nbsp;</a>\n");
      sb.append(
              "\t\t<a href=\"#\" rel=\"tooltip\" data-placement=\"bottom\" class =\"AcceptButton\" onclick=\"")
          .append(strAction)
          .append("\" title=\"" + acceptButton + "\">&nbsp;</a>\n");
    }
    sb.append("\t\t<div class=\"Edit").append(cssClass).append("Input\">\n ");

    sb.append("\n\t\t</div>\n\t</form>\n</div>\n\n</div>");
    return sb.toString();
  }
    public void execute(Event<UIForgetPassword> event) throws Exception {
      UIForgetPassword uiForm = event.getSource();
      UILogin uilogin = uiForm.getParent();
      WebuiRequestContext requestContext = event.getRequestContext();
      PortalRequestContext portalContext = PortalRequestContext.getCurrentInstance();
      String url = portalContext.getRequest().getRequestURL().toString();
      MailService mailSrc = uiForm.getApplicationComponent(MailService.class);
      OrganizationService orgSrc = uiForm.getApplicationComponent(OrganizationService.class);
      String userName = uiForm.getUIStringInput(Username).getValue();
      String email = uiForm.getUIStringInput(Email).getValue();
      uiForm.reset();

      User user = null;

      String tokenId = null;

      // User provided his username
      if (userName != null) {
        user = orgSrc.getUserHandler().findUserByName(userName);
        if (user == null) {
          requestContext
              .getUIApplication()
              .addMessage(new ApplicationMessage("UIForgetPassword.msg.user-not-exist", null));
          return;
        }
      }

      // User provided his email address
      if (user == null && email != null) {
        Query query = new Query();
        // Querying on email won't work. PLIDM-12
        // Note that querying on email is inefficient as it loops over all users...
        query.setEmail(email);
        PageList<User> users = orgSrc.getUserHandler().findUsers(query);
        if (users.getAll().size() > 0) {
          user = users.getAll().get(0);
        } else {
          requestContext
              .getUIApplication()
              .addMessage(new ApplicationMessage("UIForgetPassword.msg.email-not-exist", null));
          return;
        }
      }

      email = user.getEmail();

      // Create token
      RemindPasswordTokenService tokenService =
          uiForm.getApplicationComponent(RemindPasswordTokenService.class);
      Credentials credentials = new Credentials(user.getUserName(), "");
      tokenId = tokenService.createToken(credentials);

      String portalName = URLEncoder.encode(Util.getUIPortal().getName(), "UTF-8");

      ResourceBundle res = requestContext.getApplicationResourceBundle();
      String headerMail = "headermail";
      String footerMail = "footer";
      try {
        headerMail =
            res.getString(uiForm.getId() + ".mail.header")
                + "\n\n"
                + res.getString(uiForm.getId() + ".mail.user")
                + user.getUserName()
                + "\n"
                + res.getString(uiForm.getId() + ".mail.link");
        footerMail = "\n\n\n" + res.getString(uiForm.getId() + ".mail.footer");
      } catch (MissingResourceException e) {
        e.printStackTrace();
      }
      String host = url.substring(0, url.indexOf(requestContext.getRequestContextPath()));
      String activeLink =
          host
              + requestContext.getRequestContextPath()
              + "/public/"
              + portalName
              + "?portal:componentId=UIPortal&portal:action=RecoveryPasswordAndUsername&tokenId="
              + tokenId;
      String mailText = headerMail + "\n" + activeLink + footerMail;
      try {
        mailSrc.sendMessage(
            res.getString("UIForgetPassword.mail.from"),
            email,
            res.getString("UIForgetPassword.mail.subject"),
            mailText);
      } catch (Exception e) {
        requestContext
            .getUIApplication()
            .addMessage(new ApplicationMessage("UIForgetPassword.msg.send-mail-fail", null));
        requestContext.addUIComponentToUpdateByAjax(uilogin);

        return;
      }

      uilogin.getChild(UILoginForm.class).setRendered(true);
      uilogin.getChild(UIForgetPasswordWizard.class).setRendered(false);
      uilogin.getChild(UIForgetPassword.class).setRendered(false);
      requestContext
          .getUIApplication()
          .addMessage(new ApplicationMessage("UIForgetPassword.msg.send-mail-success", null));
      requestContext.addUIComponentToUpdateByAjax(uilogin);
    }
Example #30
0
  // ------------------------------------------------------------------------
  TextViewer(JFrame inParentFrame) {
    // super(true); //is double buffered - only for panels

    textViewerFrame = this;
    parentFrame = inParentFrame;
    lastViewedDirStr = "";
    lastViewedFileStr = "";

    setTitle(resources.getString("Title"));
    addWindowListener(new AppCloser());
    pack();
    setSize(500, 600);

    warningPopup = new WarningDialog(this);
    okCancelPopup = new WarningDialogOkCancel(this);
    messagePopup = new MessageDialog(this);
    okCancelMessagePopup = new MessageDialogOkCancel(this);

    // Force SwingSet to come up in the Cross Platform L&F
    try {
      UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
      // If you want the System L&F instead, comment out the above line and
      // uncomment the following:
      // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception exc) {
      String errstr = "TextViewer:Error loading L&F: " + exc;
      warningPopup.display(errstr);
    }

    Container cf = getContentPane();
    cf.setBackground(Color.lightGray);
    // Border etched=BorderFactory.createEtchedBorder();
    // Border title=BorderFactory.createTitledBorder(etched,"TextViewer");
    // cf.setBorder(title);
    cf.setLayout(new BorderLayout());

    // create the embedded JTextComponent
    editor1 = createEditor();
    editor1.setFont(new Font("monospaced", Font.PLAIN, 12));
    // aa -added next line
    setPlainDocument((PlainDocument) editor1.getDocument()); // sets doc1

    // install the command table
    commands = new Hashtable();
    Action[] actions = getActions();
    for (int i = 0; i < actions.length; i++) {
      Action a = actions[i];
      commands.put(a.getValue(Action.NAME), a);
      // System.out.println("Debug:TextViewer: actionName:"+a.getValue(Action.NAME));
    }
    // editor1.setPreferredSize(new Dimension(,));
    // get setting from user preferences
    if (UserPref.keymapType.equals("Word")) {
      editor1 = updateKeymapForWord(editor1);
    } else {
      editor1 = updateKeymapForEmacs(editor1);
    }

    scroller1 = new JScrollPane();
    viewport1 = scroller1.getViewport();
    viewport1.add(editor1);
    scroller1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scroller1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

    try {
      String vpFlag = resources.getString("ViewportBackingStore");
      Boolean bs = new Boolean(vpFlag);
      viewport1.setBackingStoreEnabled(bs.booleanValue());
    } catch (MissingResourceException mre) {
      System.err.println("TextViewer:missing resource:" + mre.getMessage());
      // just use the viewport1 default
    }

    menuItems = new Hashtable();

    menubar = createMenubar();

    lowerPanel = new JPanel(true); // moved double buffering to here
    lowerPanel.setLayout(new BorderLayout());
    lowerPanel.add("North", createToolbar());
    lowerPanel.add("Center", scroller1);

    cf.add("North", menubar);
    cf.add("Center", lowerPanel);
    cf.add("South", createStatusbar());

    // for the find/search utilities
    mySearchDialog = new SearchDialog(this);

    // System.out.println("Debug:TextViewer: end of TextViewer constructor");

  }