Search in sources :

Example 26 with TableMultiSelectEvent

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

the class DENManageDatesController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    ICourse course = CourseFactory.loadCourse(ores);
    if (manageDatesForm == source) {
        // generate the dates and put them into the table
        editTableDataList = denManager.generateDates(manageDatesForm.getSubject(), manageDatesForm.getComment(), manageDatesForm.getLocation(), manageDatesForm.getDuration(), manageDatesForm.getPause(), manageDatesForm.getBeginDate(), manageDatesForm.getRetakes(), manageDatesForm.getNumParts(), editTableDataList, denCourseNode.getIdent());
        denManager.persistDENSettings(editTableDataList, course, denCourseNode);
        editDENTable.setTableDataModel(editTableData);
    } else if (source == editDENTable) {
        TableMultiSelectEvent tmse = (TableMultiSelectEvent) event;
        selectedDates = tmse.getSelection();
        // clicked button to edit one date or more dates
        if (tmse.getAction().equals(DENEditTableDataModel.CHANGE_ACTION) && selectedDates.cardinality() > 0) {
            if (selectedDates.cardinality() == 1) {
                // if only one date is choosen, we can prefill some entries
                removeAsListenerAndDispose(editSingleDateForm);
                editSingleDateForm = new DENDatesForm(ureq, getWindowControl(), getTranslator(), DENDatesForm.EDIT_SINGLE_DATE_LAYOUT);
                listenTo(editSingleDateForm);
                // in this case only one date is possible
                KalendarEvent calEvent = editTableData.getObjects(selectedDates).get(0);
                editSingleDateForm.setSubject(calEvent.getSubject());
                editSingleDateForm.setComment(calEvent.getComment());
                editSingleDateForm.setLocation(calEvent.getLocation());
                editSingleDateForm.setNumParts(calEvent.getNumParticipants());
                editSingleDateForm.setFormDate(calEvent.getBegin());
                editSingleDateForm.setDuration(denManager.getDurationAsString(calEvent));
                removeAsListenerAndDispose(editDateModalCntrll);
                editDateModalCntrll = new CloseableModalController(getWindowControl(), "close", editSingleDateForm.getInitialComponent(), true, translate("dates.edit"));
                listenTo(editDateModalCntrll);
            } else if (selectedDates.cardinality() > 1) {
                removeAsListenerAndDispose(editMultipleDatesForm);
                editMultipleDatesForm = new DENDatesForm(ureq, getWindowControl(), getTranslator(), DENDatesForm.EDIT_MULTIPLE_DATES_LAYOUT);
                listenTo(editMultipleDatesForm);
                removeAsListenerAndDispose(editDateModalCntrll);
                editDateModalCntrll = new CloseableModalController(getWindowControl(), "close", editMultipleDatesForm.getInitialComponent(), true, translate("dates.edit"));
                listenTo(editDateModalCntrll);
            }
            // persist dates
            denManager.persistDENSettings(editTableData.getObjects(), course, denCourseNode);
            editDateModalCntrll.activate();
        } else if (tmse.getAction().equals(DENEditTableDataModel.DELETE_ACTION)) {
            // delete selected dates
            editTableData.removeEntries(tmse.getSelection());
            editDENTable.setTableDataModel(editTableData);
            // persist dates
            denManager.persistDENSettings(editTableData.getObjects(), course, denCourseNode);
        }
    } else if (source == editSingleDateForm) {
        // save changes for one date
        editTableData.setObjects(denManager.updateDateInList(editSingleDateForm.getSubject(), editSingleDateForm.getComment(), editSingleDateForm.getLocation(), editSingleDateForm.getDuration(), editSingleDateForm.getBeginDate(), editSingleDateForm.getNumParts(), editTableData.getObjects(), // only one bit is set
        selectedDates.nextSetBit(0)));
        editDENTable.setTableDataModel(editTableData);
        denManager.persistDENSettings(editTableData.getObjects(), course, denCourseNode);
        editDateModalCntrll.deactivate();
    } else if (source == editMultipleDatesForm) {
        // save changes for multiple dates
        editTableData.setObjects(denManager.updateMultipleDatesInList(editMultipleDatesForm.getSubject(), editMultipleDatesForm.getComment(), editMultipleDatesForm.getLocation(), editMultipleDatesForm.getMovementGap(), editMultipleDatesForm.getNumParts(), editTableData.getObjects(), selectedDates));
        editDENTable.setTableDataModel(editTableData);
        denManager.persistDENSettings(editTableData.getObjects(), course, denCourseNode);
        editDateModalCntrll.deactivate();
    }
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) TableMultiSelectEvent(org.olat.core.gui.components.table.TableMultiSelectEvent) KalendarEvent(org.olat.commons.calendar.model.KalendarEvent) ICourse(org.olat.course.ICourse)

Example 27 with TableMultiSelectEvent

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

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);
        }
    }
}
Also used : TableEvent(org.olat.core.gui.components.table.TableEvent) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) TableMultiSelectEvent(org.olat.core.gui.components.table.TableMultiSelectEvent) BitSet(java.util.BitSet) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer)

Example 28 with TableMultiSelectEvent

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

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();
    }
}
Also used : MailContextImpl(org.olat.core.util.mail.MailContextImpl) MailerResult(org.olat.core.util.mail.MailerResult) MailContext(org.olat.core.util.mail.MailContext) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) TableMultiSelectEvent(org.olat.core.gui.components.table.TableMultiSelectEvent) BitSet(java.util.BitSet) ArrayList(java.util.ArrayList) TableEvent(org.olat.core.gui.components.table.TableEvent) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) SingleIdentityChosenEvent(org.olat.basesecurity.events.SingleIdentityChosenEvent) ArrayList(java.util.ArrayList) ContactList(org.olat.core.util.mail.ContactList) List(java.util.List) Identity(org.olat.core.id.Identity) MultiIdentityChosenEvent(org.olat.basesecurity.events.MultiIdentityChosenEvent) MailBundle(org.olat.core.util.mail.MailBundle) SimpleDateFormat(java.text.SimpleDateFormat)

Example 29 with TableMultiSelectEvent

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)
 */
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 (securityManager.isIdentityInSecurityGroup(toAdd.get(0), securityGroup)) {
                    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 (securityManager.isIdentityInSecurityGroup(toAdd.get(i), securityGroup)) {
                        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();
            }
        }
    }
}
Also used : AssertException(org.olat.core.logging.AssertException) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) TableMultiSelectEvent(org.olat.core.gui.components.table.TableMultiSelectEvent) WindowControl(org.olat.core.gui.control.WindowControl) ControllerCreator(org.olat.core.gui.control.creator.ControllerCreator) TableEvent(org.olat.core.gui.components.table.TableEvent) UserInfoMainController(org.olat.user.UserInfoMainController) PopupBrowserWindow(org.olat.core.gui.control.generic.popup.PopupBrowserWindow) MailTemplate(org.olat.core.util.mail.MailTemplate) SingleIdentityChosenEvent(org.olat.basesecurity.events.SingleIdentityChosenEvent) List(java.util.List) ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity) MailNotificationEditController(org.olat.core.util.mail.MailNotificationEditController) MultiIdentityChosenEvent(org.olat.basesecurity.events.MultiIdentityChosenEvent) UserRequest(org.olat.core.gui.UserRequest)

Example 30 with TableMultiSelectEvent

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

the class OrphanVersionsController 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();
            OrphanVersion orphan = (OrphanVersion) tableCtr.getTableDataModel().getObject(rowid);
            if (actionid.equals(CMD_DELETE)) {
                VersionsManager.getInstance().delete(orphan);
                orphans.remove(orphan);
                tableCtr.modelChanged();
            }
        } else if (event.getCommand().equals(Table.COMMAND_MULTISELECT)) {
            // Multiselect events
            TableMultiSelectEvent tmse = (TableMultiSelectEvent) event;
            BitSet selectedOrphans = tmse.getSelection();
            String actionid = tmse.getAction();
            if (CMD_DELETE.equals(actionid)) {
                List<OrphanVersion> toRemove = new ArrayList<OrphanVersion>();
                for (int i = selectedOrphans.nextSetBit(0); i >= 0; i = selectedOrphans.nextSetBit(i + 1)) {
                    int rowCount = tableCtr.getTableDataModel().getRowCount();
                    if (i >= 0 && i < rowCount) {
                        OrphanVersion orphan = (OrphanVersion) tableCtr.getTableDataModel().getObject(i);
                        VersionsManager.getInstance().delete(orphan);
                        toRemove.add(orphan);
                    }
                }
                for (OrphanVersion orphan : toRemove) {
                    orphans.remove(orphan);
                }
                tableCtr.setTableDataModel(new OrphanTableModel(orphans));
                tableCtr.modelChanged();
            }
        }
    }
}
Also used : TableEvent(org.olat.core.gui.components.table.TableEvent) TableMultiSelectEvent(org.olat.core.gui.components.table.TableMultiSelectEvent) BitSet(java.util.BitSet) ArrayList(java.util.ArrayList) List(java.util.List) OrphanVersion(org.olat.core.util.vfs.version.OrphanVersion)

Aggregations

TableMultiSelectEvent (org.olat.core.gui.components.table.TableMultiSelectEvent)48 TableEvent (org.olat.core.gui.components.table.TableEvent)40 ArrayList (java.util.ArrayList)34 List (java.util.List)34 Identity (org.olat.core.id.Identity)18 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)16 BitSet (java.util.BitSet)12 SingleIdentityChosenEvent (org.olat.basesecurity.events.SingleIdentityChosenEvent)10 MultiIdentityChosenEvent (org.olat.basesecurity.events.MultiIdentityChosenEvent)8 UserRequest (org.olat.core.gui.UserRequest)6 WindowControl (org.olat.core.gui.control.WindowControl)6 ControllerCreator (org.olat.core.gui.control.creator.ControllerCreator)6 PopupBrowserWindow (org.olat.core.gui.control.generic.popup.PopupBrowserWindow)6 MailNotificationEditController (org.olat.core.util.mail.MailNotificationEditController)6 MailTemplate (org.olat.core.util.mail.MailTemplate)6 UserInfoMainController (org.olat.user.UserInfoMainController)6 MediaResource (org.olat.core.gui.media.MediaResource)4 AssertException (org.olat.core.logging.AssertException)4 MailerResult (org.olat.core.util.mail.MailerResult)4 VFSRevisionMediaResource (org.olat.core.util.vfs.VFSRevisionMediaResource)4