use of org.olat.core.gui.control.generic.ajax.autocompletion.AutoCompleterController 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;
}
use of org.olat.core.gui.control.generic.ajax.autocompletion.AutoCompleterController 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;
}
use of org.olat.core.gui.control.generic.ajax.autocompletion.AutoCompleterController 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;
}
use of org.olat.core.gui.control.generic.ajax.autocompletion.AutoCompleterController in project openolat by klemens.
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;
}
Aggregations