Search in sources :

Example 26 with TableEvent

use of org.olat.core.gui.components.table.TableEvent in project OpenOLAT by OpenOLAT.

the class NotificationsPortletRunController method event.

/**
 * @see org.olat.core.gui.control.ControllerEventListener#dispatchEvent(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) {
    super.event(ureq, source, event);
    if (source == tableCtr) {
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent te = (TableEvent) event;
            String actionid = te.getActionId();
            if (actionid.equals(CMD_LAUNCH)) {
                int rowid = te.getRowId();
                Subscriber sub = notificationListModel.getSubscriberAt(rowid);
                if (actionid.equals(CMD_LAUNCH)) {
                    NotificationUIFactory.launchSubscriptionResource(ureq, getWindowControl(), sub);
                }
            }
        }
    }
}
Also used : TableEvent(org.olat.core.gui.components.table.TableEvent) Subscriber(org.olat.core.commons.services.notifications.Subscriber)

Example 27 with TableEvent

use of org.olat.core.gui.components.table.TableEvent in project OpenOLAT by OpenOLAT.

the class MailListController 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();
            int rowid = te.getRowId();
            DBMailLight mail = (DBMailLight) tableCtr.getTableDataModel().getObject(rowid);
            if (CMD_READ.equals(actionid)) {
                if (outbox && StringHelper.containsNonWhitespace(mail.getMetaId()) && !mail.getMetaId().equals(metaId)) {
                    selectMetaMail(ureq, mail.getMetaId());
                } else {
                    selectMail(ureq, mail.getKey());
                }
            } else if (CMD_PROFILE.equals(actionid)) {
                DBMailRecipient from = mail.getFrom();
                if (from != null && from.getRecipient() != null) {
                    contextResolver.open(ureq, getWindowControl(), "[Identity:" + from.getRecipient().getKey() + "]");
                }
            } else if (CMD_MARK_TOGGLE.equals(actionid)) {
                mail = mailManager.toggleMarked(mail, getIdentity());
                replaceInModel(mail);
            } else if (CMD_READ_TOGGLE.equals(actionid)) {
                mail = mailManager.toggleRead(mail, getIdentity());
                replaceInModel(mail);
            }
        } else if (event.getCommand().equals(Table.COMMAND_MULTISELECT)) {
            // Multiselect events
            TableMultiSelectEvent tmse = (TableMultiSelectEvent) event;
            BitSet selectedMails = tmse.getSelection();
            if (selectedMails.isEmpty()) {
                tableVC.setDirty(true);
                showWarning("mail.action.emtpy");
                return;
            }
            String actionid = tmse.getAction();
            if (CMD_DELETE.equals(actionid)) {
                String title = translate("mail.confirm.delete.title");
                int selected = selectedMails.cardinality();
                String text;
                if (selected == 1) {
                    text = translate("mail.confirm.delete.single.text");
                } else {
                    text = translate("mail.confirm.delete.multi.text", selected + "");
                }
                deleteConfirmationBox = activateYesNoDialog(ureq, title, text, deleteConfirmationBox);
                deleteConfirmationBox.setUserObject(selectedMails);
            } else if (CMD_SEND_REAL_MAIL.equals(actionid)) {
                for (int i = selectedMails.nextSetBit(0); i >= 0; i = selectedMails.nextSetBit(i + 1)) {
                    DBMailLight mail = (DBMailLight) tableCtr.getTableDataModel().getObject(i);
                    MailerResult result = forwardToMyRealMail(mail);
                    if (result.getReturnCode() != MailerResult.OK) {
                        MailHelper.printErrorsAndWarnings(result, getWindowControl(), ureq.getUserSession().getRoles().isOLATAdmin(), getLocale());
                    } else {
                        showInfo("mail.action.send.real.success", mail.getSubject());
                    }
                }
                reloadModel();
            } else if (CMD_MARK_MARKED.equals(actionid) || CMD_MARK_UNMARKED.equals(actionid)) {
                for (int i = selectedMails.nextSetBit(0); i >= 0; i = selectedMails.nextSetBit(i + 1)) {
                    DBMailLight mail = (DBMailLight) tableCtr.getTableDataModel().getObject(i);
                    mailManager.setMarked(mail, CMD_MARK_MARKED.equals(actionid), getIdentity());
                }
                reloadModel();
            } else if (CMD_MARK_READ.equals(actionid) || CMD_MARK_UNREAD.equals(actionid)) {
                for (int i = selectedMails.nextSetBit(0); i >= 0; i = selectedMails.nextSetBit(i + 1)) {
                    DBMailLight mail = (DBMailLight) tableCtr.getTableDataModel().getObject(i);
                    mailManager.setRead(mail, CMD_MARK_READ.equals(actionid), getIdentity());
                }
                reloadModel();
            }
        } else if (TableController.EVENT_FILTER_SELECTED == event) {
            MailDataModel dataModel = (MailDataModel) tableCtr.getTableDataModel();
            MailContextShortName filter = (MailContextShortName) tableCtr.getActiveFilter();
            dataModel.filter(filter);
            tableCtr.setTableDataModel(dataModel);
        } else if (TableController.EVENT_NOFILTER_SELECTED == event) {
            MailDataModel dataModel = (MailDataModel) tableCtr.getTableDataModel();
            dataModel.filter(null);
            tableCtr.setTableDataModel(dataModel);
        }
    } else if (source == mailCtr) {
        backFromMail();
    } else if (source == metaMailCtr) {
        removeAsListenerAndDispose(metaMailCtr);
        metaMailCtr = null;
        mainVC.put(MAIN_CMP, tableVC);
    } else if (source == deleteConfirmationBox) {
        if (DialogBoxUIFactory.isYesEvent(event)) {
            BitSet deleteMails = (BitSet) deleteConfirmationBox.getUserObject();
            for (int i = deleteMails.nextSetBit(0); i >= 0; i = deleteMails.nextSetBit(i + 1)) {
                DBMailLight mail = (DBMailLight) tableCtr.getTableDataModel().getObject(i);
                // reload the message
                mail = mailManager.getMessageByKey(mail.getKey());
                boolean deleteMetaMail = outbox && !StringHelper.containsNonWhitespace(metaId);
                mailManager.delete(mail, getIdentity(), deleteMetaMail);
            // Do not remove from model to prevent concurrent modification
            // exception, instead just reload model afterwards
            }
            reloadModel();
        }
    } else {
        super.event(ureq, source, event);
    }
}
Also used : TableEvent(org.olat.core.gui.components.table.TableEvent) MailerResult(org.olat.core.util.mail.MailerResult) TableMultiSelectEvent(org.olat.core.gui.components.table.TableMultiSelectEvent) BitSet(java.util.BitSet) DBMailLight(org.olat.core.util.mail.model.DBMailLight) DBMailRecipient(org.olat.core.util.mail.model.DBMailRecipient)

Example 28 with TableEvent

use of org.olat.core.gui.components.table.TableEvent in project OpenOLAT by OpenOLAT.

the class CourseAreasController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (tableCtrl == source) {
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent te = (TableEvent) event;
            String actionid = te.getActionId();
            if (TABLE_ACTION_EDIT.equals(actionid)) {
                BGArea area = areaDataModel.getObject(te.getRowId());
                doEdit(ureq, area);
            } else if (TABLE_ACTION_DELETE.equals(actionid)) {
                BGArea area = areaDataModel.getObject(te.getRowId());
                String text = translate("delete.area.description", new String[] { area.getName() });
                deleteDialogCtr = activateYesNoDialog(ureq, translate("delete.area.title"), text, deleteDialogCtr);
                deleteDialogCtr.setUserObject(area);
            }
        }
    } else if (source == deleteDialogCtr) {
        if (DialogBoxUIFactory.isYesEvent(event)) {
            // yes case
            BGArea area = (BGArea) deleteDialogCtr.getUserObject();
            doDelete(area);
        }
    } else if (source == newAreaController) {
        if (event == Event.CANCELLED_EVENT) {
            mainPanel.popContent();
        } else if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            BGArea area = newAreaController.getCreatedArea();
            loadModel();
            mainPanel.popContent();
            doEdit(ureq, area);
            removeAsListenerAndDispose(newAreaController);
            newAreaController = null;
            createVC = null;
        }
    } else if (source == editController) {
        if (event == Event.BACK_EVENT) {
            mainPanel.popContent();
            removeAsListenerAndDispose(editController);
            editController = null;
        }
    }
    super.event(ureq, source, event);
}
Also used : TableEvent(org.olat.core.gui.components.table.TableEvent) BGArea(org.olat.group.area.BGArea)

Example 29 with TableEvent

use of org.olat.core.gui.components.table.TableEvent in project OpenOLAT by OpenOLAT.

the class DENRunController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (runDENTable == source) {
        // the link to enroll or cancel enrollment is clicked
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent tableEvent = (TableEvent) event;
            KalendarEvent calEvent = runTableData.getObject(tableEvent.getRowId());
            if (tableEvent.getActionId().equals(DENRunTableDataModel.CMD_ENROLL_IN_DATE)) {
                // do enroll
                status = denManager.doEnroll(ureq.getIdentity(), calEvent, ores, courseNode);
                if (!status.isEnrolled())
                    showError();
            } else if (tableEvent.getActionId().equals(DENRunTableDataModel.CMD_ENROLLED_CANCEL)) {
                // cancel enrollment
                status = denManager.cancelEnroll(ureq.getIdentity(), calEvent, ores);
                if (!status.isCancelled())
                    showError();
            }
            createOrUpdateDateTable(ureq, courseNode);
            runDENTable.setTableDataModel(runTableData);
            fireEvent(ureq, Event.DONE_EVENT);
            // inform subscription context about changes
            NotificationsManager.getInstance().markPublisherNews(subsContext, ureq.getIdentity(), true);
        // </OPAL-122>
        }
    }
}
Also used : TableEvent(org.olat.core.gui.components.table.TableEvent) KalendarEvent(org.olat.commons.calendar.model.KalendarEvent)

Example 30 with TableEvent

use of org.olat.core.gui.components.table.TableEvent in project OpenOLAT by OpenOLAT.

the class SelectionForm 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();
                UserDeletionManager.getInstance().setIdentityAsActiv(tdm.getObject(rowid));
            }
        } else if (event.getCommand().equals(Table.COMMAND_MULTISELECT)) {
            TableMultiSelectEvent tmse = (TableMultiSelectEvent) event;
            if (tmse.getAction().equals(ACTION_MULTISELECT_CHOOSE)) {
                handleEmailButtonEvent(ureq, tmse);
            }
        }
        initializeContent();
    } else if (source == deleteUserMailCtr) {
        if (event == Event.DONE_EVENT) {
            String warningMessage = UserDeletionManager.getInstance().sendUserDeleteEmailTo(selectedIdentities, deleteUserMailCtr.getMailTemplate(), deleteUserMailCtr.isTemplateChanged(), KEY_EMAIL_SUBJECT, KEY_EMAIL_BODY, ureq.getIdentity(), getTranslator());
            cmc.deactivate();
            if (deleteUserMailCtr.getMailTemplate() != null) {
                // when mailtemplate is null, user decides to send no email => no status message
                if (warningMessage.length() > 0) {
                    this.showWarning("delete.email.announcement.warning.header", warningMessage);
                } else {
                    this.showInfo("selection.feedback.msg");
                }
            }
            initializeContent();
        } else if (event == Event.CANCELLED_EVENT) {
            cmc.deactivate();
        } else {
            throw new RuntimeException("unknown event ::" + event.getCommand());
        }
    } else if (source == selectionForm) {
        if (event == Event.DONE_EVENT) {
            UserDeletionManager.getInstance().setLastLoginDuration(selectionForm.getLastLoginDuration());
            UserDeletionManager.getInstance().setDeleteEmailDuration(selectionForm.getDeleteEmailDuration());
            initializeContent();
        } else if (event == Event.CANCELLED_EVENT) {
            fireEvent(ureq, Event.CANCELLED_EVENT);
        }
        cmc.deactivate();
        removeAsListenerAndDispose(selectionForm);
        removeAsListenerAndDispose(cmc);
    }
}
Also used : TableEvent(org.olat.core.gui.components.table.TableEvent) TableMultiSelectEvent(org.olat.core.gui.components.table.TableMultiSelectEvent)

Aggregations

TableEvent (org.olat.core.gui.components.table.TableEvent)114 ArrayList (java.util.ArrayList)42 List (java.util.List)40 TableMultiSelectEvent (org.olat.core.gui.components.table.TableMultiSelectEvent)40 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)16 Identity (org.olat.core.id.Identity)16 BitSet (java.util.BitSet)12 WindowControl (org.olat.core.gui.control.WindowControl)12 SingleIdentityChosenEvent (org.olat.basesecurity.events.SingleIdentityChosenEvent)10 UserRequest (org.olat.core.gui.UserRequest)10 ControllerCreator (org.olat.core.gui.control.creator.ControllerCreator)10 PopupBrowserWindow (org.olat.core.gui.control.generic.popup.PopupBrowserWindow)10 MultiIdentityChosenEvent (org.olat.basesecurity.events.MultiIdentityChosenEvent)8 BusinessGroup (org.olat.group.BusinessGroup)8 RepositoryEntry (org.olat.repository.RepositoryEntry)8 AssertException (org.olat.core.logging.AssertException)6 UserInfoMainController (org.olat.user.UserInfoMainController)6 KalendarEvent (org.olat.commons.calendar.model.KalendarEvent)4 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)4 Subscriber (org.olat.core.commons.services.notifications.Subscriber)4