makeInternalAndExternalButtons();
}
}
} 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(feed, item, getIdentity());
if (lock.isSuccess()) {
// remove the item from the naviCtr
naviCtr.remove(item);
// remove the item also from the helper (cached selection)
helper.removeItem(item);
// permanently remove item
feedManager.remove(item, feed);
// remove delete and edit buttons of this item
deleteButtons.remove(source);
for (Link editButton : editButtons) {
if (editButton.getUserObject() == item) {
editButtons.remove(editButton);
break;
}
}
// If the last item has been deleted, provide buttons for adding
// items manually or from an external source/feed.
if (!feed.hasItems()) {
makeInternalAndExternalButtons();
// The subscription/feed url from the feed info is obsolete
fireEvent(ureq, ItemsController.FEED_INFO_IS_DIRTY_EVENT);
}
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 {
showInfo("feed.item.is.being.edited.by", lock.getOwner().getName());
}
} 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 (!feed.getItems().contains(currentItem)) {
// Add the modified item if it is not part of the feed
feedManager.addItem(currentItem, mediaFile, feed);
createButtonsForItem(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, feed, currentItem);
// add it to the navigation controller
naviCtr.add(currentItem);
// ... and also to the helper
helper.addItem(currentItem);
if (feed.getItems().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();
}
// do logging
ThreadLocalUserActivityLogger.log(FeedLoggingAction.FEED_ITEM_CREATE, getClass(), LoggingResourceable.wrap(currentItem));
} else {
// write item file
feedManager.updateItem(currentItem, mediaFile, feed);
// do logging
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, feed, feedManager);
// If there were no items and the user doesn't want to save the
// first item, go back to the decision whether to make the feed
// internally or subscribe to an external feed.
if (!feed.hasItems()) {
feedManager.updateFeedMode(null, feed);
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 == naviCtr && event instanceof NavigationEvent) {
List<? extends Dated> selItems = ((NavigationEvent) event).getSelectedItems();
List<Item> items = new ArrayList<Item>();
for (Dated item : selItems) {
if (item instanceof Item) {
items.add((Item) item);
}
}
// make sure items are sorted properly
Collections.sort(items, new ItemPublishDateComparator());
helper.setSelectedItems(items);
vcItems.setDirty(true);
mainPanel.setContent(vcItems);
} else if (source == itemCtr) {
if (event == Event.BACK_EVENT) {
mainPanel.setContent(vcItems);
}
} 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();
ItemController myItemCtr = displayItemController(ureq, item);
myItemCtr.activate(ureq, ItemController.ACTIVATION_KEY_COMMENTS);
}
}
}