use of org.olat.basesecurity.events.SingleIdentityChosenEvent in project OpenOLAT by OpenOLAT.
the class UserSearchFlexiController method doFireSelection.
@Override
protected void doFireSelection(UserRequest ureq, List<String> res) {
String mySel = res.isEmpty() ? null : res.get(0);
if (StringHelper.containsNonWhitespace(mySel) && StringHelper.isLong(mySel)) {
try {
Long key = Long.valueOf(mySel);
if (key > 0) {
Identity chosenIdent = securityManager.loadIdentityByKey(key);
if (chosenIdent != null) {
fireEvent(ureq, new SingleIdentityChosenEvent(chosenIdent));
List<Identity> selectedIdentities = Collections.singletonList(chosenIdent);
userTableModel.setObjects(selectedIdentities);
Set<Integer> selectedIndex = new HashSet<>();
selectedIndex.add(new Integer(0));
tableEl.setMultiSelectedIndex(selectedIndex);
}
}
} catch (NumberFormatException e) {
getWindowControl().setWarning(translate("error.no.user.found"));
}
} else {
getWindowControl().setWarning(translate("error.search.form.notempty"));
}
}
use of org.olat.basesecurity.events.SingleIdentityChosenEvent in project OpenOLAT by OpenOLAT.
the class UsermanagerUserSearchForm method activate.
@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
if (state instanceof StateMapped) {
StateMapped searchState = (StateMapped) state;
searchform.setStateEntry(searchState);
if (entries != null && entries.size() > 0) {
String table = entries.get(0).getOLATResourceable().getResourceableTypeName();
if ("table".equals(table)) {
entries.remove(0);
event(ureq, searchform, Event.DONE_EVENT);
}
}
}
if (entries == null || entries.isEmpty())
return;
for (int i = 0; i < entries.size(); i++) {
String resourceType = entries.get(i).getOLATResourceable().getResourceableTypeName();
if ("Identity".equalsIgnoreCase(resourceType)) {
Long identityKey = entries.get(i).getOLATResourceable().getResourceableId();
Identity found = null;
if (tdm != null) {
for (Identity identity : tdm.getObjects()) {
if (identityKey.equals(identity.getKey())) {
found = identity;
}
}
}
if (found == null) {
found = securityManager.loadIdentityByKey(identityKey);
if (found == null)
return;
List<Identity> foundIdentites = new ArrayList<>();
foundIdentites.add(found);
initUserListCtr(ureq, foundIdentites, 0);
}
fireEvent(ureq, new SingleIdentityChosenEvent(found));
}
}
}
use of org.olat.basesecurity.events.SingleIdentityChosenEvent in project OpenOLAT by OpenOLAT.
the class DirectDeleteController method event.
/**
* This dispatches controller events...
*
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
*/
public void event(UserRequest ureq, Controller sourceController, Event event) {
if (sourceController == usc) {
if (event == Event.CANCELLED_EVENT) {
removeAsListenerAndDispose(usc);
} else if (event instanceof MultiIdentityChosenEvent) {
MultiIdentityChosenEvent multiEvent = (MultiIdentityChosenEvent) event;
toDelete = multiEvent.getChosenIdentities();
if (toDelete.size() == 0) {
showError("msg.selectionempty");
return;
}
String names = buildUserNameList(toDelete);
deleteConfirmController = activateOkCancelDialog(ureq, null, translate("readyToDelete.delete.confirm", names), deleteConfirmController);
return;
} else if (event instanceof SingleIdentityChosenEvent) {
// single choose event may come from autocompleter user search
SingleIdentityChosenEvent uce = (SingleIdentityChosenEvent) event;
toDelete = new ArrayList<Identity>();
toDelete.add(uce.getChosenIdentity());
String fullname = userManager.getUserDisplayName(uce.getChosenIdentity());
deleteConfirmController = activateOkCancelDialog(ureq, null, translate("readyToDelete.delete.confirm", fullname), deleteConfirmController);
return;
} else {
throw new AssertException("unknown event ::" + event.getCommand());
}
} else if (sourceController == deleteConfirmController) {
if (DialogBoxUIFactory.isOkEvent(event)) {
deleteIdentities(toDelete);
if (bdc != null) {
bdc.sendMail();
}
initializeUserSearchController(ureq);
initializeUserListForm(ureq);
showInfo("deleted.users.msg");
}
} else if (sourceController == bdc) {
toDelete = bdc.getToDelete();
cmc.deactivate();
String names = buildUserNameList(toDelete);
deleteConfirmController = activateOkCancelDialog(ureq, null, translate("readyToDelete.delete.confirm", names), deleteConfirmController);
} else if (sourceController == cmc) {
if (event == Event.CANCELLED_EVENT) {
cmc.deactivate();
}
} else if (sourceController == userListForm) {
removeAsListenerAndDispose(bdc);
bdc = new BulkDeleteController(ureq, getWindowControl(), userListForm.getLogins(), userListForm.getReason());
listenTo(bdc);
removeAsListenerAndDispose(cmc);
cmc = new CloseableModalController(getWindowControl(), translate("close"), bdc.getInitialComponent());
listenTo(cmc);
cmc.activate();
}
}
use of org.olat.basesecurity.events.SingleIdentityChosenEvent in project OpenOLAT by OpenOLAT.
the class MemberSearchController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (event instanceof SingleIdentityChosenEvent) {
SingleIdentityChosenEvent e = (SingleIdentityChosenEvent) event;
String key = e.getChosenIdentity().getKey().toString();
addToRunContext("keys", Collections.singletonList(key));
fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
} else if (event instanceof MultiIdentityChosenEvent) {
MultiIdentityChosenEvent e = (MultiIdentityChosenEvent) event;
Collection<String> keys = new ArrayList<String>();
for (Identity identity : e.getChosenIdentities()) {
keys.add(identity.getKey().toString());
}
addToRunContext("keys", keys);
fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
} else {
super.event(ureq, source, event);
}
}
use of org.olat.basesecurity.events.SingleIdentityChosenEvent in project OpenOLAT by OpenOLAT.
the class ImportMemberBySearchController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (event instanceof SingleIdentityChosenEvent) {
SingleIdentityChosenEvent e = (SingleIdentityChosenEvent) event;
addToRunContext("keyIdentities", Collections.singletonList(e.getChosenIdentity()));
fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
} else if (event instanceof MultiIdentityChosenEvent) {
MultiIdentityChosenEvent e = (MultiIdentityChosenEvent) event;
addToRunContext("keyIdentities", e.getChosenIdentities());
fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
} else {
super.event(ureq, source, event);
}
}
Aggregations