Search in sources :

Example 1 with LeavingEvent

use of org.olat.repository.ui.list.LeavingEvent 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 2 with LeavingEvent

use of org.olat.repository.ui.list.LeavingEvent in project openolat by klemens.

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)

Aggregations

OLATResourceable (org.olat.core.id.OLATResourceable)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2 RepositoryEntryRef (org.olat.repository.RepositoryEntryRef)2 EntryChangedEvent (org.olat.repository.controllers.EntryChangedEvent)2 LeavingEvent (org.olat.repository.ui.list.LeavingEvent)2 AccessEvent (org.olat.resource.accesscontrol.ui.AccessEvent)2