Search in sources :

Example 1 with ListProvider

use of org.olat.core.gui.control.generic.ajax.autocompletion.ListProvider in project OpenOLAT by OpenOLAT.

the class TableController method createTableSearchController.

private AutoCompleterController createTableSearchController(final UserRequest ureq, final WindowControl wControl) {
    ListProvider genericProvider = new TableListProvider(table);
    removeAsListenerAndDispose(tableSearchController);
    tableSearchController = new AutoCompleterController(ureq, wControl, genericProvider, null, false, 60, 3, translate("table.filter.label"));
    tableSearchController.setEmptyAsReset(true);
    listenTo(tableSearchController);
    return tableSearchController;
}
Also used : ListProvider(org.olat.core.gui.control.generic.ajax.autocompletion.ListProvider) AutoCompleterController(org.olat.core.gui.control.generic.ajax.autocompletion.AutoCompleterController)

Example 2 with ListProvider

use of org.olat.core.gui.control.generic.ajax.autocompletion.ListProvider in project OpenOLAT by OpenOLAT.

the class EMailCalloutCtrl method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    Roles roles = ureq.getUserSession().getRoles();
    boolean autoCompleteAllowed = securityModule.isUserAllowedAutoComplete(roles);
    boolean isAdministrativeUser = securityModule.isUserAllowedAdminProps(roles);
    if (autoCompleteAllowed) {
        ListProvider provider = new UserSearchListProvider();
        autocompleterC = new FlexiAutoCompleterController(ureq, getWindowControl(), provider, null, isAdministrativeUser, allowExternalAddress, 60, 3, null, mainForm);
        autocompleterC.setFormElement(false);
        listenTo(autocompleterC);
        FormItem item = autocompleterC.getInitialFormItem();
        formLayout.add(item);
    } else if (allowExternalAddress) {
        emailEl = uifactory.addTextElement("email" + CodeHelper.getRAMUniqueID(), "email", null, 256, "", formLayout);
    }
}
Also used : FormItem(org.olat.core.gui.components.form.flexible.FormItem) UserSearchListProvider(org.olat.admin.user.UserSearchListProvider) ListProvider(org.olat.core.gui.control.generic.ajax.autocompletion.ListProvider) UserSearchListProvider(org.olat.admin.user.UserSearchListProvider) Roles(org.olat.core.id.Roles) FlexiAutoCompleterController(org.olat.core.gui.control.generic.ajax.autocompletion.FlexiAutoCompleterController)

Example 3 with ListProvider

use of org.olat.core.gui.control.generic.ajax.autocompletion.ListProvider in project openolat by klemens.

the class EMailCalloutCtrl method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    Roles roles = ureq.getUserSession().getRoles();
    boolean autoCompleteAllowed = securityModule.isUserAllowedAutoComplete(roles);
    boolean isAdministrativeUser = securityModule.isUserAllowedAdminProps(roles);
    if (autoCompleteAllowed) {
        ListProvider provider = new UserSearchListProvider();
        autocompleterC = new FlexiAutoCompleterController(ureq, getWindowControl(), provider, null, isAdministrativeUser, allowExternalAddress, 60, 3, null, mainForm);
        autocompleterC.setFormElement(false);
        listenTo(autocompleterC);
        FormItem item = autocompleterC.getInitialFormItem();
        formLayout.add(item);
    } else if (allowExternalAddress) {
        emailEl = uifactory.addTextElement("email" + CodeHelper.getRAMUniqueID(), "email", null, 256, "", formLayout);
    }
}
Also used : FormItem(org.olat.core.gui.components.form.flexible.FormItem) UserSearchListProvider(org.olat.admin.user.UserSearchListProvider) ListProvider(org.olat.core.gui.control.generic.ajax.autocompletion.ListProvider) UserSearchListProvider(org.olat.admin.user.UserSearchListProvider) Roles(org.olat.core.id.Roles) FlexiAutoCompleterController(org.olat.core.gui.control.generic.ajax.autocompletion.FlexiAutoCompleterController)

Example 4 with ListProvider

use of org.olat.core.gui.control.generic.ajax.autocompletion.ListProvider in project OpenOLAT by OpenOLAT.

the class GUIDemoMainController method handleOwnMenuTreeEvent.

@Override
protected Controller handleOwnMenuTreeEvent(Object uobject, final UserRequest ureq) {
    if (uobject.equals("guidemo-autocompletion")) {
        // for a demo of autocompletion, do a user search
        ListProvider provider = new ListProvider() {

            public void getResult(String searchValue, ListReceiver receiver) {
                Map<String, String> userProperties = new HashMap<String, String>();
                // We can only search in mandatory User-Properties due to problems
                // with hibernate query with join and not existing rows
                userProperties.put(UserConstants.FIRSTNAME, searchValue);
                userProperties.put(UserConstants.LASTNAME, searchValue);
                userProperties.put(UserConstants.EMAIL, searchValue);
                List<Identity> res = BaseSecurityManager.getInstance().getVisibleIdentitiesByPowerSearch(searchValue, userProperties, false, null, null, null, null, null);
                int maxEntries = 15;
                boolean hasMore = false;
                for (Iterator<Identity> it_res = res.iterator(); (hasMore = it_res.hasNext()) && maxEntries > 0; ) {
                    maxEntries--;
                    Identity ident = it_res.next();
                    User u = ident.getUser();
                    String key = ident.getKey().toString();
                    String displayKey = ident.getName();
                    String first = u.getProperty(UserConstants.FIRSTNAME, getLocale());
                    String last = u.getProperty(UserConstants.LASTNAME, getLocale());
                    String displayText = last + " " + first;
                    receiver.addEntry(key, displayKey, displayText, CSSHelper.CSS_CLASS_USER);
                }
                if (hasMore) {
                    receiver.addEntry("-1", ".....");
                }
            }
        };
        Controller c = new AutoCompleterController(ureq, getWindowControl(), provider, null, true, 60, 3, null);
        // for demo only, normally use in parent controller
        c.addControllerListener(new ControllerEventListener() {

            public void dispatchEvent(UserRequest uureq, Controller source, Event event) {
                EntriesChosenEvent ece = (EntriesChosenEvent) event;
                String sel = ece.getEntries().toString();
                getWindowControl().setInfo("selected entrie(s):" + sel);
            }
        });
        return c;
    }
    return null;
}
Also used : User(org.olat.core.id.User) HashMap(java.util.HashMap) ListProvider(org.olat.core.gui.control.generic.ajax.autocompletion.ListProvider) Controller(org.olat.core.gui.control.Controller) AutoCompleterController(org.olat.core.gui.control.generic.ajax.autocompletion.AutoCompleterController) GenericMainController(org.olat.core.gui.control.generic.layout.GenericMainController) ControllerEventListener(org.olat.core.gui.control.ControllerEventListener) Event(org.olat.core.gui.control.Event) EntriesChosenEvent(org.olat.core.gui.control.generic.ajax.autocompletion.EntriesChosenEvent) AutoCompleterController(org.olat.core.gui.control.generic.ajax.autocompletion.AutoCompleterController) Identity(org.olat.core.id.Identity) ListReceiver(org.olat.core.gui.control.generic.ajax.autocompletion.ListReceiver) EntriesChosenEvent(org.olat.core.gui.control.generic.ajax.autocompletion.EntriesChosenEvent) UserRequest(org.olat.core.gui.UserRequest)

Example 5 with ListProvider

use of org.olat.core.gui.control.generic.ajax.autocompletion.ListProvider in project openolat by klemens.

the class TableController method createTableSearchController.

private AutoCompleterController createTableSearchController(final UserRequest ureq, final WindowControl wControl) {
    ListProvider genericProvider = new TableListProvider(table);
    removeAsListenerAndDispose(tableSearchController);
    tableSearchController = new AutoCompleterController(ureq, wControl, genericProvider, null, false, 60, 3, translate("table.filter.label"));
    tableSearchController.setEmptyAsReset(true);
    listenTo(tableSearchController);
    return tableSearchController;
}
Also used : ListProvider(org.olat.core.gui.control.generic.ajax.autocompletion.ListProvider) AutoCompleterController(org.olat.core.gui.control.generic.ajax.autocompletion.AutoCompleterController)

Aggregations

ListProvider (org.olat.core.gui.control.generic.ajax.autocompletion.ListProvider)6 AutoCompleterController (org.olat.core.gui.control.generic.ajax.autocompletion.AutoCompleterController)4 HashMap (java.util.HashMap)2 UserSearchListProvider (org.olat.admin.user.UserSearchListProvider)2 UserRequest (org.olat.core.gui.UserRequest)2 FormItem (org.olat.core.gui.components.form.flexible.FormItem)2 Controller (org.olat.core.gui.control.Controller)2 ControllerEventListener (org.olat.core.gui.control.ControllerEventListener)2 Event (org.olat.core.gui.control.Event)2 EntriesChosenEvent (org.olat.core.gui.control.generic.ajax.autocompletion.EntriesChosenEvent)2 FlexiAutoCompleterController (org.olat.core.gui.control.generic.ajax.autocompletion.FlexiAutoCompleterController)2 ListReceiver (org.olat.core.gui.control.generic.ajax.autocompletion.ListReceiver)2 GenericMainController (org.olat.core.gui.control.generic.layout.GenericMainController)2 Identity (org.olat.core.id.Identity)2 Roles (org.olat.core.id.Roles)2 User (org.olat.core.id.User)2