Search in sources :

Example 1 with DialogBoxController

use of org.olat.core.gui.control.generic.modal.DialogBoxController in project OpenOLAT by OpenOLAT.

the class ItemsController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    // reload feed for this event and make sure the updated feed object is
    // in the view
    feedResource = feedManager.loadFeed(feedResource);
    accessibleItems = feedManager.loadFilteredAndSortedItems(feedResource, callback, ureq.getIdentity());
    if (source == cmc) {
        if (event.equals(CloseableModalController.CLOSE_MODAL_EVENT)) {
            removeAsListenerAndDispose(cmc);
            cmc = null;
            removeAsListenerAndDispose(itemFormCtr);
            itemFormCtr = null;
            // Check if this item has ever been added to the feed. If not,
            // remove the temp dir
            cleanupTmpItemMediaDir(currentItem);
            // internally or subscribe to an external feed.
            if (!feedManager.hasItems(feedResource)) {
                feedResource = feedManager.updateFeedMode(null, feedResource);
                makeInternalAndExternalButtons();
            }
            // release lock
            feedManager.releaseLock(lock);
        }
    } else if (source == confirmDialogCtr && DialogBoxUIFactory.isYesEvent(event)) {
        // The user confirmed that the item shall be deleted
        Item item = (Item) ((DialogBoxController) source).getUserObject();
        lock = feedManager.acquireLock(feedResource, item, getIdentity());
        if (lock.isSuccess()) {
            // remove the item from the naviCtr
            naviCtr.remove(item);
            // permanently remove item
            feedResource = feedManager.deleteItem(item);
            // remove delete and edit buttons of this item
            for (Link deleteButton : deleteButtons) {
                if (item.equals(deleteButton.getUserObject())) {
                    deleteButtons.remove(deleteButton);
                    break;
                }
            }
            for (Link editButton : editButtons) {
                if (item.equals(editButton.getUserObject())) {
                    editButtons.remove(editButton);
                    break;
                }
            }
            // items manually or from an external source/feed.
            if (!feedManager.hasItems(feedResource)) {
                makeInternalAndExternalButtons();
                // The subscription/feed url from the feed info is obsolete
                fireEvent(ureq, ItemsController.FEED_INFO_IS_DIRTY_EVENT);
            } else {
                if (callback.mayEditItems() || callback.mayCreateItems()) {
                    createEditButtons(ureq, feedResource);
                }
                createCommentsAndRatingsLinks(ureq, feedResource);
            }
            vcItems.setDirty(true);
            // in case we were in single item view, show all items
            mainPanel.setContent(vcItems);
            feedManager.releaseLock(lock);
            lock = null;
            // do logging
            ThreadLocalUserActivityLogger.log(FeedLoggingAction.FEED_ITEM_DELETE, getClass(), LoggingResourceable.wrap(item));
        } else {
            String fullName = userManager.getUserDisplayName(lock.getOwner());
            showInfo("feed.item.is.being.edited.by", fullName);
        }
    } else if (source == itemFormCtr) {
        if (event.equals(Event.CHANGED_EVENT) || event.equals(Event.CANCELLED_EVENT)) {
            if (event.equals(Event.CHANGED_EVENT)) {
                FileElement mediaFile = currentItem.getMediaFile();
                if (feedManager.getItemContainer(currentItem) == null) {
                    // Ups, deleted in the meantime by someone else
                    // remove the item from the naviCtr
                    naviCtr.remove(currentItem);
                } else {
                    if (!accessibleItems.contains(currentItem)) {
                        // Add the modified item if it is not part of the
                        // feed
                        feedResource = feedManager.createItem(feedResource, currentItem, mediaFile);
                        if (feedResource != null) {
                            createButtonsForItem(ureq, feedResource, currentItem);
                            createItemLink(currentItem);
                            // Add date component
                            String guid = currentItem.getGuid();
                            if (currentItem.getDate() != null) {
                                DateComponentFactory.createDateComponentWithYear("date." + guid, currentItem.getDate(), vcItems);
                            }
                            // Add comments and rating
                            createCommentsAndRatingsLink(ureq, feedResource, currentItem);
                            // add it to the navigation controller
                            naviCtr.add(currentItem);
                            accessibleItems = feedManager.loadFilteredAndSortedItems(feedResource, callback, ureq.getIdentity());
                            if (accessibleItems != null && accessibleItems.size() == 1) {
                                // First item added, show feed url (for
                                // subscription)
                                fireEvent(ureq, ItemsController.FEED_INFO_IS_DIRTY_EVENT);
                                // Set the base URI of the feed for the
                                // current user. All users
                                // have unique URIs.
                                helper.setURIs(currentItem.getFeed());
                            }
                        }
                    } else {
                        // Write item file
                        currentItem = feedManager.updateItem(currentItem, mediaFile);
                        if (itemCtr != null) {
                            displayItemController(ureq, currentItem);
                        }
                        ThreadLocalUserActivityLogger.log(FeedLoggingAction.FEED_ITEM_EDIT, getClass(), LoggingResourceable.wrap(currentItem));
                    }
                }
                vcItems.setDirty(true);
                // if the current item is displayed, update the view
                if (itemCtr != null) {
                    itemCtr.getInitialComponent().setDirty(true);
                }
            } else if (event.equals(Event.CANCELLED_EVENT)) {
                // Check if this item has ever been added to the feed. If
                // not, remove the temp dir
                cleanupTmpItemMediaDir(currentItem);
                // internally or subscribe to an external feed.
                if (!feedManager.hasItems(feedResource)) {
                    feedResource = feedManager.updateFeedMode(null, feedResource);
                    makeInternalAndExternalButtons();
                }
            }
            // release the lock
            feedManager.releaseLock(lock);
            // Dispose the cmc and the podcastFormCtr.
            cmc.deactivate();
            removeAsListenerAndDispose(cmc);
            cmc = null;
            removeAsListenerAndDispose(itemFormCtr);
            itemFormCtr = null;
        }
    } else if (source == externalUrlCtr) {
        if (event.equals(Event.CHANGED_EVENT)) {
            String externalUrl = externalUrlCtr.getExternalFeedUrlEl();
            feedManager.updateExternalFeedUrl(feedResource, externalUrl);
        } else if (event.equals(Event.CHANGED_EVENT)) {
        // nothing to do
        }
        cmc.deactivate();
        removeAsListenerAndDispose(cmc);
        cmc = null;
        removeAsListenerAndDispose(externalUrlCtr);
        externalUrlCtr = null;
    } else if (source == naviCtr && event instanceof NavigationEvent) {
        List<? extends Dated> selItems = ((NavigationEvent) event).getSelectedItems();
        List<Item> items = new ArrayList<>();
        for (Dated item : selItems) {
            if (item instanceof Item) {
                items.add((Item) item);
            }
        }
        if (callback.mayEditItems() || callback.mayCreateItems()) {
            createEditButtons(ureq, feedResource);
        }
        createCommentsAndRatingsLinks(ureq, feedResource);
        vcItems.setDirty(true);
        mainPanel.setContent(vcItems);
    } else if (source == itemCtr) {
        if (event == Event.BACK_EVENT) {
            mainPanel.setContent(vcItems);
            removeAsListenerAndDispose(itemCtr);
            itemCtr = null;
        }
    } else if (source instanceof UserCommentsAndRatingsController) {
        UserCommentsAndRatingsController commentsRatingsCtr = (UserCommentsAndRatingsController) source;
        if (event == UserCommentsAndRatingsController.EVENT_COMMENT_LINK_CLICKED) {
            // go to details page
            Item item = (Item) commentsRatingsCtr.getUserObject();
            if (item != null) {
                ItemController myItemCtr = displayItemController(ureq, item);
                List<ContextEntry> entries = BusinessControlFactory.getInstance().createCEListFromResourceType(ItemController.ACTIVATION_KEY_COMMENTS);
                myItemCtr.activate(ureq, entries, null);
            }
        }
    }
    // reload everything
    if (feedResource != null) {
        resetItems(ureq, feedResource);
    }
}
Also used : NavigationEvent(org.olat.core.commons.controllers.navigation.NavigationEvent) ArrayList(java.util.ArrayList) ContextEntry(org.olat.core.id.context.ContextEntry) DialogBoxController(org.olat.core.gui.control.generic.modal.DialogBoxController) Item(org.olat.modules.webFeed.Item) UserCommentsAndRatingsController(org.olat.core.commons.services.commentAndRating.ui.UserCommentsAndRatingsController) FileElement(org.olat.core.gui.components.form.flexible.elements.FileElement) Dated(org.olat.core.commons.controllers.navigation.Dated) Link(org.olat.core.gui.components.link.Link)

Example 2 with DialogBoxController

use of org.olat.core.gui.control.generic.modal.DialogBoxController in project openolat by klemens.

the class ItemsController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    // reload feed for this event and make sure the updated feed object is
    // in the view
    feedResource = feedManager.loadFeed(feedResource);
    accessibleItems = feedManager.loadFilteredAndSortedItems(feedResource, callback, ureq.getIdentity());
    if (source == cmc) {
        if (event.equals(CloseableModalController.CLOSE_MODAL_EVENT)) {
            removeAsListenerAndDispose(cmc);
            cmc = null;
            removeAsListenerAndDispose(itemFormCtr);
            itemFormCtr = null;
            // Check if this item has ever been added to the feed. If not,
            // remove the temp dir
            cleanupTmpItemMediaDir(currentItem);
            // internally or subscribe to an external feed.
            if (!feedManager.hasItems(feedResource)) {
                feedResource = feedManager.updateFeedMode(null, feedResource);
                makeInternalAndExternalButtons();
            }
            // release lock
            feedManager.releaseLock(lock);
        }
    } else if (source == confirmDialogCtr && DialogBoxUIFactory.isYesEvent(event)) {
        // The user confirmed that the item shall be deleted
        Item item = (Item) ((DialogBoxController) source).getUserObject();
        lock = feedManager.acquireLock(feedResource, item, getIdentity());
        if (lock.isSuccess()) {
            // remove the item from the naviCtr
            naviCtr.remove(item);
            // permanently remove item
            feedResource = feedManager.deleteItem(item);
            // remove delete and edit buttons of this item
            for (Link deleteButton : deleteButtons) {
                if (item.equals(deleteButton.getUserObject())) {
                    deleteButtons.remove(deleteButton);
                    break;
                }
            }
            for (Link editButton : editButtons) {
                if (item.equals(editButton.getUserObject())) {
                    editButtons.remove(editButton);
                    break;
                }
            }
            // items manually or from an external source/feed.
            if (!feedManager.hasItems(feedResource)) {
                makeInternalAndExternalButtons();
                // The subscription/feed url from the feed info is obsolete
                fireEvent(ureq, ItemsController.FEED_INFO_IS_DIRTY_EVENT);
            } else {
                if (callback.mayEditItems() || callback.mayCreateItems()) {
                    createEditButtons(ureq, feedResource);
                }
                createCommentsAndRatingsLinks(ureq, feedResource);
            }
            vcItems.setDirty(true);
            // in case we were in single item view, show all items
            mainPanel.setContent(vcItems);
            feedManager.releaseLock(lock);
            lock = null;
            // do logging
            ThreadLocalUserActivityLogger.log(FeedLoggingAction.FEED_ITEM_DELETE, getClass(), LoggingResourceable.wrap(item));
        } else {
            String fullName = userManager.getUserDisplayName(lock.getOwner());
            showInfo("feed.item.is.being.edited.by", fullName);
        }
    } else if (source == itemFormCtr) {
        if (event.equals(Event.CHANGED_EVENT) || event.equals(Event.CANCELLED_EVENT)) {
            if (event.equals(Event.CHANGED_EVENT)) {
                FileElement mediaFile = currentItem.getMediaFile();
                if (feedManager.getItemContainer(currentItem) == null) {
                    // Ups, deleted in the meantime by someone else
                    // remove the item from the naviCtr
                    naviCtr.remove(currentItem);
                } else {
                    if (!accessibleItems.contains(currentItem)) {
                        // Add the modified item if it is not part of the
                        // feed
                        feedResource = feedManager.createItem(feedResource, currentItem, mediaFile);
                        if (feedResource != null) {
                            createButtonsForItem(ureq, feedResource, currentItem);
                            createItemLink(currentItem);
                            // Add date component
                            String guid = currentItem.getGuid();
                            if (currentItem.getDate() != null) {
                                DateComponentFactory.createDateComponentWithYear("date." + guid, currentItem.getDate(), vcItems);
                            }
                            // Add comments and rating
                            createCommentsAndRatingsLink(ureq, feedResource, currentItem);
                            // add it to the navigation controller
                            naviCtr.add(currentItem);
                            accessibleItems = feedManager.loadFilteredAndSortedItems(feedResource, callback, ureq.getIdentity());
                            if (accessibleItems != null && accessibleItems.size() == 1) {
                                // First item added, show feed url (for
                                // subscription)
                                fireEvent(ureq, ItemsController.FEED_INFO_IS_DIRTY_EVENT);
                                // Set the base URI of the feed for the
                                // current user. All users
                                // have unique URIs.
                                helper.setURIs(currentItem.getFeed());
                            }
                        }
                    } else {
                        // Write item file
                        currentItem = feedManager.updateItem(currentItem, mediaFile);
                        if (itemCtr != null) {
                            displayItemController(ureq, currentItem);
                        }
                        ThreadLocalUserActivityLogger.log(FeedLoggingAction.FEED_ITEM_EDIT, getClass(), LoggingResourceable.wrap(currentItem));
                    }
                }
                vcItems.setDirty(true);
                // if the current item is displayed, update the view
                if (itemCtr != null) {
                    itemCtr.getInitialComponent().setDirty(true);
                }
            } else if (event.equals(Event.CANCELLED_EVENT)) {
                // Check if this item has ever been added to the feed. If
                // not, remove the temp dir
                cleanupTmpItemMediaDir(currentItem);
                // internally or subscribe to an external feed.
                if (!feedManager.hasItems(feedResource)) {
                    feedResource = feedManager.updateFeedMode(null, feedResource);
                    makeInternalAndExternalButtons();
                }
            }
            // release the lock
            feedManager.releaseLock(lock);
            // Dispose the cmc and the podcastFormCtr.
            cmc.deactivate();
            removeAsListenerAndDispose(cmc);
            cmc = null;
            removeAsListenerAndDispose(itemFormCtr);
            itemFormCtr = null;
        }
    } else if (source == externalUrlCtr) {
        if (event.equals(Event.CHANGED_EVENT)) {
            String externalUrl = externalUrlCtr.getExternalFeedUrlEl();
            feedManager.updateExternalFeedUrl(feedResource, externalUrl);
        } else if (event.equals(Event.CHANGED_EVENT)) {
        // nothing to do
        }
        cmc.deactivate();
        removeAsListenerAndDispose(cmc);
        cmc = null;
        removeAsListenerAndDispose(externalUrlCtr);
        externalUrlCtr = null;
    } else if (source == naviCtr && event instanceof NavigationEvent) {
        List<? extends Dated> selItems = ((NavigationEvent) event).getSelectedItems();
        List<Item> items = new ArrayList<>();
        for (Dated item : selItems) {
            if (item instanceof Item) {
                items.add((Item) item);
            }
        }
        if (callback.mayEditItems() || callback.mayCreateItems()) {
            createEditButtons(ureq, feedResource);
        }
        createCommentsAndRatingsLinks(ureq, feedResource);
        vcItems.setDirty(true);
        mainPanel.setContent(vcItems);
    } else if (source == itemCtr) {
        if (event == Event.BACK_EVENT) {
            mainPanel.setContent(vcItems);
            removeAsListenerAndDispose(itemCtr);
            itemCtr = null;
        }
    } else if (source instanceof UserCommentsAndRatingsController) {
        UserCommentsAndRatingsController commentsRatingsCtr = (UserCommentsAndRatingsController) source;
        if (event == UserCommentsAndRatingsController.EVENT_COMMENT_LINK_CLICKED) {
            // go to details page
            Item item = (Item) commentsRatingsCtr.getUserObject();
            if (item != null) {
                ItemController myItemCtr = displayItemController(ureq, item);
                List<ContextEntry> entries = BusinessControlFactory.getInstance().createCEListFromResourceType(ItemController.ACTIVATION_KEY_COMMENTS);
                myItemCtr.activate(ureq, entries, null);
            }
        }
    }
    // reload everything
    if (feedResource != null) {
        resetItems(ureq, feedResource);
    }
}
Also used : NavigationEvent(org.olat.core.commons.controllers.navigation.NavigationEvent) ArrayList(java.util.ArrayList) ContextEntry(org.olat.core.id.context.ContextEntry) DialogBoxController(org.olat.core.gui.control.generic.modal.DialogBoxController) Item(org.olat.modules.webFeed.Item) UserCommentsAndRatingsController(org.olat.core.commons.services.commentAndRating.ui.UserCommentsAndRatingsController) FileElement(org.olat.core.gui.components.form.flexible.elements.FileElement) Dated(org.olat.core.commons.controllers.navigation.Dated) Link(org.olat.core.gui.components.link.Link)

Example 3 with DialogBoxController

use of org.olat.core.gui.control.generic.modal.DialogBoxController in project openolat by klemens.

the class EPMultipleMapController 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
protected void event(UserRequest ureq, Controller source, Event event) {
    super.event(ureq, source, event);
    if (source == delMapCtrl) {
        if (DialogBoxUIFactory.isYesEvent(event)) {
            PortfolioStructure mapToDel = (PortfolioStructure) ((DialogBoxController) source).getUserObject();
            String title = mapToDel.getTitle();
            ePFMgr.deletePortfolioStructure(mapToDel);
            showInfo("delete.map.success", title);
            ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapPortfolioOres(mapToDel));
            ThreadLocalUserActivityLogger.log(EPLoggingAction.EPORTFOLIO_MAP_REMOVED, getClass());
            initOrUpdateMaps(ureq);
        }
    } else if (source == copyMapCtrl) {
        if (event.equals(Event.CANCELLED_EVENT)) {
            fireEvent(ureq, Event.CANCELLED_EVENT);
            return;
        }
        int pos = DialogBoxUIFactory.getButtonPos(event);
        boolean withArtefacts = false;
        PortfolioStructure mapToCopy = (PortfolioStructure) ((DialogBoxController) source).getUserObject();
        // shift clicked pos, when "with artefacts" was hidden before
        if (!ePFMgr.isMapOwner(getIdentity(), mapToCopy))
            pos++;
        if (pos == 2) {
            // clicked cancel button
            fireEvent(ureq, Event.CANCELLED_EVENT);
            return;
        } else if (pos == 0)
            withArtefacts = true;
        PortfolioStructureMap targetMap = ePFMgr.createAndPersistPortfolioDefaultMap(getIdentity(), translate("map.copy.of", mapToCopy.getTitle()), mapToCopy.getDescription());
        ePFMgr.copyStructureRecursively(mapToCopy, targetMap, withArtefacts);
        // open the map
        String title = targetMap.getTitle();
        showInfo("copy.map.success", title);
        initOrUpdateMaps(ureq);
        String businessPath = "[" + targetMap.getClass().getSimpleName() + ":" + targetMap.getResourceableId() + "]";
        NewControllerFactory.getInstance().launch(businessPath, ureq, getWindowControl());
    } else if (source == mapViewCtrl) {
        if (EPStructureEvent.CLOSE.equals(event.getCommand())) {
            myPanel.popContent();
            fireEvent(ureq, event);
            removeAsListenerAndDispose(mapViewCtrl);
            mapViewCtrl = null;
            // refresh on close (back-link) to prevent stale object errors, when map got changed meanwhile
            initOrUpdateMaps(ureq);
            addToHistory(ureq);
        } else if (EPStructureEvent.SUBMIT.equals(event.getCommand()) || event.equals(Event.CHANGED_EVENT)) {
            // refresh on submission of a map or on any other changes which needs an ui-update
            initOrUpdateMaps(ureq);
        }
    } else if (source == shareListController) {
        shareBox.deactivate();
        removeAsListenerAndDispose(shareListController);
        initOrUpdateMaps(ureq);
    }
    if (event instanceof EPStructureChangeEvent) {
        // event from child
        String evCmd = event.getCommand();
        if (evCmd.equals(EPStructureChangeEvent.ADDED) || evCmd.equals(EPStructureChangeEvent.CHANGED)) {
            initOrUpdateMaps(ureq);
        }
    }
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) DialogBoxController(org.olat.core.gui.control.generic.modal.DialogBoxController)

Example 4 with DialogBoxController

use of org.olat.core.gui.control.generic.modal.DialogBoxController in project openolat by klemens.

the class DropboxController 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 == fileChooserController) {
        cmc.deactivate();
        if (event.equals(Event.DONE_EVENT)) {
            boolean success = false;
            File fIn = fileChooserController.getUploadFile();
            VFSContainer fDropbox = getDropBox(ureq.getIdentity());
            String filename = fileChooserController.getUploadFileName();
            VFSLeaf fOut;
            if (fDropbox.resolve(filename) != null) {
                // FIXME ms: check if dropbox quota is exceeded -> clarify with customers
                fOut = fDropbox.createChildLeaf(getNewUniqueName(filename));
            } else {
                fOut = fDropbox.createChildLeaf(filename);
            }
            try {
                InputStream in = new FileInputStream(fIn);
                OutputStream out = new BufferedOutputStream(fOut.getOutputStream(false));
                success = FileUtils.copy(in, out);
                FileUtils.closeSafely(in);
                FileUtils.closeSafely(out);
            } catch (FileNotFoundException e) {
                logError("", e);
                return;
            }
            if (fOut instanceof MetaTagged) {
                MetaInfo info = ((MetaTagged) fOut).getMetaInfo();
                if (info != null) {
                    info.setAuthor(ureq.getIdentity());
                    info.write();
                }
            }
            if (success) {
                int numFiles = fDropbox.getItems().size();
                myContent.contextPut("numfiles", new String[] { Integer.toString(numFiles) });
                // assemble confirmation
                String confirmation = getConfirmation(ureq, fOut.getName());
                // send email if necessary
                Boolean sendEmail = (Boolean) config.get(TACourseNode.CONF_DROPBOX_ENABLEMAIL);
                if (sendEmail == null)
                    sendEmail = Boolean.FALSE;
                boolean sendMailError = false;
                if (sendEmail.booleanValue()) {
                    // send mail
                    MailContext context = new MailContextImpl(getWindowControl().getBusinessControl().getAsString());
                    MailBundle bundle = new MailBundle();
                    bundle.setContext(context);
                    bundle.setToId(ureq.getIdentity());
                    bundle.setContent(translate("conf.mail.subject"), confirmation);
                    MailerResult result = CoreSpringFactory.getImpl(MailManager.class).sendMessage(bundle);
                    if (result.getFailedIdentites().size() > 0) {
                        List<Identity> disabledIdentities = new ArrayList<Identity>();
                        disabledIdentities = result.getFailedIdentites();
                        // show error that message can not be sent
                        ArrayList<String> myButtons = new ArrayList<String>();
                        myButtons.add(translate("back"));
                        String title = MailHelper.getTitleForFailedUsersError(ureq.getLocale());
                        String message = MailHelper.getMessageForFailedUsersError(ureq.getLocale(), disabledIdentities);
                        // add dropbox specific error message
                        message += "\n<br />" + translate("conf.mail.error");
                        // FIXME:FG:6.2: fix problem in info message, not here
                        message += "\n<br />\n<br />" + confirmation.replace("\n", "&#10;").replace("\r", "&#10;").replace("\u2028", "&#10;");
                        DialogBoxController noUsersErrorCtr = null;
                        noUsersErrorCtr = activateGenericDialog(ureq, title, message, myButtons, noUsersErrorCtr);
                        sendMailError = true;
                    } else if (result.getReturnCode() > 0) {
                        // show error that message can not be sent
                        ArrayList<String> myButtons = new ArrayList<String>();
                        myButtons.add(translate("back"));
                        DialogBoxController noUsersErrorCtr = null;
                        String message = translate("conf.mail.error");
                        // FIXME:FG:6.2: fix problem in info message, not here
                        message += "\n<br />\n<br />" + confirmation.replace("\n", "&#10;").replace("\r", "&#10;").replace("\u2028", "&#10;");
                        noUsersErrorCtr = activateGenericDialog(ureq, translate("error.header"), message, myButtons, noUsersErrorCtr);
                        sendMailError = true;
                    }
                }
                // inform subscription manager about new element
                if (subsContext != null) {
                    NotificationsManager.getInstance().markPublisherNews(subsContext, ureq.getIdentity(), true);
                }
                // FIXME:FG:6.2: fix problem in info message, not here
                if (!sendMailError) {
                    getWindowControl().setInfo(confirmation.replace("\n", "&#10;").replace("\r", "&#10;").replace("\u2028", "&#10;"));
                }
            } else {
                showInfo("dropbox.upload.failed");
            }
        }
    }
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) MailContextImpl(org.olat.core.util.mail.MailContextImpl) MailContext(org.olat.core.util.mail.MailContext) MailerResult(org.olat.core.util.mail.MailerResult) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) VFSContainer(org.olat.core.util.vfs.VFSContainer) BufferedOutputStream(java.io.BufferedOutputStream) OutputStream(java.io.OutputStream) FileNotFoundException(java.io.FileNotFoundException) MetaTagged(org.olat.core.commons.modules.bc.meta.tagged.MetaTagged) MetaInfo(org.olat.core.commons.modules.bc.meta.MetaInfo) ArrayList(java.util.ArrayList) FileInputStream(java.io.FileInputStream) DialogBoxController(org.olat.core.gui.control.generic.modal.DialogBoxController) MailManager(org.olat.core.util.mail.MailManager) MailBundle(org.olat.core.util.mail.MailBundle) Identity(org.olat.core.id.Identity) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream)

Example 5 with DialogBoxController

use of org.olat.core.gui.control.generic.modal.DialogBoxController in project OpenOLAT by OpenOLAT.

the class UsrPropCfgResetController method formOK.

/**
 * form is ok<br/>
 * load the selected preset.properties file and reset userProperties.<br />
 * show dialog on error
 */
@Override
protected void formOK(UserRequest ureq) {
    String propertyFileName = "_static/" + resetDropdown.getSelectedKey() + ".properties";
    InputStream is = this.getClass().getResourceAsStream(propertyFileName);
    try {
        Properties p = new Properties();
        p.load(is);
        usrPropCfgMng.resetToPresetConfig(p);
        fireEvent(ureq, Event.DONE_EVENT);
    } catch (IOException e) {
        DialogBoxController dBox = null;
        List<String> buttonLabels = Collections.singletonList(translate("ok"));
        activateGenericDialog(ureq, "ERROR", "Sorry, Preset-File was not found: " + propertyFileName, buttonLabels, dBox);
    } catch (Exception ex) {
        DialogBoxController dBox = null;
        List<String> buttonLabels = Collections.singletonList(translate("ok"));
        StringBuilder sbError = new StringBuilder();
        sbError.append("Sorry, there was an error while loading the preset file: ");
        sbError.append(propertyFileName);
        sbError.append("<br /><br />");
        sbError.append(ex.getClass().getSimpleName()).append("      ").append(ex.getMessage());
        activateGenericDialog(ureq, "ERROR", sbError.toString(), buttonLabels, dBox);
    }
}
Also used : InputStream(java.io.InputStream) List(java.util.List) IOException(java.io.IOException) Properties(java.util.Properties) IOException(java.io.IOException) DialogBoxController(org.olat.core.gui.control.generic.modal.DialogBoxController)

Aggregations

DialogBoxController (org.olat.core.gui.control.generic.modal.DialogBoxController)8 InputStream (java.io.InputStream)4 ArrayList (java.util.ArrayList)4 BufferedOutputStream (java.io.BufferedOutputStream)2 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 OutputStream (java.io.OutputStream)2 List (java.util.List)2 Properties (java.util.Properties)2 Dated (org.olat.core.commons.controllers.navigation.Dated)2 NavigationEvent (org.olat.core.commons.controllers.navigation.NavigationEvent)2 MetaInfo (org.olat.core.commons.modules.bc.meta.MetaInfo)2 MetaTagged (org.olat.core.commons.modules.bc.meta.tagged.MetaTagged)2 UserCommentsAndRatingsController (org.olat.core.commons.services.commentAndRating.ui.UserCommentsAndRatingsController)2 FileElement (org.olat.core.gui.components.form.flexible.elements.FileElement)2 Link (org.olat.core.gui.components.link.Link)2 Identity (org.olat.core.id.Identity)2 ContextEntry (org.olat.core.id.context.ContextEntry)2