Package org.olat.core.util.prefs

Examples of org.olat.core.util.prefs.Preferences


   
    // expand pathes from last time
    Set<String> expandedPathes = null;
    if (treeID != null) {
      guiPrefsKey = GUI_PREFS_KEY_PREFIX + treeID;
      Preferences guiPrefs = ureq.getUserSession().getGuiPreferences();
      expandedPathes = (Set<String>) guiPrefs.get(TreeController.class, guiPrefsKey);
      mainVC.contextPut("presistPathes", Boolean.TRUE);
    } else {
      mainVC.contextPut("presistPathes", Boolean.FALSE);
    }
    if (expandedPathes == null) {
View Full Code Here


        String newValue = uriHelper.getParameter(PARAM_VALUE);
        TreeNodeModifiedEvent editedEvent = new TreeNodeModifiedEvent(node, newValue);
        fireEvent(ureq, editedEvent);

      } else if (event.getCommand().equals(CMD_EXPAND)) {
        Preferences guiPrefs = ureq.getUserSession().getGuiPreferences();
        String expandedPath = uriHelper.getParameter(PARAM_PATH);
        Set<String> oldPathes = (Set<String>) guiPrefs.get(TreeController.class, guiPrefsKey);
        if (oldPathes == null) oldPathes = new HashSet<String>();
        Set<String> newPathes = new HashSet();
        for (String oldPath : oldPathes) {
          // remove all parent pathes to reduce redundancy
          if (!expandedPath.startsWith(oldPath)) newPathes.add(oldPath);
        }
        // add newly expaned node
        newPathes.add(expandedPath);
        guiPrefs.putAndSave(TreeController.class, guiPrefsKey, newPathes);
        // return empty resource
        ureq.getDispatchResult().setResultingMediaResource(okMediaResource);
       
      } else if (event.getCommand().equals(CMD_COLLAPSE)) {
        Preferences guiPrefs = ureq.getUserSession().getGuiPreferences();
        String collapsedPath = uriHelper.getParameter(PARAM_PATH);
        Set<String> oldPathes = (Set<String>) guiPrefs.get(TreeController.class, guiPrefsKey);
        if (oldPathes == null) oldPathes = new HashSet<String>();
        Set<String> newPathes = new HashSet();
        for (String oldPath : oldPathes) {
          // remove all child pathes
          if (!oldPath.startsWith(collapsedPath)) newPathes.add(oldPath);
        }
        guiPrefs.putAndSave(TreeController.class, guiPrefsKey, newPathes);
        // return empty resource
        ureq.getDispatchResult().setResultingMediaResource(okMediaResource);

      } else if (event.getCommand().equals(CMD_PING)) {
        // Nothing special to do. If any component is dirty, the framework has
View Full Code Here

    // Inline translation interceptor. when the translation tool is enabled it
    // will start the translation tool in translation mode, if the overlay
    // feature is enabled it will start in customizing mode
    if (ureq.getUserSession().isAuthenticated() && ureq.getUserSession().getRoles().isOLATAdmin() && (I18nModule.isTransToolEnabled() || I18nModule.isOverlayEnabled())) {
      inlineTranslationC = wbo.createInlineTranslationDispatcherController(ureq, getWindowControl());
      Preferences guiPrefs = ureq.getUserSession().getGuiPreferences();
      Boolean isInlineTranslationEnabled = (Boolean) guiPrefs.get(I18nModule.class, I18nModule.GUI_PREFS_INLINE_TRANSLATION_ENABLED, Boolean.FALSE);
      I18nManager.getInstance().setMarkLocalizedStringsEnabled(ureq.getUserSession(), isInlineTranslationEnabled);     
      mainvc.put("inlineTranslation", inlineTranslationC.getInitialComponent());
    }   

    // debug info if debugging
View Full Code Here

   */
  @Override
  protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    FormUIFactory formFactory = FormUIFactory.getInstance();
    I18nManager i18nMgr = I18nManager.getInstance();
    Preferences guiPrefs = ureq.getUserSession().getGuiPreferences();
    this.flc.contextPut("referenceLanguageKey", referenceLocale.toString());
    this.flc.contextPut("referenceLanguage", i18nMgr.getLanguageTranslated(referenceLocale.toString(), false));
    // Add bundles and keys selection
    List<String> bundlesList = new ArrayList<String>();
    List<String> keysList = new ArrayList<String>();
    for (I18nItem item : i18nItems) {
      if (!bundlesList.contains(item.getBundleName())) {
        bundlesList.add(item.getBundleName());
      }
      if (currentItem.getBundleName().equals(item.getBundleName())) {
        keysList.add(item.getKey());
      }
    }
    String[] bundlesListArray = ArrayHelper.toArray(bundlesList);
    String[] keysListArray = ArrayHelper.toArray(keysList);
    bundlesSelection = formFactory.addDropdownSingleselect("bundlesSelection", this.flc, bundlesListArray, bundlesListArray, null);
    bundlesSelection.addActionListener(this, FormEvent.ONCHANGE);
    bundlesSelection.select(currentItem.getBundleName(), true);
    keysSelection = formFactory.addDropdownSingleselect("keysSelection", this.flc, keysListArray, keysListArray, null);
    keysSelection.addActionListener(this, FormEvent.ONCHANGE);
    keysSelection.select(currentItem.getKey(), true);
    // Add reference box
    referenceArea = formFactory.addTextAreaElement("referenceArea", "edit.referenceArea", -1, 1, -1, true, null, this.flc);
    referenceArea.setEnabled(false); // read only
    // Add compare box
    Boolean compareEnabledPrefs = (Boolean) guiPrefs.get(I18nModule.class, I18nModule.GUI_PREFS_COMPARE_LANG_ENABLED, Boolean.FALSE);
    compareArea = formFactory.addTextAreaElement("compareArea", "edit.compareArea", -1, 1, -1, true, null, this.flc);
    compareArea.setEnabled(false); // read only
    compareArea.setVisible(compareEnabledPrefs.booleanValue());
    compareSwitch = formFactory.addCheckboxesHorizontal("compareSwitch", null, this.flc, new String[] { KEYS_ENABLED },
        new String[] { KEYS_EMPTY }, null);//i18nLabel set to null -> disabled label
    compareSwitch.select(KEYS_ENABLED, compareEnabledPrefs.booleanValue());
    compareSwitch.addActionListener(listener, FormEvent.ONCLICK);
    formLayout.add(compareSwitch);
    this.flc.contextPut("compareSwitchEnabled", compareEnabledPrefs);
    // Add compare language selection
    Set<String> availableLangKeys = I18nModule.getAvailableLanguageKeys();
    String[] comparelangKeys = ArrayHelper.toArray(availableLangKeys);
    String[] compareLangValues = new String[comparelangKeys.length];
    for (int i = 0; i < comparelangKeys.length; i++) {
      String key = comparelangKeys[i];
      String explLang = i18nMgr.getLanguageInEnglish(key, customizingMode);
      String all = explLang;
      if (explLang != null && !explLang.equals(key)) all += " (" + key + ")";
      compareLangValues[i] = all;
    }
    ArrayHelper.sort(comparelangKeys, compareLangValues, false, true, false);
    // Build css classes for comparison languages
    String[] compareLangCssClasses = i18nMgr.createLanguageFlagsCssClasses(comparelangKeys, "b_with_small_icon_left");
    String comparePrefs = (String) guiPrefs.get(I18nModule.class, I18nModule.GUI_PREFS_PREFERRED_COMPARE_LANG, I18nModule
        .getDefaultLocale().toString());
    compareLocale = i18nMgr.getLocaleOrNull(comparePrefs);
    if (compareLocale == null) compareLocale = I18nModule.getDefaultLocale();
    compareLangSelection = formFactory.addDropdownSingleselect("compareLangSelection", this.flc, comparelangKeys, compareLangValues,
        compareLangCssClasses);
View Full Code Here

    this.flc.contextPut("hasPrevious", (currentItemPosition == 0 ? Boolean.FALSE : Boolean.TRUE));
    this.flc.contextPut("hasNext", (currentItemPosition + 1 == i18nItems.size() ? Boolean.FALSE : Boolean.TRUE));
  }

  private void updateCompareArea(UserRequest ureq) {
    Preferences guiPrefs = ureq.getUserSession().getGuiPreferences();
    if (compareSwitch.isSelected(0)) {
      I18nManager i18nMgr = I18nManager.getInstance();
      // Add target value
      String compareValue = i18nMgr.getLocalizedString(currentItem.getBundleName(), currentItem.getKey(), null, compareLocale, customizingMode, false,
          false, false, 0);
      compareArea.setValue(compareValue);
      // save settings as gui prefs
      guiPrefs.put(I18nModule.class, I18nModule.GUI_PREFS_PREFERRED_COMPARE_LANG, compareLocale.toString());
      guiPrefs.putAndSave(I18nModule.class, I18nModule.GUI_PREFS_COMPARE_LANG_ENABLED, Boolean.TRUE);
    } else {
      guiPrefs.putAndSave(I18nModule.class, I18nModule.GUI_PREFS_COMPARE_LANG_ENABLED, Boolean.FALSE);
    }
    // update GUI
    this.flc.contextPut("compareSwitchEnabled", Boolean.valueOf(compareSwitch.isSelected(0)));
    this.flc.contextPut("compareLanguageKey", compareLocale.toString());
  }
View Full Code Here

    }
    ArrayHelper.sort(referencelangKeys, referenceLangValues, false, true, false);
    // Build css classes for reference languages
    String[] referenceLangCssClasses = i18nMgr.createLanguageFlagsCssClasses(referencelangKeys, "b_with_small_icon_left");
    // Preset first of the reference locales
    Preferences guiPrefs = usess.getGuiPreferences();
    String referencePrefs = (String) guiPrefs.get(I18nModule.class, I18nModule.GUI_PREFS_PREFERRED_REFERENCE_LANG, referenceLangs.get(0));
    referenceLocale = i18nMgr.getLocaleOrNull(referencePrefs);
    referenceLangSelection = formFactory.addDropdownSingleselect("start.referenceLangSelection", formLayout, referencelangKeys,
        referenceLangValues, referenceLangCssClasses);
    referenceLangSelection.select(referenceLocale.toString(), true);
    this.flc.contextPut("referenceLangKey", referenceLocale.toString());
View Full Code Here

    } else if (source == referenceLangSelection) {
      String langKey = referenceLangSelection.getSelectedKey();
      referenceLocale = i18nMgr.getLocaleOrNull(langKey);
      // update in gui prefs
      Preferences guiPrefs = ureq.getUserSession().getGuiPreferences();
      guiPrefs.putAndSave(I18nModule.class, I18nModule.GUI_PREFS_PREFERRED_REFERENCE_LANG, referenceLocale.toString());
      // update GUI
      this.flc.contextPut("referenceLangKey", i18nMgr.getLocaleKey(referenceLocale));
      // Set target language to reference language when in customizing mode
      if (customizingMode) {
        targetLocale = I18nModule.getOverlayLocales().get(referenceLocale)
View Full Code Here

    // Add link to flush the cache
    if (I18nManager.getInstance().isCachingEnabled()) {
      cacheFlushLink = LinkFactory.createButton("cache.flush", translationToolLauncherVC, this);
    }
    // Add inline translation status and link
    Preferences guiPrefs = ureq.getUserSession().getGuiPreferences();
    updateInlineTranslationStatusAndLink(guiPrefs);
    putInitialPanel(translationToolLauncherVC);
    // Enable or disable entire translation tool
    boolean isTranslationToolEnabled = I18nModule.isTransToolEnabled();
    translationToolLauncherVC.contextPut("transToolEnabled", Boolean.valueOf(isTranslationToolEnabled));
View Full Code Here

   *
   * @param ureq
   * @param enable
   */
  private void setNewInlineStatus(UserRequest ureq, boolean enable) {
    Preferences guiPrefs = ureq.getUserSession().getGuiPreferences();
    guiPrefs.putAndSave(I18nModule.class, I18nModule.GUI_PREFS_INLINE_TRANSLATION_ENABLED, Boolean.valueOf(enable));
    updateInlineTranslationStatusAndLink(guiPrefs);
  }
View Full Code Here

      if (isLogDebugEnabled()) {
        logDebug("Got event to launch inline translation tool for bundle::" + bundle + " and key::" + key, null);
      }
      if (StringHelper.containsNonWhitespace(bundle) && StringHelper.containsNonWhitespace(key)) {
        // Get userconfigured reference locale
        Preferences guiPrefs = ureq.getUserSession().getGuiPreferences();
        List<String> referenceLangs = I18nModule.getTransToolReferenceLanguages();
        String referencePrefs = (String) guiPrefs.get(I18nModule.class, I18nModule.GUI_PREFS_PREFERRED_REFERENCE_LANG, referenceLangs
            .get(0));
        I18nManager i18nMgr = I18nManager.getInstance();
        Locale referenceLocale = i18nMgr.getLocaleOrNull(referencePrefs);
        // Set target local to current user language
        Locale targetLocale = i18nMgr.getLocaleOrNull(ureq.getLocale().toString());
View Full Code Here

TOP

Related Classes of org.olat.core.util.prefs.Preferences

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.