Search in sources :

Example 21 with Collator

use of java.text.Collator in project OpenAM by OpenRock.

the class DirectoryServicesImpl method search.

// RENAME from searchUsingSearchControl => search()
/**
     * Search the Directory
     * 
     * @param token
     *            SSOToken
     * @param entryDN
     *            DN of the entry to start the search with
     * @param searchFilter
     *            search filter
     * @param searchControl
     *            search control defining the VLV indexes and search scope
     * @param attrNames
     *            name of attributes
     * @return Set set of matching DNs
     */
public AMSearchResults search(SSOToken token, String entryDN, String searchFilter, SearchControl searchControl, String[] attrNames) throws AMException {
    AMSearchResults amResults = null;
    try {
        SortKey[] skeys = searchControl.getSortKeys();
        SortKey skey = null;
        if (skeys != null && skeys.length > 0 && skeys[0].attributeName != null) {
            skey = skeys[0];
        }
        String userLocale = CommonUtils.getUserLocale(token);
        if (debug.messageEnabled()) {
            debug.message("DirectoryServicesImpl.search() search with " + "searchcontrol locale = " + userLocale);
        }
        Collator collator = Collator.getInstance(Locale.getLocale(userLocale));
        SearchControl sc;
        if (skey != null) {
            sc = new SearchControl();
            sc.setMaxResults(searchControl.getMaxResults());
            sc.setSearchScope(searchControl.getSearchScope());
            sc.setTimeOut(searchControl.getTimeOut());
        } else {
            sc = searchControl;
        }
        PersistentObject po = UMSObject.getObjectHandle(token, new Guid(entryDN));
        SearchResults results;
        if (attrNames == null) {
            if (skey == null) {
                results = po.search(searchFilter, sc);
            } else {
                String[] tmpAttrNames = { skey.attributeName };
                results = po.search(searchFilter, tmpAttrNames, sc);
            }
        } else {
            if (skey == null) {
                results = po.search(searchFilter, attrNames, sc);
            } else {
                String[] tmpAttrNames = new String[attrNames.length + 1];
                System.arraycopy(attrNames, 0, tmpAttrNames, 0, attrNames.length);
                tmpAttrNames[attrNames.length] = skey.attributeName;
                results = po.search(searchFilter, tmpAttrNames, sc);
            }
        }
        amResults = getSearchResults(results, skey, attrNames, collator, sc.isGetAllReturnAttributesEnabled());
    } catch (UMSException ue) {
        if (debug.warningEnabled()) {
            debug.warning("DirectoryServicesImpl.search() with search " + "control entryDN: " + entryDN + " Search Filter: " + searchFilter + " Error occurred: ", ue);
        }
        processInternalException(token, ue, "341");
    }
    return amResults;
}
Also used : UMSException(com.iplanet.ums.UMSException) PersistentObject(com.iplanet.ums.PersistentObject) SortKey(com.iplanet.ums.SortKey) SearchControl(com.iplanet.ums.SearchControl) Guid(com.iplanet.ums.Guid) AMSearchResults(com.iplanet.am.sdk.AMSearchResults) AMSearchResults(com.iplanet.am.sdk.AMSearchResults) SearchResults(com.iplanet.ums.SearchResults) Collator(java.text.Collator)

Example 22 with Collator

use of java.text.Collator in project zm-mailbox by Zimbra.

the class Entry method sortByDisplayName.

/**
     * Sort a collection of Entries by locale-sensitive String comparison on
     * each entry's displayName.  If there is no display name, use entry.getLabel()
     * as the key.
     */
public static List<Entry> sortByDisplayName(Collection<? extends Entry> entries, Locale locale) {
    List<Entry> sorted = Lists.newArrayList();
    // short-circuit if there is only one entry or no entry
    if (entries.size() <= 1) {
        sorted.addAll(entries);
    } else {
        Collator collator = Collator.getInstance(locale);
        TreeMultimap<CollationKey, Entry> map = TreeMultimap.create(Ordering.natural(), new SortByLabelAsc());
        for (Entry entry : entries) {
            String key = entry.getAttr(Provisioning.A_displayName);
            if (key == null) {
                key = entry.getLabel();
            }
            CollationKey collationKey = collator.getCollationKey(key);
            map.put(collationKey, entry);
        }
        sorted.addAll(map.values());
    }
    return sorted;
}
Also used : CollationKey(java.text.CollationKey) Collator(java.text.Collator)

Example 23 with Collator

use of java.text.Collator in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class VirtualKeyboardFragment method updateInputMethodPreferenceViews.

private void updateInputMethodPreferenceViews() {
    // Clear existing "InputMethodPreference"s
    mInputMethodPreferenceList.clear();
    List<String> permittedList = mDpm.getPermittedInputMethodsForCurrentUser();
    final Context context = getPrefContext();
    final List<InputMethodInfo> imis = mImm.getEnabledInputMethodList();
    final int N = (imis == null ? 0 : imis.size());
    for (int i = 0; i < N; ++i) {
        final InputMethodInfo imi = imis.get(i);
        final boolean isAllowedByOrganization = permittedList == null || permittedList.contains(imi.getPackageName());
        Drawable icon;
        try {
            // TODO: Consider other ways to retrieve an icon to show here.
            icon = getActivity().getPackageManager().getApplicationIcon(imi.getPackageName());
        } catch (Exception e) {
            // TODO: Consider handling the error differently perhaps by showing default icons.
            icon = NO_ICON;
        }
        final InputMethodPreference pref = new InputMethodPreference(context, imi, false, /* isImeEnabler */
        isAllowedByOrganization, null);
        pref.setIcon(icon);
        mInputMethodPreferenceList.add(pref);
    }
    final Collator collator = Collator.getInstance();
    Collections.sort(mInputMethodPreferenceList, new Comparator<InputMethodPreference>() {

        @Override
        public int compare(InputMethodPreference lhs, InputMethodPreference rhs) {
            return lhs.compareTo(rhs, collator);
        }
    });
    getPreferenceScreen().removeAll();
    for (int i = 0; i < N; ++i) {
        final InputMethodPreference pref = mInputMethodPreferenceList.get(i);
        pref.setOrder(i);
        getPreferenceScreen().addPreference(pref);
        InputMethodAndSubtypeUtil.removeUnnecessaryNonPersistentPreference(pref);
        pref.updatePreferenceViews();
    }
    mAddVirtualKeyboardScreen.setIcon(R.drawable.ic_add_24dp);
    mAddVirtualKeyboardScreen.setOrder(N);
    getPreferenceScreen().addPreference(mAddVirtualKeyboardScreen);
}
Also used : Context(android.content.Context) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) InputMethodInfo(android.view.inputmethod.InputMethodInfo) Collator(java.text.Collator)

Example 24 with Collator

use of java.text.Collator in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class InputMethodAndLanguageSettings method updateInputMethodPreferenceViews.

private void updateInputMethodPreferenceViews() {
    if (mKeyboardSettingsCategory == null) {
        return;
    }
    synchronized (mInputMethodPreferenceList) {
        // Clear existing "InputMethodPreference"s
        for (final InputMethodPreference pref : mInputMethodPreferenceList) {
            mKeyboardSettingsCategory.removePreference(pref);
        }
        mInputMethodPreferenceList.clear();
        List<String> permittedList = mDpm.getPermittedInputMethodsForCurrentUser();
        final Context context = getPrefContext();
        final List<InputMethodInfo> imis = mShowsOnlyFullImeAndKeyboardList ? mInputMethodSettingValues.getInputMethodList() : mImm.getEnabledInputMethodList();
        final int N = (imis == null ? 0 : imis.size());
        for (int i = 0; i < N; ++i) {
            final InputMethodInfo imi = imis.get(i);
            final boolean isAllowedByOrganization = permittedList == null || permittedList.contains(imi.getPackageName());
            final InputMethodPreference pref = new InputMethodPreference(context, imi, mShowsOnlyFullImeAndKeyboardList, /* hasSwitch */
            isAllowedByOrganization, this);
            mInputMethodPreferenceList.add(pref);
        }
        final Collator collator = Collator.getInstance();
        Collections.sort(mInputMethodPreferenceList, new Comparator<InputMethodPreference>() {

            @Override
            public int compare(InputMethodPreference lhs, InputMethodPreference rhs) {
                return lhs.compareTo(rhs, collator);
            }
        });
        for (int i = 0; i < N; ++i) {
            final InputMethodPreference pref = mInputMethodPreferenceList.get(i);
            mKeyboardSettingsCategory.addPreference(pref);
            InputMethodAndSubtypeUtil.removeUnnecessaryNonPersistentPreference(pref);
            pref.updatePreferenceViews();
        }
    }
    updateCurrentImeName();
    // TODO: Consolidate the logic with InputMethodSettingsWrapper
    // CAVEAT: The preference class here does not know about the default value - that is
    // managed by the Input Method Manager Service, so in this case it could save the wrong
    // value. Hence we must update the checkboxes here.
    InputMethodAndSubtypeUtil.loadInputMethodSubtypeList(this, getContentResolver(), mInputMethodSettingValues.getInputMethodList(), null);
}
Also used : Context(android.content.Context) InputMethodInfo(android.view.inputmethod.InputMethodInfo) Collator(java.text.Collator)

Example 25 with Collator

use of java.text.Collator in project EnrichmentMapApp by BaderLab.

the class ControlPanel method updateEmViewCombo.

void updateEmViewCombo() {
    CyNetworkView selectedItem = (CyNetworkView) getEmViewCombo().getSelectedItem();
    Map<Long, EnrichmentMap> emMap = emManager.getAllEnrichmentMaps();
    getEmViewCombo().setEnabled(!emMap.isEmpty());
    getEmViewCombo().removeAllItems();
    if (!emMap.isEmpty()) {
        Set<CyNetworkView> allViews = networkViewManager.getNetworkViewSet();
        List<CyNetworkView> emViews = allViews.stream().filter(emManager::isEnrichmentMap).collect(Collectors.toList());
        Collator collator = Collator.getInstance(Locale.getDefault());
        emViews.sort((v1, v2) -> collator.compare(NetworkUtil.getTitle(v1), NetworkUtil.getTitle(v2)));
        emViews.forEach(getEmViewCombo()::addItem);
        getEmViewCombo().setSelectedItem(selectedItem);
    }
}
Also used : EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) CyNetworkView(org.cytoscape.view.model.CyNetworkView) Collator(java.text.Collator)

Aggregations

Collator (java.text.Collator)70 ArrayList (java.util.ArrayList)14 RuleBasedCollator (java.text.RuleBasedCollator)8 HashMap (java.util.HashMap)7 Comparator (java.util.Comparator)5 List (java.util.List)5 GraphObject (com.facebook.model.GraphObject)4 Context (android.content.Context)3 InputMethodInfo (android.view.inputmethod.InputMethodInfo)3 HashSet (java.util.HashSet)3 LinkedHashMap (java.util.LinkedHashMap)3 Locale (java.util.Locale)3 Entry (java.util.Map.Entry)3 SharedPreferences (android.content.SharedPreferences)2 ApplicationInfo (android.content.pm.ApplicationInfo)2 PackageInfo (android.content.pm.PackageInfo)2 DBObject (com.mongodb.DBObject)2 SMSException (com.sun.identity.sm.SMSException)2 ServiceSchema (com.sun.identity.sm.ServiceSchema)2 AutoPilot (com.ximpleware.AutoPilot)2