Search in sources :

Example 1 with EntryChangedEvent

use of org.olat.repository.controllers.EntryChangedEvent in project OpenOLAT by OpenOLAT.

the class QuestionListController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == shareTargetCtrl) {
        List<QuestionItemShort> items = getSelectedShortItems();
        calloutCtrl.deactivate();
        if (items.isEmpty()) {
            showWarning("error.select.one");
        } else if (ShareTargetController.SHARE_GROUP_CMD.equals(event.getCommand())) {
            doSelectGroup(ureq, items);
        } else if (ShareTargetController.SHARE_POOL_CMD.equals(event.getCommand())) {
            doSelectPool(ureq, items);
        }
    } else if (source == selectPoolCtrl) {
        cmc.deactivate();
        if (event instanceof QPoolSelectionEvent) {
            QPoolSelectionEvent qpe = (QPoolSelectionEvent) event;
            List<Pool> pools = qpe.getPools();
            if (pools.size() > 0) {
                @SuppressWarnings("unchecked") List<QuestionItemShort> items = (List<QuestionItemShort>) selectPoolCtrl.getUserObject();
                doShareItemsToPools(ureq, items, pools);
            }
        }
    } else if (source == importSourcesCtrl) {
        calloutCtrl.deactivate();
        if (ImportSourcesController.IMPORT_FILE.equals(event.getCommand())) {
            doOpenFileImport(ureq);
        } else if (ImportSourcesController.IMPORT_REPO.equals(event.getCommand())) {
            doOpenRepositoryImport(ureq);
        } else if (ImportSourcesController.IMPORT_EXCEL_QTI_12.equals(event.getCommand())) {
            doOpenExcelImportQTI12(ureq);
        } else if (ImportSourcesController.IMPORT_EXCEL_QTI_21.equals(event.getCommand())) {
            doOpenExcelImportQTI21(ureq);
        }
    } else if (source == newItemOptionsCtrl) {
        cmc.deactivate();
        if (event instanceof QItemCreationCmdEvent) {
            QItemCreationCmdEvent qicce = (QItemCreationCmdEvent) event;
            doCreateNewItem(ureq, qicce.getTitle(), qicce.getTaxonomyLevel(), qicce.getFactory());
        }
    } else if (source == selectGroupCtrl) {
        cmc.deactivate();
        if (event instanceof BusinessGroupSelectionEvent) {
            BusinessGroupSelectionEvent bge = (BusinessGroupSelectionEvent) event;
            List<BusinessGroup> groups = bge.getGroups();
            if (groups.size() > 0) {
                @SuppressWarnings("unchecked") List<QuestionItemShort> items = (List<QuestionItemShort>) selectGroupCtrl.getUserObject();
                doShareItemsToGroups(ureq, items, groups);
            }
        }
    } else if (source == shareItemsCtrl) {
        if (event instanceof QPoolEvent) {
            fireEvent(ureq, event);
        }
        cmc.deactivate();
        cleanUp();
    } else if (source == listTargetCtrl) {
        List<QuestionItemShort> items = getSelectedShortItems();
        calloutCtrl.deactivate();
        if (CollectionTargetController.ADD_TO_LIST_POOL_CMD.equals(event.getCommand())) {
            if (items.isEmpty()) {
                showWarning("error.select.one");
            } else {
                doChooseCollection(ureq, items);
            }
        } else if (CollectionTargetController.NEW_LIST_CMD.equals(event.getCommand())) {
            doAskCollectionName(ureq, items);
        } else if (CollectionTargetController.RENAME_LIST_CMD.equals(event.getCommand())) {
            doOpenRenameCallout(ureq);
        } else if (CollectionTargetController.DELETE_LIST_CMD.equals(event.getCommand())) {
            doConfirmDeleteSource(ureq);
        }
    } else if (source == createCollectionCtrl) {
        if (Event.DONE_EVENT == event) {
            List<QuestionItemShort> items = createCollectionCtrl.getUserObject();
            String collectionName = createCollectionCtrl.getName();
            doCreateCollection(ureq, collectionName, items);
        }
        cmc.deactivate();
        cleanUp();
    }
    if (source == confirmDeleteSourceBox) {
        boolean delete = DialogBoxUIFactory.isYesEvent(event) || DialogBoxUIFactory.isOkEvent(event);
        if (delete) {
            doDeleteItemCollection(ureq);
        }
    } else if (source == renameCtrl) {
        cmc.deactivate();
        if (Event.CHANGED_EVENT == event) {
            String newName = renameCtrl.getName();
            doRenameItemCollection(ureq, newName);
        }
    } else if (source == chooseCollectionCtrl) {
        cmc.deactivate();
        cleanUp();
    } else if (source == createTestTargetCtrl && event instanceof ExportFormatSelectionEvent) {
        calloutCtrl.deactivate();
        ExportFormatSelectionEvent efsEvent = (ExportFormatSelectionEvent) event;
        ExportFormatOptions format = efsEvent.getFormat();
        List<QuestionItemShort> items = getSelectedShortItems();
        doShowCreateTestOverview(ureq, items, format);
    } else if (source == createTestOverviewCtrl) {
        List<QuestionItemShort> items = createTestOverviewCtrl.getExportableQuestionItems();
        String typeFormat = createTestOverviewCtrl.getResourceTypeFormat();
        cmc.deactivate();
        cleanUp();
        if (event == Event.DONE_EVENT) {
            doOpenCreateRepositoryTest(ureq, items, typeFormat);
        }
    } else if (source == exportWizard) {
        if (event == Event.CANCELLED_EVENT || event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            getWindowControl().pop();
            removeAsListenerAndDispose(exportWizard);
            StepsRunContext runContext = exportWizard.getRunContext();
            exportWizard = null;
            if (event == Event.CHANGED_EVENT) {
                doExecuteExport(ureq, runContext);
            }
        }
    } else if (source == excelImportWizard) {
        if (event == Event.CANCELLED_EVENT || event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            getWindowControl().pop();
            removeAsListenerAndDispose(excelImportWizard);
            excelImportWizard = null;
        }
    } else if (source == importAuthorsWizard) {
        if (event == Event.CANCELLED_EVENT || event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            getWindowControl().pop();
            removeAsListenerAndDispose(importAuthorsWizard);
            importAuthorsWizard = null;
        }
    } else if (source == importItemCtrl) {
        if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            getItemsTable().reset();
        }
        cmc.deactivate();
        cleanUp();
    } else if (source == importTestCtrl) {
        RepositoryEntry re = importTestCtrl.getSelectedEntry();
        cmc.deactivate();
        cleanUp();
        if (event == ReferencableEntriesSearchController.EVENT_REPOSITORY_ENTRY_SELECTED) {
            doImportResource(ureq, re);
        }
    } else if (source == shareItemsToSourceCtrl) {
        if (QPoolEvent.ITEM_SHARED.equals(event.getCommand())) {
            getItemsTable().reset();
        }
        cmcShareItemToSource.deactivate();
        cleanUp();
    } else if (source == bulkChangeCtrl) {
        if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            updateRows(bulkChangeCtrl.getUpdatedItems());
            fireEvent(ureq, new QPoolEvent(QPoolEvent.BULK_CHANGE));
        }
        cmc.deactivate();
        cleanUp();
    } else if (source == copyConfirmationCtrl) {
        doPostCopy(ureq, event);
        cmc.deactivate();
        cleanUp();
    } else if (source == conversionConfirmationCtrl) {
        doPostConvert(ureq, event);
        cmc.deactivate();
        cleanUp();
    } else if (source == deleteConfirmationCtrl) {
        if (event == Event.DONE_EVENT) {
            List<QuestionItemShort> items = deleteConfirmationCtrl.getItemsToDelete();
            doDelete(items);
        }
        cmc.deactivate();
        cleanUp();
    } else if (source == confirmRemoveBox) {
        if (DialogBoxUIFactory.isYesEvent(event) || DialogBoxUIFactory.isOkEvent(event)) {
            @SuppressWarnings("unchecked") List<QuestionItemShort> items = (List<QuestionItemShort>) confirmRemoveBox.getUserObject();
            doRemove(items);
        }
    } else if (source == currentDetailsCtrl) {
        if (event instanceof QItemEvent) {
            QItemEvent qce = (QItemEvent) event;
            if ("copy-item".equals(qce.getCommand()) || "convert-item".equals(qce.getCommand())) {
                stackPanel.popUpToRootController(ureq);
                doOpenDetails(ureq, qce.getItem());
            } else if ("previous".equals(qce.getCommand())) {
                doPrevious(ureq, qce.getItem());
            } else if ("next".equals(qce.getCommand())) {
                doNext(ureq, qce.getItem());
            }
        } else if (event instanceof QItemEdited) {
            String title = ((QItemEdited) event).getItem().getTitle();
            stackPanel.changeDisplayname(title, null, currentDetailsCtrl);
            itemCollectionDirty = true;
        } else if (event instanceof QPoolEvent) {
            QPoolEvent qce = (QPoolEvent) event;
            if (QPoolEvent.ITEM_DELETED.equals(qce.getCommand())) {
                fireEvent(ureq, qce);
            } else if (QPoolEvent.ITEM_STATUS_CHANGED.equals(qce.getCommand())) {
                itemCollectionDirty = true;
            }
        }
    } else if (source == addController) {
        if (event instanceof EntryChangedEvent) {
            cmc.deactivate();
            cleanUp();
            EntryChangedEvent addEvent = (EntryChangedEvent) event;
            Long repoEntryKey = addEvent.getRepositoryEntryKey();
            doCreateRepositoryTest(ureq, repoEntryKey);
        } else if (event == Event.CANCELLED_EVENT) {
            cmc.deactivate();
            cleanUp();
        }
    } else if (source == cmc) {
        cleanUp();
    }
    super.event(ureq, source, event);
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) BusinessGroupSelectionEvent(org.olat.group.model.BusinessGroupSelectionEvent) QPoolEvent(org.olat.modules.qpool.ui.events.QPoolEvent) RepositoryEntry(org.olat.repository.RepositoryEntry) StepsRunContext(org.olat.core.gui.control.generic.wizard.StepsRunContext) ExportFormatSelectionEvent(org.olat.modules.qpool.ui.events.ExportFormatSelectionEvent) QItemEdited(org.olat.modules.qpool.ui.events.QItemEdited) ExportFormatOptions(org.olat.modules.qpool.ExportFormatOptions) EntryChangedEvent(org.olat.repository.controllers.EntryChangedEvent) QPoolSelectionEvent(org.olat.modules.qpool.ui.events.QPoolSelectionEvent) QuestionItemShort(org.olat.modules.qpool.QuestionItemShort) QItemCreationCmdEvent(org.olat.modules.qpool.ui.events.QItemCreationCmdEvent) QItemEvent(org.olat.modules.qpool.ui.events.QItemEvent) QItemList(org.olat.modules.qpool.model.QItemList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 2 with EntryChangedEvent

use of org.olat.repository.controllers.EntryChangedEvent in project OpenOLAT by OpenOLAT.

the class AuthorListController method doMark.

protected boolean doMark(UserRequest ureq, AuthoringEntryRow row) {
    OLATResourceable item = OresHelper.createOLATResourceableInstance("RepositoryEntry", row.getKey());
    if (markManager.isMarked(item, getIdentity(), null)) {
        markManager.removeMark(item, getIdentity(), null);
        // before sending, save the changes
        dbInstance.commit();
        EntryChangedEvent e = new EntryChangedEvent(row, getIdentity(), Change.removeBookmark, i18nName);
        ureq.getUserSession().getSingleUserEventCenter().fireEventToListenersOf(e, RepositoryService.REPOSITORY_EVENT_ORES);
        return false;
    }
    String businessPath = "[RepositoryEntry:" + item.getResourceableId() + "]";
    markManager.setMark(item, getIdentity(), null, businessPath);
    // before sending, save the changes
    dbInstance.commit();
    EntryChangedEvent e = new EntryChangedEvent(row, getIdentity(), Change.addBookmark, i18nName);
    ureq.getUserSession().getSingleUserEventCenter().fireEventToListenersOf(e, RepositoryService.REPOSITORY_EVENT_ORES);
    return true;
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) EntryChangedEvent(org.olat.repository.controllers.EntryChangedEvent)

Example 3 with EntryChangedEvent

use of org.olat.repository.controllers.EntryChangedEvent in project OpenOLAT by OpenOLAT.

the class RepositoryEntryRuntimeController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (cmc == source) {
        cleanUp();
    } else if (source == accessController) {
        if (event.equals(AccessEvent.ACCESS_OK_EVENT)) {
            doPostSuccessfullAccess(ureq);
        } else if (event.equals(AccessEvent.ACCESS_FAILED_EVENT)) {
            String msg = ((AccessEvent) event).getMessage();
            if (StringHelper.containsNonWhitespace(msg)) {
                getWindowControl().setError(msg);
            } else {
                showError("error.accesscontrol");
            }
        }
    } else if (accessCtrl == source) {
        if (event == Event.CHANGED_EVENT) {
            refreshRepositoryEntry(accessCtrl.getEntry());
            if (ordersLink != null) {
                boolean booking = acService.isResourceAccessControled(re.getOlatResource(), null);
                ordersLink.setVisible(!corrupted && booking);
            }
        } else if (event == Event.CLOSE_EVENT) {
            doClose(ureq);
        }
    } else if (descriptionCtrl == source) {
        if (event == Event.CHANGED_EVENT) {
            RepositoryEntry entry = descriptionCtrl.getEntry();
            refreshRepositoryEntry(entry);
            handler.onDescriptionChanged(entry);
            // update name of root bread crumb and opened tabs in top nav in case the title has been modified
            if (toolbarPanel.getBreadCrumbs().size() > 0) {
                String newTitle = entry.getDisplayname();
                String oldTitle = toolbarPanel.getBreadCrumbs().get(0).getCustomDisplayText();
                if (!newTitle.equals(oldTitle)) {
                    // 1: update breadcrumb in toolbar
                    toolbarPanel.getBreadCrumbs().get(0).setCustomDisplayText(newTitle);
                    // 2: update dynamic tab in topnav
                    OLATResourceable reOres = OresHelper.clone(entry);
                    getWindowControl().getWindowBackOffice().getWindow().getDTabs().updateDTabTitle(reOres, newTitle);
                }
            }
        } else if (event == Event.CLOSE_EVENT) {
            doClose(ureq);
        }
    } else if (detailsCtrl == source) {
        if (event instanceof LeavingEvent) {
            doClose(ureq);
        } else if (event == Event.DONE_EVENT) {
            popToRoot(ureq);
            cleanUp();
            if (getRuntimeController() == null) {
                doRun(ureq, reSecurity);
            }
        }
    } else if (confirmDeleteCtrl == source) {
        if (event == Event.CANCELLED_EVENT) {
            cmc.deactivate();
            removeAsListenerAndDispose(confirmDeleteCtrl);
            removeAsListenerAndDispose(cmc);
            confirmDeleteCtrl = null;
            cmc = null;
        } else if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            cmc.deactivate();
            EntryChangedEvent e = new EntryChangedEvent(getRepositoryEntry(), getIdentity(), Change.deleted, "runtime");
            ureq.getUserSession().getSingleUserEventCenter().fireEventToListenersOf(e, RepositoryService.REPOSITORY_EVENT_ORES);
            doClose(ureq);
            cleanUp();
        }
    } else if (copyCtrl == source) {
        cmc.deactivate();
        if (event == Event.DONE_EVENT) {
            RepositoryEntryRef copy = copyCtrl.getCopiedEntry();
            String businessPath = "[RepositoryEntry:" + copy.getKey() + "][EditDescription:0]";
            NewControllerFactory.getInstance().launch(businessPath, ureq, getWindowControl());
            EntryChangedEvent e = new EntryChangedEvent(getRepositoryEntry(), getIdentity(), Change.added, "runtime");
            ureq.getUserSession().getSingleUserEventCenter().fireEventToListenersOf(e, RepositoryService.REPOSITORY_EVENT_ORES);
        }
        cleanUp();
    }
}
Also used : LeavingEvent(org.olat.repository.ui.list.LeavingEvent) AccessEvent(org.olat.resource.accesscontrol.ui.AccessEvent) OLATResourceable(org.olat.core.id.OLATResourceable) EntryChangedEvent(org.olat.repository.controllers.EntryChangedEvent) RepositoryEntry(org.olat.repository.RepositoryEntry) RepositoryEntryRef(org.olat.repository.RepositoryEntryRef)

Example 4 with EntryChangedEvent

use of org.olat.repository.controllers.EntryChangedEvent in project OpenOLAT by OpenOLAT.

the class RepositoryEntryRuntimeController method doMark.

protected boolean doMark(UserRequest ureq) {
    OLATResourceable item = OresHelper.clone(re);
    if (markManager.isMarked(item, getIdentity(), null)) {
        markManager.removeMark(item, getIdentity(), null);
        EntryChangedEvent e = new EntryChangedEvent(getRepositoryEntry(), getIdentity(), Change.removeBookmark, "runtime");
        ureq.getUserSession().getSingleUserEventCenter().fireEventToListenersOf(e, RepositoryService.REPOSITORY_EVENT_ORES);
        return false;
    } else {
        String businessPath = "[RepositoryEntry:" + item.getResourceableId() + "]";
        markManager.setMark(item, getIdentity(), null, businessPath);
        EntryChangedEvent e = new EntryChangedEvent(getRepositoryEntry(), getIdentity(), Change.addBookmark, "runtime");
        ureq.getUserSession().getSingleUserEventCenter().fireEventToListenersOf(e, RepositoryService.REPOSITORY_EVENT_ORES);
        return true;
    }
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) EntryChangedEvent(org.olat.repository.controllers.EntryChangedEvent)

Example 5 with EntryChangedEvent

use of org.olat.repository.controllers.EntryChangedEvent in project OpenOLAT by OpenOLAT.

the class AuthoringEditAccessController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == propPupForm) {
        if (event == Event.DONE_EVENT) {
            // inform user about inconsistent configuration: doesn't make sense to set a repositoryEntry canReference=true if it is only accessible to owners
            if (!entry.getCanReference() && propPupForm.canReference() && (propPupForm.getAccess() < RepositoryEntry.ACC_OWNERS_AUTHORS && !propPupForm.isMembersOnly())) {
                showError("warn.config.reference.no.access");
            }
            int access = propPupForm.getAccess();
            int numOfBookingConfigs = acCtr.getNumOfBookingConfigurations();
            entry = repositoryManager.setAccessAndProperties(entry, access, propPupForm.isMembersOnly(), propPupForm.canCopy(), propPupForm.canReference(), propPupForm.canDownload());
            if (entry == null) {
                showWarning("repositoryentry.not.existing");
                fireEvent(ureq, Event.CLOSE_EVENT);
            } else {
                boolean managedBookings = RepositoryEntryManagedFlag.isManaged(entry, RepositoryEntryManagedFlag.bookings);
                if (access == RepositoryEntry.ACC_USERS || access == RepositoryEntry.ACC_USERS_GUESTS) {
                    if ((!managedBookings && acModule.isEnabled()) || numOfBookingConfigs > 0) {
                        editproptabpubVC.put("accesscontrol", acCtr.getInitialComponent());
                        editproptabpubVC.contextPut("isGuestAccess", Boolean.valueOf(access == RepositoryEntry.ACC_USERS_GUESTS));
                    }
                } else {
                    editproptabpubVC.remove(acCtr.getInitialComponent());
                }
                // inform anybody interested about this change
                MultiUserEvent modifiedEvent = new EntryChangedEvent(entry, getIdentity(), Change.modifiedAccess, "authoring");
                CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(modifiedEvent, entry);
                CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(modifiedEvent, RepositoryService.REPOSITORY_EVENT_ORES);
                fireEvent(ureq, Event.CHANGED_EVENT);
            }
        }
    } else if (source == leaveForm) {
        if (event == Event.DONE_EVENT) {
            RepositoryEntryAllowToLeaveOptions leaveSetting = leaveForm.getSelectedLeaveSetting();
            entry = repositoryManager.setLeaveSetting(entry, leaveSetting);
            if (entry == null) {
                showWarning("repositoryentry.not.existing");
                fireEvent(ureq, Event.CLOSE_EVENT);
            } else {
                MultiUserEvent modifiedEvent = new EntryChangedEvent(entry, getIdentity(), Change.modifiedAccess, "authorings");
                CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(modifiedEvent, entry);
                CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(modifiedEvent, RepositoryService.REPOSITORY_EVENT_ORES);
                fireEvent(ureq, Event.CHANGED_EVENT);
            }
        }
    } else if (acCtr == source) {
        if (event == Event.CHANGED_EVENT) {
            fireEvent(ureq, Event.CHANGED_EVENT);
        }
    }
}
Also used : EntryChangedEvent(org.olat.repository.controllers.EntryChangedEvent) RepositoryEntryAllowToLeaveOptions(org.olat.repository.RepositoryEntryAllowToLeaveOptions) MultiUserEvent(org.olat.core.util.event.MultiUserEvent)

Aggregations

EntryChangedEvent (org.olat.repository.controllers.EntryChangedEvent)32 RepositoryEntry (org.olat.repository.RepositoryEntry)12 MultiUserEvent (org.olat.core.util.event.MultiUserEvent)10 OLATResourceable (org.olat.core.id.OLATResourceable)8 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 List (java.util.List)2 LicenseType (org.olat.core.commons.services.license.LicenseType)2 StepsRunContext (org.olat.core.gui.control.generic.wizard.StepsRunContext)2 Roles (org.olat.core.id.Roles)2 LocalFileImpl (org.olat.core.util.vfs.LocalFileImpl)2 LocalFolderImpl (org.olat.core.util.vfs.LocalFolderImpl)2 VFSContainer (org.olat.core.util.vfs.VFSContainer)2 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)2 BusinessGroup (org.olat.group.BusinessGroup)2 BusinessGroupSelectionEvent (org.olat.group.model.BusinessGroupSelectionEvent)2 ExportFormatOptions (org.olat.modules.qpool.ExportFormatOptions)2 QuestionItemShort (org.olat.modules.qpool.QuestionItemShort)2 QItemList (org.olat.modules.qpool.model.QItemList)2