use of org.olat.core.gui.components.table.TableMultiSelectEvent in project OpenOLAT by OpenOLAT.
the class ChecklistAuthorOptionsForm 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
protected void event(UserRequest ureq, Controller source, Event event) {
if (source == runChecklistTable) {
if (event instanceof TableMultiSelectEvent) {
TableMultiSelectEvent tmse = (TableMultiSelectEvent) event;
selection = tmse.getSelection();
boolean doUpdate = true;
int size = visibleCheckpoints.size();
// check for once editable checkpoints -> show confirmation dialog
for (int i = 0; i < size; i++) {
Checkpoint checkpoint = visibleCheckpoints.get(i);
Boolean selected = checkpoint.getSelectionFor(ureq.getIdentity());
if (checkpoint.getMode().equals(CheckpointMode.MODE_EDITABLE_ONCE) && selected.booleanValue() != selection.get(i)) {
removeAsListenerAndDispose(yesNoDialog);
yesNoDialog = DialogBoxUIFactory.createYesNoDialog(ureq, getWindowControl(), translate("dialog.save.title"), translate("dialog.save.text"));
listenTo(yesNoDialog);
yesNoDialog.activate();
doUpdate = false;
break;
}
}
// no confirmation necessary, do update immediately
if (doUpdate)
updateCheckpoints(ureq);
}
} else if (source == yesNoDialog) {
// do update after confirmation
if (DialogBoxUIFactory.isYesEvent(event))
updateCheckpoints(ureq);
removeAsListenerAndDispose(yesNoDialog);
} else if (source == authorOptions) {
if (event == ChecklistAuthorOptionsForm.CONFIG_CHECKPOINT) {
removeAsListenerAndDispose(editController);
CheckpointComparator checkpointComparator = null;
boolean asc = runChecklistTable.getTableSortAsc();
switch(runChecklistTable.getTableSortCol()) {
case 1:
if (asc) {
checkpointComparator = ChecklistUIFactory.comparatorTitleAsc;
} else {
checkpointComparator = ChecklistUIFactory.comparatorTitleDesc;
}
break;
case 2:
if (asc) {
checkpointComparator = ChecklistUIFactory.comparatorDescriptionAsc;
} else {
checkpointComparator = ChecklistUIFactory.comparatorDescriptionDesc;
}
break;
case 3:
if (asc) {
checkpointComparator = ChecklistUIFactory.comparatorModeAsc;
} else {
checkpointComparator = ChecklistUIFactory.comparatorModeDesc;
}
break;
}
editController = ChecklistUIFactory.getInstance().createEditCheckpointsController(ureq, getWindowControl(), checklist, "cl.save.close", checkpointComparator);
listenTo(editController);
removeAsListenerAndDispose(cmcEdit);
cmcEdit = new CloseableModalController(getWindowControl(), translate("cl.close"), editController.getInitialComponent(), true, translate("cl.edit.title"));
listenTo(cmcEdit);
cmcEdit.activate();
} else if (event == ChecklistAuthorOptionsForm.MANAGE_CHECKPOINT) {
removeAsListenerAndDispose(manageController);
manageController = new ChecklistManageCheckpointsController(ureq, getWindowControl(), checklist, course, readOnly);
listenTo(manageController);
removeAsListenerAndDispose(cmcManage);
cmcManage = new CloseableModalController(getWindowControl(), translate("cl.close"), manageController.getInitialComponent(), true, translate("cl.manage.title"));
listenTo(cmcManage);
cmcManage.activate();
}
} else if (source == cmcEdit) {
initTable(ureq);
} else if (source == editController) {
if (event == Event.CHANGED_EVENT | event == Event.CANCELLED_EVENT) {
initTable(ureq);
cmcEdit.deactivate();
}
} else if (source == cmcManage) {
initTable(ureq);
} else if (source == manageController && event == Event.DONE_EVENT) {
initTable(ureq);
cmcManage.deactivate();
}
}
use of org.olat.core.gui.components.table.TableMultiSelectEvent in project OpenOLAT by OpenOLAT.
the class UsermanagerUserSearchForm 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 == searchform) {
if (event == Event.DONE_EVENT) {
// form validation was ok
identitiesList = findIdentitiesFromSearchForm();
initUserListCtr(ureq, identitiesList, null);
userListVC.put("userlist", tableCtr.getInitialComponent());
userListVC.contextPut("emptyList", (identitiesList.size() == 0 ? Boolean.TRUE : Boolean.FALSE));
panel.setContent(userListVC);
// fxdiff BAKS-7 Resume function
ContextEntry currentEntry = getWindowControl().getBusinessControl().getCurrentContextEntry();
if (currentEntry != null) {
currentEntry.setTransientState(searchform.getStateEntry());
}
addToHistory(ureq, tableCtr);
} else if (event == Event.CANCELLED_EVENT) {
fireEvent(ureq, Event.CANCELLED_EVENT);
}
} else if (source == tableCtr) {
if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
TableEvent te = (TableEvent) event;
String actionid = te.getActionId();
if (actionid.equals(ExtendedIdentitiesTableDataModel.COMMAND_SELECTUSER)) {
int rowid = te.getRowId();
Identity foundIdentity = tdm.getObject(rowid);
// Tell parentController that a subject has been found
fireEvent(ureq, new SingleIdentityChosenEvent(foundIdentity));
} else if (actionid.equals(ExtendedIdentitiesTableDataModel.COMMAND_VCARD)) {
// get identity and open new visiting card controller in new window
int rowid = te.getRowId();
final Identity identity = tdm.getObject(rowid);
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);
}
}
if (event instanceof TableMultiSelectEvent) {
// Multiselect events
TableMultiSelectEvent tmse = (TableMultiSelectEvent) event;
if (tmse.getAction().equals(CMD_BULKEDIT)) {
if (tmse.getSelection().isEmpty()) {
// empty selection
showWarning("msg.selectionempty");
return;
}
selectedIdentities = tdm.getIdentities(tmse.getSelection());
// valid selection: load in wizard
Step start = new UserBulkChangeStep00(ureq, selectedIdentities);
// callback executed in case wizard is finished.
StepRunnerCallback finish = new StepRunnerCallback() {
public Step execute(UserRequest ureq1, WindowControl wControl1, StepsRunContext runContext) {
// all information to do now is within the runContext saved
boolean hasChanges = false;
try {
if (runContext.containsKey("validChange") && ((Boolean) runContext.get("validChange")).booleanValue()) {
HashMap<String, String> attributeChangeMap = (HashMap<String, String>) runContext.get("attributeChangeMap");
HashMap<String, String> roleChangeMap = (HashMap<String, String>) runContext.get("roleChangeMap");
List<Long> ownGroups = (List<Long>) runContext.get("ownerGroups");
List<Long> partGroups = (List<Long>) runContext.get("partGroups");
// List<Long> mailGroups = (List<Long>) runContext.get("mailGroups");
if (attributeChangeMap.size() != 0 || roleChangeMap.size() != 0 || ownGroups.size() != 0 || partGroups.size() != 0) {
Identity addingIdentity = ureq1.getIdentity();
ubcMan.changeSelectedIdentities(selectedIdentities, attributeChangeMap, roleChangeMap, notUpdatedIdentities, isAdministrativeUser, ownGroups, partGroups, getTranslator(), addingIdentity);
hasChanges = true;
}
}
} catch (Exception any) {
// return new ErrorStep
}
// signal correct completion and tell if changes were made or not.
return hasChanges ? StepsMainRunController.DONE_MODIFIED : StepsMainRunController.DONE_UNCHANGED;
}
};
removeAsListenerAndDispose(userBulkChangeStepsController);
userBulkChangeStepsController = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("bulkChange.title"), "o_sel_user_bulk_change_wizard");
listenTo(userBulkChangeStepsController);
getWindowControl().pushAsModalDialog(userBulkChangeStepsController.getInitialComponent());
} else if (tmse.getAction().equals(CMD_MAIL)) {
if (tmse.getSelection().isEmpty()) {
// empty selection
showWarning("msg.selectionempty");
return;
}
// create e-mail message
ContactMessage cmsg = new ContactMessage(ureq.getIdentity());
selectedIdentities = tdm.getIdentities(tmse.getSelection());
ContactList contacts = new ContactList(translate("mailto.userlist"));
contacts.addAllIdentites(selectedIdentities);
cmsg.addEmailTo(contacts);
// create contact form controller with ContactMessage
removeAsListenerAndDispose(contactCtr);
contactCtr = new ContactFormController(ureq, getWindowControl(), true, false, false, cmsg);
listenTo(contactCtr);
mailVC.put("mailform", contactCtr.getInitialComponent());
panel.setContent(mailVC);
}
}
} else if (source == contactCtr) {
// in any case go back to list (events: done, failed or cancel)
panel.setContent(userListVC);
} else if (source == userBulkChangeStepsController) {
if (event == Event.CANCELLED_EVENT) {
getWindowControl().pop();
} else if (event == Event.CHANGED_EVENT) {
getWindowControl().pop();
Integer selIdentCount = selectedIdentities.size();
if (notUpdatedIdentities.size() > 0) {
Integer notUpdatedIdentCount = notUpdatedIdentities.size();
Integer sucChanges = selIdentCount - notUpdatedIdentCount;
String changeErrors = "";
for (String err : notUpdatedIdentities) {
changeErrors += err + "<br />";
}
getWindowControl().setError(translate("bulkChange.partialsuccess", new String[] { sucChanges.toString(), selIdentCount.toString(), changeErrors }));
} else {
showInfo("bulkChange.success");
}
// update table model - has changed
reloadDataModel(ureq);
} else if (event == Event.DONE_EVENT) {
showError("bulkChange.failed");
}
}
}
use of org.olat.core.gui.components.table.TableMultiSelectEvent in project OpenOLAT by OpenOLAT.
the class WikiMainController method event.
@Override
public void event(UserRequest ureq, Controller source, Event event) {
Wiki wiki = getWiki();
if (wiki == null) {
mainPanel.setContent(createVelocityContainer("deleted"));
return;
}
// reload page from cache
WikiPage page = wiki.getPage(pageId, true);
// set recent page id to the page currently used
this.pageId = page.getPageId();
if (event instanceof TreeEvent) {
TreeEvent te = (TreeEvent) event;
String nodeId = te.getNodeId();
if (navAZNode.getIdent().equals(nodeId)) {
openAtoZPage(ureq, wiki);
} else if (navChangesNode.getIdent().equals(nodeId)) {
openLastChangesPage(ureq, wiki);
} else if (navMainPageNode.getIdent().equals(nodeId)) {
page = openIndexPage(ureq, wiki);
} else if (wikiMenuNode.getIdent().equals(nodeId)) {
page = openPage(ureq, WikiPage.WIKI_MENU_PAGE, wiki);
} else {
TreeNode node = wikiMenuModel.getNodeById(nodeId);
if (node != null && node.getUserObject() instanceof String) {
String link = (String) node.getUserObject();
page = openPage(ureq, link, wiki);
}
}
if (page != null) {
this.pageId = page.getPageId();
}
} else if (source == versioningTableCtr) {
/**
***********************************************************************
* history table events
***********************************************************************
*/
if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
TableEvent te = (TableEvent) event;
if (te.getActionId().equals(ACTION_COMPARE)) {
selectedPage = versioningTableModel.getObject(te.getRowId());
diffs = wiki.getDiff(page, selectedPage.getVersion() - 1, selectedPage.getVersion());
versioningContent.contextPut("diffs", diffs);
versioningContent.remove(wikiVersionDisplayComp);
versioningContent.contextPut("page", selectedPage);
} else if (te.getActionId().equals(ACTION_SHOW)) {
versioningContent.contextRemove("diffs");
selectedPage = versioningTableModel.getObject(te.getRowId());
selectedPage = wiki.loadVersion(selectedPage, selectedPage.getVersion());
wikiVersionDisplayComp.setWikiContent(selectedPage.getContent());
wikiVersionDisplayComp.setImageMapperUri(ureq, wikiContainer);
versioningContent.put("versionDisplay", wikiVersionDisplayComp);
versioningContent.contextPut("page", selectedPage);
}
}
} else if (source == wikiUploadFileCtr) {
if (event.getCommand().equals(FolderEvent.UPLOAD_EVENT)) {
FolderEvent fEvent = (FolderEvent) event;
createMediaMetadataFile(fEvent.getFilename(), ureq.getIdentity().getKey());
updateFileAndLinkList(wiki);
}
cmc.deactivate();
cleanUp();
} else if (source == removePageDialogCtr) {
if (DialogBoxUIFactory.isOkEvent(event)) {
wiki.removePage(page);
breadcrumpDropdown.removeComponent(page.getPageName());
WikiManager.getInstance().deleteWikiPage(ores, page);
page = wiki.getPage(WikiPage.WIKI_INDEX_PAGE);
updatePageContext(ureq, page);
tabs.setSelectedPane(ureq, 0);
}
} else if (source == mediaTableCtr) {
if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
TableEvent te = (TableEvent) event;
if (te.getActionId().equals(ACTION_DELETE_MEDIA)) {
List<MediaFileElement> list = new ArrayList<MediaFileElement>(1);
list.add(mediaFilesTableModel.getObject(te.getRowId()));
deleteMediaFile(list, ureq);
} else if (te.getActionId().equals(ACTION_SHOW_MEDIA)) {
// show a selected file from the media folder
MediaFileElement element = mediaFilesTableModel.getObject(te.getRowId());
if (isImage(element.getFilename())) {
// show images inline
// as modal overlay
imageDisplay.contextPut("mediaElement", element);
imageDisplay.contextPut("imageUri", wikiArticleComp.getImageBaseUri());
removeAsListenerAndDispose(cmc);
cmc = new CloseableModalController(getWindowControl(), translate("close"), imageDisplay);
listenTo(cmc);
cmc.activate();
} else {
deliverMediaFile(ureq, element.getFilename());
}
}
} else if (event.getCommand().equals(Table.COMMAND_MULTISELECT)) {
TableMultiSelectEvent tmse = (TableMultiSelectEvent) event;
if (tmse.getAction().equals(ACTION_DELETE_MEDIAS)) {
deleteMediaFile(mediaFilesTableModel.getObjects(tmse.getSelection()), ureq);
updateFileAndLinkList(wiki);
}
}
} else if (source == archiveWikiDialogCtr) {
if (DialogBoxUIFactory.isOkEvent(event)) {
WikiToCPResource rsrc = new WikiToCPResource(ores, getIdentity(), getTranslator());
ureq.getDispatchResult().setResultingMediaResource(rsrc);
}
} else if (source == createArticleForm) {
calloutCtrl.deactivate();
String query = createArticleForm.getQuery();
if (!StringHelper.containsNonWhitespace(query)) {
query = WikiPage.WIKI_INDEX_PAGE;
}
page = wiki.findPage(query);
pageId = page.getPageId();
if (page.getPageName().equals(Wiki.NEW_PAGE)) {
setTabsEnabled(false);
}
page.incrementViewCount();
updatePageContext(ureq, page);
if (!page.getPageName().startsWith("O_")) {
Link pageLink = LinkFactory.createToolLink(page.getPageName(), "select-page", page.getPageName(), this);
breadcrumpDropdown.addComponent(pageLink);
}
tabs.setSelectedPane(ureq, 0);
} else if (source == wikiEditForm) {
// set recent page id to the page currently used
this.pageId = page.getPageId();
boolean wantPreview = false;
boolean wantSave = false;
boolean wantClose = false;
if (event == Event.CANCELLED_EVENT) {
wantClose = true;
} else if (event == Event.DONE_EVENT) {
wantSave = true;
} else if (event.getCommand().equals("save.and.close")) {
wantClose = true;
wantSave = true;
event = Event.DONE_EVENT;
} else if (event.getCommand().equals("preview")) {
wantPreview = true;
event = Event.DONE_EVENT;
} else if (event.getCommand().equals("delete.page")) {
String msg = translate("question", page.getPageName());
removePageDialogCtr = activateOkCancelDialog(ureq, null, msg, removePageDialogCtr);
return;
} else if (event.getCommand().equals("media.upload")) {
doUploadFiles(ureq);
return;
} else if (event.getCommand().equals("manage.media")) {
doManageMedias(ureq, wiki);
return;
}
boolean dirty = !wikiEditForm.getWikiContent().equals(page.getContent());
if (wantPreview) {
WikiPage preview = new WikiPage("temp");
preview.setContent(wikiEditForm.getWikiContent());
wikiVersionDisplayComp.setWikiContent(preview.getContent());
editContent.put("versionDisplay", wikiVersionDisplayComp);
}
if (wantSave && dirty) {
editContent.contextPut("isDirty", Boolean.valueOf(false));
page.setContent(wikiEditForm.getWikiContent());
page.setModifyAuthor(getIdentity().getKey().longValue());
page.setUpdateComment(wikiEditForm.getUpdateComment());
if (page.getInitalAuthor() == 0)
page.setInitalAuthor(getIdentity().getKey().longValue());
// changed
if (page.getPageName().equals(WikiPage.WIKI_MENU_PAGE)) {
updateWikiMenu(wiki);
}
WikiManager.getInstance().saveWikiPage(ores, page, true, wiki);
// inform subscription context about changes
NotificationsManager.getInstance().markPublisherNews(subsContext, ureq.getIdentity(), true);
updatePageContext(ureq, page);
}
if (dirty && wantPreview && !wantSave) {
// wikiEditForm.setDirty(true);
editContent.contextPut("isDirty", Boolean.valueOf(dirty));
}
if (wantClose) {
tabs.setSelectedPane(ureq, 0);
doReleaseEditLock();
return;
}
}
}
use of org.olat.core.gui.components.table.TableMultiSelectEvent 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.core.gui.components.table.TableMultiSelectEvent in project OpenOLAT by OpenOLAT.
the class ViteroUserToGroupController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (source == tableCtr) {
if (event instanceof TableEvent) {
TableEvent e = (TableEvent) event;
int row = e.getRowId();
Identity identity = (Identity) tableCtr.getTableDataModel().getObject(row);
if ("signin".equals(e.getActionId())) {
signIn(Collections.singletonList(identity));
} else if ("signout".equals(e.getActionId())) {
signOut(Collections.singletonList(identity));
}
} else if (event instanceof TableMultiSelectEvent) {
TableMultiSelectEvent e = (TableMultiSelectEvent) event;
List<Identity> identities = new ArrayList<Identity>();
for (int i = e.getSelection().nextSetBit(0); i >= 0; i = e.getSelection().nextSetBit(i + 1)) {
Identity identity = (Identity) tableCtr.getTableDataModel().getObject(i);
identities.add(identity);
}
if ("signin".equals(e.getAction())) {
signIn(identities);
} else if ("signout".equals(e.getAction())) {
signOut(identities);
} else if ("reload".equals(e.getAction())) {
loadModel();
}
}
}
super.event(ureq, source, event);
}
Aggregations