use of org.olat.core.gui.components.table.TableEvent in project openolat by klemens.
the class DENManageParticipantsController method event.
@Override
public void event(UserRequest ureq, Controller source, Event event) {
if (source == tableListParticipants) {
if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
TableEvent tableEvent = (TableEvent) event;
// open window for choosen date to manage the enrolled users or manually add
if (tableEvent.getActionId().equals(DENListTableDataModel.CHANGE_ACTION)) {
selectedEvent = listTableData.getObject(tableEvent.getRowId());
List<Identity> participants = denManager.getEventParticipants(selectedEvent);
participantsTableData = new DENParticipantsTableDataModel(participants);
removeAsListenerAndDispose(tableManageParticipants);
tableManageParticipants = denManager.createParticipantsTable(ureq, getWindowControl(), getTranslator(), participantsTableData);
listenTo(tableManageParticipants);
participantsVC = createVelocityContainer("participants");
DateFormat df = new SimpleDateFormat();
participantsVC.contextPut("dateTitle", selectedEvent.getSubject());
participantsVC.contextPut("dateTimeframe", df.format(selectedEvent.getBegin()) + " - " + df.format(selectedEvent.getEnd()));
participantsVC.put("participantsTable", tableManageParticipants.getInitialComponent());
addParticipantButton = LinkFactory.createButton("participants.add", participantsVC, this);
removeAsListenerAndDispose(manageParticipantsModalCntrl);
manageParticipantsModalCntrl = new CloseableModalController(getWindowControl(), "close", participantsVC, true, translate("dates.table.participant.manage"));
listenTo(manageParticipantsModalCntrl);
manageParticipantsModalCntrl.activate();
}
} else {
TableMultiSelectEvent tmse = (TableMultiSelectEvent) event;
BitSet selection = tmse.getSelection();
// delete all users from the selected dates
if (tmse.getAction().equals(DENListTableDataModel.DELETE_ACTION) && selection.cardinality() > 0) {
selectedIds = denManager.getSelectedEventParticipants(dateList, selection);
dateList = denManager.deleteParticipants(ores, courseNode, denManager.getSelectedEventIDs(dateList, selection));
listTableData.setObjects(dateList);
// send notification mail
createNotificationMail(ureq, courseNode.getShortTitle(), REMOVE_ACTION);
} else if (tmse.getAction().equals(DENListTableDataModel.MAIL_ACTION) && selection.cardinality() > 0) {
// send email to all users from the selected dates
List<Identity> participants = denManager.getSelectedEventParticipants(dateList, selection);
createParticipantsMail(ureq, participants);
} else if (selection.cardinality() == 0) {
showWarning("participants.message.empty");
}
}
} else if (source == userSearchCntrl) {
if (event == Event.CANCELLED_EVENT) {
userSearchCMC.deactivate();
} else {
List<Identity> toAdd = null;
selectedIds = new ArrayList<Identity>();
if (event instanceof SingleIdentityChosenEvent) {
SingleIdentityChosenEvent singleEvent = (SingleIdentityChosenEvent) event;
Identity choosenIdentity = singleEvent.getChosenIdentity();
toAdd = new ArrayList<Identity>();
toAdd.add(choosenIdentity);
} else if (event instanceof MultiIdentityChosenEvent) {
MultiIdentityChosenEvent multiEvent = (MultiIdentityChosenEvent) event;
toAdd = multiEvent.getChosenIdentities();
}
boolean showMessage = false;
if (toAdd != null && toAdd.size() > 0) {
for (Identity identity : toAdd) {
status = denManager.doEnroll(identity, selectedEvent, ores, courseNode, true);
if (!status.isEnrolled() && status.getErrorMessage().equals(DENStatus.ERROR_ALREADY_ENROLLED))
showMessage = true;
else
selectedIds.add(identity);
}
if (showMessage)
showWarning("enrollment.warning.manual");
refreshTables();
}
userSearchCMC.deactivate();
if (selectedIds.size() > 0) {
// write notification mail
createNotificationMail(ureq, selectedEvent.getSubject(), ADD_ACTION);
}
}
} else if (source == tableManageParticipants) {
if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
TableEvent tableEvent = (TableEvent) event;
// delete single user from event
if (tableEvent.getActionId().equals(DENParticipantsTableDataModel.REMOVE_ACTION)) {
Identity identity = participantsTableData.getEntryAt(tableEvent.getRowId());
status = denManager.cancelEnroll(identity, selectedEvent, ores);
if (!status.isCancelled())
showError();
else // send notification mail
{
selectedIds.clear();
selectedIds.add(identity);
createNotificationMail(ureq, selectedEvent.getSubject(), REMOVE_ACTION);
}
refreshTables();
// write email to single user
} else if (tableEvent.getActionId().equals(DENParticipantsTableDataModel.MAIL_ACTION)) {
List<Identity> participants = new ArrayList<Identity>();
participants.add(participantsTableData.getEntryAt(tableEvent.getRowId()));
createParticipantsMail(ureq, participants);
}
}
} else if (source == notificationCtr && event == Event.DONE_EVENT) {
if (notificationCtr.getMailTemplate() != null) {
Identity sender = ureq.getIdentity();
MailerResult result = new MailerResult();
String metaId = UUID.randomUUID().toString().replace("-", "");
MailContext context = new MailContextImpl(getWindowControl().getBusinessControl().getAsString());
MailBundle[] bundles = mailManager.makeMailBundles(context, selectedIds, notificationCtr.getMailTemplate(), sender, metaId, result);
result.append(mailManager.sendMessage(bundles));
if (notificationCtr.getMailTemplate().getCpfrom()) {
MailBundle ccBundles = mailManager.makeMailBundle(context, sender, notificationCtr.getMailTemplate(), sender, metaId, result);
result.append(mailManager.sendMessage(ccBundles));
}
MailHelper.printErrorsAndWarnings(result, getWindowControl(), ureq.getUserSession().getRoles().isOLATAdmin(), ureq.getLocale());
}
notificationCmc.deactivate();
selectedIds.clear();
} else if (source == contactCtr) {
notificationCmc.deactivate();
}
}
use of org.olat.core.gui.components.table.TableEvent in project openolat by klemens.
the class AllCachesController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (source == tableCtr) {
if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
TableEvent te = (TableEvent) event;
String actionid = te.getActionId();
if (actionid.equals("empty")) {
Object cacheInfos = tableCtr.getTableDataModel().getObject(te.getRowId());
dc = activateYesNoDialog(ureq, null, translate("confirm.emptycache"), dc);
dc.setUserObject(cacheInfos);
}
}
} else if (source == dc) {
if (DialogBoxUIFactory.isYesEvent(event)) {
String cacheName = null;
try {
CacheInfos cacheInfos = (CacheInfos) dc.getUserObject();
cacheInfos.clear();
loadModel();
} catch (IllegalStateException e) {
log.error("Cannot remove Cache:" + cacheName, e);
}
}
}
}
use of org.olat.core.gui.components.table.TableEvent in project openolat by klemens.
the class GroupChoiceForm method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (source == manageChecklistTable) {
if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
TableEvent tableEvent = (TableEvent) event;
Long identityKey = manageTableData.getParticipantKeyAt(tableEvent.getRowId());
selectedIdentity = securityManager.loadIdentityByKey(identityKey, false);
if (tableEvent.getActionId().equals(EDIT_ACTION)) {
initEditTable(ureq, selectedIdentity);
VelocityContainer vcManageUser = createVelocityContainer("manageUser");
vcManageUser.put("table", editChecklistTable.getInitialComponent());
String name = selectedIdentity.getUser().getProperty(UserConstants.FIRSTNAME, getLocale()) + " " + selectedIdentity.getUser().getProperty(UserConstants.LASTNAME, getLocale());
visitingCardButton = LinkFactory.createLink("cl.manage.user.visitingcard", vcManageUser, this);
visitingCardButton.setCustomDisplayText(name);
removeAsListenerAndDispose(cmc);
cmc = new CloseableModalController(getWindowControl(), translate("cl.close"), vcManageUser, true, translate("cl.edit.title"));
listenTo(cmc);
cmc.activate();
} else if (tableEvent.getActionId().equals(DETAILS_ACTION)) {
openVisitingCard(ureq);
}
}
} else if (source == editChecklistTable) {
if (event instanceof TableMultiSelectEvent) {
TableMultiSelectEvent tmse = (TableMultiSelectEvent) event;
if (tmse.getAction().equals("save")) {
BitSet selection = tmse.getSelection();
updateCheckpointsFor(selectedIdentity, selection);
initManageTable(ureq);
}
cmc.deactivate();
}
} else if (source == groupForm) {
if (event == Event.CHANGED_EVENT) {
initManageTable(ureq);
} else if (event.getCommand().equals(GroupChoiceForm.EXPORT_TABLE)) {
downloadResults(ureq);
}
}
}
use of org.olat.core.gui.components.table.TableEvent in project openolat by klemens.
the class LockController 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;
LockEntry lockToRelease = locksTableModel.getObject(te.getRowId());
dialogController = activateYesNoDialog(ureq, null, translate("lock.release.sure"), dialogController);
dialogController.setUserObject(lockToRelease);
}
} else if (source == dialogController) {
if (DialogBoxUIFactory.isYesEvent(event)) {
LockEntry lockToRelease = (LockEntry) dialogController.getUserObject();
MultiUserEvent mue = new LockRemovedEvent(lockToRelease);
OLATResourceable lockEntryOres = OresHelper.createOLATResourceableInstance(LockEntry.class, 0l);
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(mue, lockEntryOres);
CoordinatorManager.getInstance().getCoordinator().getLocker().releaseLockEntry(lockToRelease);
lockToRelease = null;
resetTableModel();
}
}
}
use of org.olat.core.gui.components.table.TableEvent in project OpenOLAT by OpenOLAT.
the class RevisionListController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (source == revisionListTableCtr) {
if (event instanceof TableEvent) {
TableEvent tEvent = (TableEvent) event;
int row = tEvent.getRowId();
if (CMD_DOWNLOAD.equals(tEvent.getActionId())) {
MediaResource resource;
if (row < versionedFile.getVersions().getRevisions().size()) {
// restore current, do nothing
VFSRevision version = versionedFile.getVersions().getRevisions().get(row);
resource = new VFSRevisionMediaResource(version, true);
} else {
resource = new VFSMediaResource((VFSLeaf) versionedFile);
((VFSMediaResource) resource).setDownloadable(true);
}
ureq.getDispatchResult().setResultingMediaResource(resource);
} else if (CMD_RESTORE.equals(tEvent.getActionId())) {
if (row >= versionedFile.getVersions().getRevisions().size()) {
// restore current, do nothing
status = FolderCommandStatus.STATUS_SUCCESS;
fireEvent(ureq, FolderCommand.FOLDERCOMMAND_FINISHED);
} else {
VFSRevision version = versionedFile.getVersions().getRevisions().get(row);
String comment = translate("version.restore.comment", new String[] { version.getRevisionNr() });
if (versionedFile.getVersions().restore(ureq.getIdentity(), version, comment)) {
status = FolderCommandStatus.STATUS_SUCCESS;
fireEvent(ureq, FolderCommand.FOLDERCOMMAND_FINISHED);
} else {
status = FolderCommandStatus.STATUS_FAILED;
showError("version.restore.failed");
fireEvent(ureq, FolderCommand.FOLDERCOMMAND_FINISHED);
}
}
}
} else if (event instanceof TableMultiSelectEvent) {
TableMultiSelectEvent tEvent = (TableMultiSelectEvent) event;
if (CMD_CANCEL.equals(tEvent.getAction())) {
status = FolderCommandStatus.STATUS_CANCELED;
fireEvent(ureq, FolderCommand.FOLDERCOMMAND_FINISHED);
} else {
List<VFSRevision> selectedVersions = getSelectedRevisions(tEvent.getSelection());
if (!selectedVersions.isEmpty()) {
if (CMD_DELETE.equals(tEvent.getAction())) {
String numOfVersionToDelete = Integer.toString(selectedVersions.size());
confirmDeleteBoxCtr = activateYesNoDialog(ureq, null, translate("version.confirmDelete", new String[] { numOfVersionToDelete }), confirmDeleteBoxCtr);
confirmDeleteBoxCtr.setUserObject(selectedVersions);
}
}
}
}
} else if (source == confirmDeleteBoxCtr) {
if (DialogBoxUIFactory.isYesEvent(event)) {
@SuppressWarnings("unchecked") List<VFSRevision> selectedVersions = (List<VFSRevision>) confirmDeleteBoxCtr.getUserObject();
versionedFile.getVersions().delete(ureq.getIdentity(), selectedVersions);
status = FolderCommandStatus.STATUS_SUCCESS;
} else {
status = FolderCommandStatus.STATUS_CANCELED;
}
fireEvent(ureq, FolderCommand.FOLDERCOMMAND_FINISHED);
}
}
Aggregations