use of org.olat.basesecurity.events.MultiIdentityChosenEvent in project OpenOLAT by OpenOLAT.
the class UserSearchController method event.
/**
* @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 source, Event event) {
if (source == tableCtr) {
if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
TableEvent te = (TableEvent) event;
if (te.getActionId().equals(ACTION_SINGLESELECT_CHOOSE)) {
int rowid = te.getRowId();
Identity foundIdentity = tdm.getObject(rowid);
foundIdentities.add(foundIdentity);
// Tell parentController that a subject has been found
fireEvent(ureq, new SingleIdentityChosenEvent(foundIdentity));
}
} else if (event.getCommand().equals(Table.COMMAND_MULTISELECT)) {
TableMultiSelectEvent tmse = (TableMultiSelectEvent) event;
if (tmse.getAction().equals(ACTION_MULTISELECT_CHOOSE)) {
foundIdentities = tdm.getObjects(tmse.getSelection());
fireEvent(ureq, new MultiIdentityChosenEvent(foundIdentities));
}
}
} else if (source == autocompleterC) {
if (event instanceof EntriesChosenEvent) {
EntriesChosenEvent ece = (EntriesChosenEvent) event;
List<String> res = ece.getEntries();
// if we get the event, we have a result or an incorrect selection see OLAT-5114 -> check for empty
String mySel = res.isEmpty() ? null : (String) res.get(0);
if ((mySel == null) || mySel.trim().equals("")) {
getWindowControl().setWarning(translate("error.search.form.notempty"));
return;
}
// default not found
Long key = -1l;
try {
key = Long.valueOf(mySel);
if (key > 0) {
Identity chosenIdent = BaseSecurityManager.getInstance().loadIdentityByKey(key);
// No need to check for null, exception is thrown when identity does not exist which really
// should not happen at all.
// Tell that an identity has been chosen
fireEvent(ureq, new SingleIdentityChosenEvent(chosenIdent));
}
} catch (NumberFormatException e) {
getWindowControl().setWarning(translate("error.no.user.found"));
return;
}
}
} else if (source == searchform) {
if (event == Event.DONE_EVENT) {
// form validation was ok
doSearch(ureq);
} else if (event == Event.CANCELLED_EVENT) {
fireEvent(ureq, Event.CANCELLED_EVENT);
}
}
}
use of org.olat.basesecurity.events.MultiIdentityChosenEvent in project OpenOLAT by OpenOLAT.
the class GroupController method event.
/**
* @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)
*/
@Override
public void event(UserRequest ureq, Controller sourceController, Event event) {
if (sourceController == tableCtr) {
if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
// Single row selects
TableEvent te = (TableEvent) event;
String actionid = te.getActionId();
final Identity identity = identitiesTableModel.getObject(te.getRowId()).getIdentity();
if (actionid.equals(COMMAND_VCARD)) {
// get identity and open new visiting card controller in new window
ControllerCreator userInfoMainControllerCreator = new ControllerCreator() {
@Override
public Controller createController(UserRequest lureq, WindowControl lwControl) {
return new UserInfoMainController(lureq, lwControl, identity, true, false);
}
};
// wrap the content controller into a full header layout
ControllerCreator layoutCtrlr = BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(ureq, userInfoMainControllerCreator);
// open in new browser window
PopupBrowserWindow pbw = getWindowControl().getWindowBackOffice().getWindowManager().createNewPopupBrowserWindowFor(ureq, layoutCtrlr);
pbw.open(ureq);
//
} else if (actionid.equals(COMMAND_SELECTUSER)) {
fireEvent(ureq, new SingleIdentityChosenEvent(identity));
} else if (COMMAND_IM.equals(actionid)) {
doIm(ureq, identity);
}
} else if (event.getCommand().equals(Table.COMMAND_MULTISELECT)) {
// Multiselect events
TableMultiSelectEvent tmse = (TableMultiSelectEvent) event;
if (tmse.getAction().equals(COMMAND_REMOVEUSER)) {
if (tmse.getSelection().isEmpty()) {
// empty selection
showWarning("msg.selectionempty");
return;
}
int size = identitiesTableModel.getObjects().size();
toRemove = identitiesTableModel.getIdentities(tmse.getSelection());
// list is never null, but can be empty
if (keepAtLeastOne && (size == 1 || size - toRemove.size() == 0)) {
// at least one must be kept
// do not delete the last one => ==1
// do not allow to delete all => size - selectedCnt == 0
showError("msg.atleastone");
} else {
// valid selection to be deleted.
if (removeUserMailDefaultTempl == null) {
doBuildConfirmDeleteDialog(ureq);
} else {
removeAsListenerAndDispose(removeUserMailCtr);
removeUserMailCtr = new MailNotificationEditController(getWindowControl(), ureq, removeUserMailDefaultTempl, true, false, true);
listenTo(removeUserMailCtr);
removeAsListenerAndDispose(cmc);
cmc = new CloseableModalController(getWindowControl(), translate("close"), removeUserMailCtr.getInitialComponent());
listenTo(cmc);
cmc.activate();
}
}
}
}
} else if (sourceController == removeUserMailCtr) {
if (event == Event.DONE_EVENT) {
removeUserMailCustomTempl = removeUserMailCtr.getMailTemplate();
cmc.deactivate();
doBuildConfirmDeleteDialog(ureq);
} else {
cmc.deactivate();
}
} else if (sourceController == usc) {
if (event == Event.CANCELLED_EVENT) {
cmc.deactivate();
} else {
if (event instanceof SingleIdentityChosenEvent) {
SingleIdentityChosenEvent singleEvent = (SingleIdentityChosenEvent) event;
Identity choosenIdentity = singleEvent.getChosenIdentity();
if (choosenIdentity == null) {
showError("msg.selectionempty");
return;
}
toAdd = new ArrayList<Identity>();
toAdd.add(choosenIdentity);
} else if (event instanceof MultiIdentityChosenEvent) {
MultiIdentityChosenEvent multiEvent = (MultiIdentityChosenEvent) event;
toAdd = multiEvent.getChosenIdentities();
if (toAdd.size() == 0) {
showError("msg.selectionempty");
return;
}
} else {
throw new RuntimeException("unknown event ::" + event.getCommand());
}
if (toAdd.size() == 1) {
// check if already in group [makes only sense for a single choosen identity]
if (groupDao.hasRole(group, toAdd.get(0), role)) {
String fullName = userManager.getUserDisplayName(toAdd.get(0));
getWindowControl().setInfo(translate("msg.subjectalreadyingroup", new String[] { fullName }));
return;
}
} else if (toAdd.size() > 1) {
// check if already in group
List<Identity> alreadyInGroup = new ArrayList<Identity>();
for (int i = 0; i < toAdd.size(); i++) {
if (groupDao.hasRole(group, toAdd.get(i), role)) {
tableCtr.setMultiSelectSelectedAt(i, false);
alreadyInGroup.add(toAdd.get(i));
}
}
if (!alreadyInGroup.isEmpty()) {
StringBuilder names = new StringBuilder();
for (Identity ident : alreadyInGroup) {
if (names.length() > 0)
names.append(", ");
names.append(userManager.getUserDisplayName(ident));
toAdd.remove(ident);
}
getWindowControl().setInfo(translate("msg.subjectsalreadyingroup", names.toString()));
}
if (toAdd.isEmpty()) {
return;
}
}
// in both cases continue adding the users or asking for the mail
// template if available (=not null)
cmc.deactivate();
if (addUserMailDefaultTempl == null) {
doAddIdentitiesToGroup(ureq, toAdd, null);
} else {
removeAsListenerAndDispose(addUserMailCtr);
addUserMailCtr = new MailNotificationEditController(getWindowControl(), ureq, addUserMailDefaultTempl, true, mandatoryEmail, true);
listenTo(addUserMailCtr);
removeAsListenerAndDispose(cmc);
cmc = new CloseableModalController(getWindowControl(), translate("close"), addUserMailCtr.getInitialComponent());
listenTo(cmc);
cmc.activate();
}
}
// in any case cleanup this controller, not used anymore
usc.dispose();
usc = null;
} else if (sourceController == addUserMailCtr) {
if (event == Event.DONE_EVENT) {
MailTemplate customTemplate = addUserMailCtr.getMailTemplate();
doAddIdentitiesToGroup(ureq, toAdd, customTemplate);
cmc.deactivate();
} else if (event == Event.CANCELLED_EVENT) {
cmc.deactivate();
} else {
throw new RuntimeException("unknown event ::" + event.getCommand());
}
} else if (sourceController == confirmDelete) {
if (DialogBoxUIFactory.isYesEvent(event)) {
// before deleting, assure it is allowed
if (!mayModifyMembers)
throw new AssertException("not allowed to remove member!");
// list is never null, but can be empty
// TODO: Theoretically it can happen that the table model here is not accurate!
// the 'keep at least one' should be handled by the security manager that should
// synchronizes the method on the group
int size = identitiesTableModel.getObjects().size();
if (keepAtLeastOne && (size - toRemove.size() == 0)) {
showError("msg.atleastone");
} else {
doRemoveIdentitiesFromGroup(ureq, toRemove, removeUserMailCustomTempl);
}
}
} else if (sourceController == userToGroupWizard) {
if (event == Event.CANCELLED_EVENT || event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
getWindowControl().pop();
removeAsListenerAndDispose(userToGroupWizard);
userToGroupWizard = null;
if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
reloadData();
}
}
}
}
use of org.olat.basesecurity.events.MultiIdentityChosenEvent in project OpenOLAT by OpenOLAT.
the class AuthorListController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (cmc == source) {
cleanUp();
} else if (createCtrl == source) {
cmc.deactivate();
if (Event.DONE_EVENT.equals(event)) {
launchEditDescription(ureq, createCtrl.getAddedEntry());
reloadRows();
cleanUp();
} else if (CreateRepositoryEntryController.CREATION_WIZARD.equals(event)) {
doPostCreateWizard(ureq, createCtrl.getAddedEntry(), createCtrl.getHandler());
} else {
cleanUp();
}
} else if (copyCtrl == source) {
cmc.deactivate();
if (event == Event.DONE_EVENT) {
reloadRows();
launchEditDescription(ureq, copyCtrl.getCopiedEntry());
}
cleanUp();
} else if (importCtrl == source) {
cmc.deactivate();
if (Event.DONE_EVENT.equals(event)) {
reloadRows();
launchEditDescription(ureq, importCtrl.getImportedEntry());
}
cleanUp();
} else if (wizardCtrl == source) {
if (event.equals(Event.CHANGED_EVENT) || event.equals(Event.CANCELLED_EVENT)) {
getWindowControl().pop();
RepositoryEntry newEntry = (RepositoryEntry) wizardCtrl.getRunContext().get("authoringNewEntry");
reloadRows();
cleanUp();
launchEditDescription(ureq, newEntry);
}
} else if (searchCtrl == source) {
if (event instanceof SearchEvent) {
SearchEvent se = (SearchEvent) event;
doSearch(ureq, se);
} else if (event == Event.CANCELLED_EVENT) {
searchParams.setResourceTypes(null);
searchParams.setIdAndRefs(null);
searchParams.setAuthor(null);
searchParams.setDisplayname(null);
searchParams.setDescription(null);
searchParams.setOwnedResourcesOnly(false);
searchParams.setResourceUsage(ResourceUsage.all);
searchParams.setLicneseTypeKeys(null);
}
} else if (userSearchCtr == source) {
@SuppressWarnings("unchecked") List<AuthoringEntryRow> rows = (List<AuthoringEntryRow>) userSearchCtr.getUserObject();
if (event instanceof MultiIdentityChosenEvent) {
MultiIdentityChosenEvent mice = (MultiIdentityChosenEvent) event;
doAddOwners(mice.getChosenIdentities(), rows);
} else if (event instanceof SingleIdentityChosenEvent) {
SingleIdentityChosenEvent sice = (SingleIdentityChosenEvent) event;
List<Identity> futureOwners = Collections.singletonList(sice.getChosenIdentity());
doAddOwners(futureOwners, rows);
}
cmc.deactivate();
cleanUp();
} else if (sendMailCtrl == source) {
cmc.deactivate();
cleanUp();
} else if (toolsCtrl == source) {
if (event == Event.DONE_EVENT) {
toolsCalloutCtrl.deactivate();
cleanUp();
}
} else if (referencesCtrl == source) {
if (event == Event.DONE_EVENT) {
toolsCalloutCtrl.deactivate();
cleanUp();
}
} else if (closeCtrl == source) {
if (event == Event.CANCELLED_EVENT) {
cmc.deactivate();
cleanUp();
} else if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
cmc.deactivate();
reloadRows();
cleanUp();
}
} else if (confirmDeleteCtrl == source) {
if (event == Event.CANCELLED_EVENT) {
cmc.deactivate();
cleanUp();
} else if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
cmc.deactivate();
reloadRows();
cleanUp();
}
} else if (copyDialogCtrl == source) {
if (DialogBoxUIFactory.isYesEvent(event)) {
@SuppressWarnings("unchecked") List<AuthoringEntryRow> rows = (List<AuthoringEntryRow>) copyDialogCtrl.getUserObject();
doCompleteCopy(rows);
reloadRows();
}
}
super.event(ureq, source, event);
}
use of org.olat.basesecurity.events.MultiIdentityChosenEvent in project OpenOLAT by OpenOLAT.
the class ImportAuthorBySearchController 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.MultiIdentityChosenEvent in project OpenOLAT by OpenOLAT.
the class TaxonomyLevelCompetenceController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (userSearchCtrl == source) {
if (event instanceof SingleIdentityChosenEvent) {
SingleIdentityChosenEvent singleEvent = (SingleIdentityChosenEvent) event;
Identity choosenIdentity = singleEvent.getChosenIdentity();
if (choosenIdentity != null) {
List<Identity> toAdd = Collections.singletonList(choosenIdentity);
doAddCompetence(toAdd, (TaxonomyCompetenceTypes) userSearchCtrl.getUserObject());
loadModel();
}
} else if (event instanceof MultiIdentityChosenEvent) {
MultiIdentityChosenEvent multiEvent = (MultiIdentityChosenEvent) event;
List<Identity> toAdd = multiEvent.getChosenIdentities();
if (toAdd.size() > 0) {
doAddCompetence(toAdd, (TaxonomyCompetenceTypes) userSearchCtrl.getUserObject());
loadModel();
}
}
cmc.deactivate();
cleanUp();
} else if (confirmDeleteDialog == source) {
if (DialogBoxUIFactory.isOkEvent(event) || DialogBoxUIFactory.isYesEvent(event)) {
@SuppressWarnings("unchecked") List<TaxonomyLevelCompetenceRow> selectedRows = (List<TaxonomyLevelCompetenceRow>) confirmDeleteDialog.getUserObject();
doRemoveCompetences(selectedRows);
}
} else if (editCompetenceCtrl == source) {
if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
loadModel();
tableEl.reset(false, false, true);
}
cmc.deactivate();
cleanUp();
} else if (addCompetencesCallout == source) {
cleanUp();
} else if (cmc == source) {
cleanUp();
}
super.event(ureq, source, event);
}
Aggregations