Search in sources :

Example 46 with TableEvent

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

the class BusinessGroupEditResourceController 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 source, Event event) {
    if (source == repoSearchCtr) {
        if (event == ReferencableEntriesSearchController.EVENT_REPOSITORY_ENTRY_SELECTED) {
            // repository search controller done
            RepositoryEntry re = repoSearchCtr.getSelectedEntry();
            removeAsListenerAndDispose(repoSearchCtr);
            cmc.deactivate();
            if (re != null) {
                doAddRepositoryEntry(Collections.singletonList(re));
                fireEvent(ureq, Event.CHANGED_EVENT);
            }
        } else if (event == ReferencableEntriesSearchController.EVENT_REPOSITORY_ENTRIES_SELECTED) {
            // repository search controller done
            List<RepositoryEntry> res = repoSearchCtr.getSelectedEntries();
            removeAsListenerAndDispose(repoSearchCtr);
            cmc.deactivate();
            if (res != null && !res.isEmpty()) {
                doAddRepositoryEntry(res);
                fireEvent(ureq, Event.CHANGED_EVENT);
            }
        }
    } else if (source == resourcesCtr) {
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent te = (TableEvent) event;
            String actionid = te.getActionId();
            RepositoryEntry re = repoTableModel.getObject(te.getRowId());
            if (actionid.equals(RepositoryTableModel.TABLE_ACTION_REMOVE_LINK)) {
                // present dialog box if resource should be removed
                String text = getTranslator().translate("resource.remove", new String[] { group.getName(), re.getDisplayname() });
                confirmRemoveResource = activateYesNoDialog(ureq, null, text, this.confirmRemoveResource);
                confirmRemoveResource.setUserObject(re);
            } else if (RepositoryTableModel.TABLE_ACTION_INFOS.equals(actionid)) {
                int row = resourcesCtr.getIndexOfSortedObject(re);
                doOpenInfos(ureq, re, row);
            }
        }
    } else if (source == confirmRemoveResource) {
        if (DialogBoxUIFactory.isYesEvent(event)) {
            // yes case
            RepositoryEntry re = (RepositoryEntry) confirmRemoveResource.getUserObject();
            doRemoveResource(re);
            fireEvent(ureq, Event.CHANGED_EVENT);
        }
    }
}
Also used : TableEvent(org.olat.core.gui.components.table.TableEvent) ArrayList(java.util.ArrayList) List(java.util.List) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 47 with TableEvent

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

the class OpenMeetingsAdminRoomsController 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();
            OpenMeetingsRoom room = (OpenMeetingsRoom) tableCtr.getTableDataModel().getObject(row);
            if ("delete".equals(e.getActionId())) {
                confirmDelete(ureq, room);
            } else if ("infos".equals(e.getActionId())) {
                openInfoBox(ureq, room);
            } else if ("resource".equals(e.getActionId())) {
                openResource(ureq, room);
            }
        }
    } else if (source == dialogCtr) {
        if (DialogBoxUIFactory.isOkEvent(event)) {
            OpenMeetingsRoom room = (OpenMeetingsRoom) dialogCtr.getUserObject();
            doDelete(room);
        }
    } else if (source == cmc) {
        removeAsListenerAndDispose(infoController);
        removeAsListenerAndDispose(cmc);
    } else if (source == infoController) {
        cmc.deactivate();
        removeAsListenerAndDispose(infoController);
        removeAsListenerAndDispose(cmc);
        reloadModel();
    }
}
Also used : OpenMeetingsRoom(org.olat.modules.openmeetings.model.OpenMeetingsRoom) TableEvent(org.olat.core.gui.components.table.TableEvent)

Example 48 with TableEvent

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

the class OpenMeetingsRecordingsController 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();
            OpenMeetingsRecording recording = (OpenMeetingsRecording) tableCtr.getTableDataModel().getObject(row);
            if ("view".equals(e.getActionId())) {
                doView(ureq, recording);
            } else if ("delete".equals(e.getActionId())) {
                String text = getTranslator().translate("recording.remove", new String[] { recording.getFilename() });
                confirmRemoveRecording = activateYesNoDialog(ureq, null, text, confirmRemoveRecording);
                confirmRemoveRecording.setUserObject(recording);
            }
        }
    } else if (source == confirmRemoveRecording) {
        if (DialogBoxUIFactory.isYesEvent(event)) {
            // yes case
            OpenMeetingsRecording recording = (OpenMeetingsRecording) confirmRemoveRecording.getUserObject();
            doDelete(recording);
        }
    }
}
Also used : OpenMeetingsRecording(org.olat.modules.openmeetings.model.OpenMeetingsRecording) TableEvent(org.olat.core.gui.components.table.TableEvent)

Example 49 with TableEvent

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

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);
    }
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) TableEvent(org.olat.core.gui.components.table.TableEvent) VFSRevision(org.olat.core.util.vfs.version.VFSRevision) VFSRevisionMediaResource(org.olat.core.util.vfs.VFSRevisionMediaResource) TableMultiSelectEvent(org.olat.core.gui.components.table.TableMultiSelectEvent) MediaResource(org.olat.core.gui.media.MediaResource) VFSMediaResource(org.olat.core.util.vfs.VFSMediaResource) VFSRevisionMediaResource(org.olat.core.util.vfs.VFSRevisionMediaResource) ArrayList(java.util.ArrayList) List(java.util.List) VFSMediaResource(org.olat.core.util.vfs.VFSMediaResource)

Example 50 with TableEvent

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

the class TaskController 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) {
    log.debug("Test Controller.event source" + source + "  , event=" + event);
    if (source == tableCtr) {
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent ta = (TableEvent) event;
            if (ta.getActionId().equals(TaskController.ACTION_PREVIEW)) {
                String previewTask = (String) taskTableModel.getValueAt(ta.getRowId(), 0);
                doFileDelivery(ureq, previewTask);
            } else if (ta.getActionId().equals(TaskController.ACTION_SELECT)) {
                // select a task
                assignedTask = (String) taskTableModel.getValueAt(ta.getRowId(), 0);
                List<String> availableTasks = compileAvailableTasks();
                if (!availableTasks.contains(assignedTask)) {
                    showWarning("task.chosen");
                    taskTableModel.setObjects(availableTasks);
                    tableCtr.modelChanged();
                    if (availableTasks.size() == 0) {
                        // no more tasks available
                        myContent.contextPut(VC_NOMORETASKS, translate("task.nomoretasks"));
                    }
                } else {
                    setAssignedTask(ureq.getIdentity(), assignedTask);
                    if (!samplingWithReplacement)
                        markTaskAsSampled(assignedTask);
                    if (!isDeselectable()) {
                        pushTaskToVC();
                    } else {
                        // if assignedTask selected, and deselectable, update taskTableModel
                        List<String> allTasks = compileAvailableTasks();
                        if (!samplingWithReplacement) {
                            // if assignable to only one user, this means that the assignedTask is no more in the availableTasks, but show it in taskTableModel
                            allTasks.add(assignedTask);
                        }
                        taskTableModel.setObjects(allTasks);
                        tableCtr.modelChanged();
                    }
                }
            } else if (ta.getActionId().equals(TaskController.ACTION_DESELECT)) {
                if (assignedTask != null) {
                    removeAssignedTask(ureq.getIdentity());
                    List<String> availableTasks = compileAvailableTasks();
                    taskTableModel.setObjects(availableTasks);
                    tableCtr.modelChanged();
                }
            }
        }
    }
}
Also used : TableEvent(org.olat.core.gui.components.table.TableEvent) ArrayList(java.util.ArrayList) List(java.util.List)

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