private void createReactions() { for (BaseContentItem reactionContentItem : linkedContentItemsByType.get(ContentItemType.REACTION)) { reactions.add( LinkedViewFactory.createView(reactionContentItem, contentItem.getAuthorsString())); assignNavLinkString(reactions, ContentItemType.REACTION.getNavLinkString()); } }
private void createBackground() { for (BaseContentItem backgroundContentItem : linkedContentItemsByType.get(ContentItemType.BACKGROUND)) { background.add( LinkedViewFactory.createView(backgroundContentItem, contentItem.getAuthorsString())); assignNavLinkString(background, ContentItemType.BACKGROUND.getNavLinkString()); } }
private void createImages() { List<AssetContentItem> linkedImages = linkedAssetsByType.get(AssetType.IMAGE); List<AssetContentItem> slideshowImages = new ArrayList<AssetContentItem>(); List<AssetContentItem> thumbnailOnlyImages = new ArrayList<AssetContentItem>(); for (AssetContentItem image : linkedImages) { if (GlobalUtil.isContentEmpty(image.getContent())) { thumbnailOnlyImages.add(image); } else { slideshowImages.add(image); } } if (!slideshowImages.isEmpty()) { AssetContentItem previewImage = slideshowImages.get(0); previewImage.setRelatedAssets(slideshowImages); Widget previewPanel = LinkedViewFactory.createView(previewImage, contentItem.getAuthorsString()); if (previewImage.getImportance() == Importance.HIGH) { importantImages.add(previewPanel); } else { images.add(previewPanel); assignNavLinkString(images, AssetType.IMAGE.getNavLinkString()); } } for (AssetContentItem image : thumbnailOnlyImages) { Widget previewPanel = LinkedViewFactory.createView(image, contentItem.getAuthorsString()); if (image.getImportance() == Importance.HIGH) { importantImages.add(previewPanel); } else { images.add(previewPanel); assignNavLinkString(images, AssetType.IMAGE.getNavLinkString()); } } }
private void createAssets() { for (Entry<AssetType, List<AssetContentItem>> linkedAssets : linkedAssetsByType.entrySet()) { // Render everything except images, which we've already done elsewhere. if (linkedAssets.getKey() != AssetType.IMAGE) { for (AssetContentItem assetContentItem : linkedAssets.getValue()) { Widget view = LinkedViewFactory.createView(assetContentItem, contentItem.getAuthorsString()); if (assetContentItem.getImportance() == Importance.HIGH) { importantAssets.add(view); } else { assets.add(view); assignNavLinkString(view, linkedAssets.getKey().getNavLinkString()); } } } } }
private void createQuotes() { for (BaseContentItem quoteContentItem : linkedContentItemsByType.get(ContentItemType.QUOTE)) { quotes.add(LinkedViewFactory.createView(quoteContentItem, contentItem.getAuthorsString())); assignNavLinkString(quotes, ContentItemType.QUOTE.getNavLinkString()); } }
private void createPlayers() { for (BaseContentItem playerContentItem : linkedContentItemsByType.get(ContentItemType.PLAYER)) { players.add(LinkedViewFactory.createView(playerContentItem, contentItem.getAuthorsString())); assignNavLinkString(players, ContentItemType.PLAYER.getNavLinkString()); } }
/** * A narrative that is linked to an event or another narrative and has to be rendered within it * has to be treated especially, because unlike with other linked content item types, we do want * to show the content items that have been linked to the narrative. We'll only show the linked * content items of the type: Multimedia, Quotes and Players. * * <p>TODO: Reuse the ContainerView here somehow, instead of reimplementing a bunch of stuff. */ private Widget renderLinkedNarrative(NarrativeContentItem narrative) { // The left panel has the narrative headline, byline, summary and body Widget leftPanel = LinkedViewFactory.createView(narrative, contentItem.getAuthorsString()); // The right panel has multimedia, players and quotes FlowPanel rightPanel = new FlowPanel(); rightPanel.addStyleName(Resources.INSTANCE.css().linkedContentItemsPanel()); // Create a map from the different types linked to the narrative to the widgets of content items // of those types that will be rendered Map<ContentItemType, List<Widget>> linkedWidgetsMap = new HashMap<ContentItemType, List<Widget>>(); for (ContentItemType contentItemType : LINKED_TYPES_SHOWN_FOR_NARRATIVES) { linkedWidgetsMap.put(contentItemType, new ArrayList<Widget>()); } List<AssetContentItem> linkedImages = new ArrayList<AssetContentItem>(); for (BaseContentItem linkedContentItem : narrative.getLinkedContentItems()) { if (linkedContentItem != null) { ContentItemType linkedContentItemType = linkedContentItem.getContentItemType(); if (linkedContentItemType == ContentItemType.ASSET && ((AssetContentItem) linkedContentItem).getAssetType() == AssetType.IMAGE) { // Collect all of the images in a list so that they can be shown in a slideshow linkedImages.add((AssetContentItem) linkedContentItem); } else if (LINKED_TYPES_SHOWN_FOR_NARRATIVES.contains(linkedContentItemType)) { // Create a widget for the linked content items and put it in the map linkedWidgetsMap .get(linkedContentItemType) .add(LinkedViewFactory.createView(linkedContentItem, narrative.getAuthorsString())); } } } // First render the images // TODO: this is mostly repeated from 'createImages' below, but // will go away once we get narratives rendering with a ContainerView as well. if (!linkedImages.isEmpty()) { List<AssetContentItem> slideshowImages = new ArrayList<AssetContentItem>(); List<AssetContentItem> thumbnailOnlyImages = new ArrayList<AssetContentItem>(); for (AssetContentItem image : linkedImages) { if (GlobalUtil.isContentEmpty(image.getContent())) { thumbnailOnlyImages.add(image); } else { slideshowImages.add(image); } } if (!slideshowImages.isEmpty()) { AssetContentItem previewImage = slideshowImages.get(0); previewImage.setRelatedAssets(slideshowImages); Widget previewPanel = LinkedViewFactory.createView(previewImage, contentItem.getAuthorsString()); rightPanel.add(previewPanel); } for (AssetContentItem image : thumbnailOnlyImages) { rightPanel.add(LinkedViewFactory.createView(image, contentItem.getAuthorsString())); } } // Then render the rest of the linked content items for (List<Widget> widgetList : linkedWidgetsMap.values()) { for (Widget widget : widgetList) { rightPanel.add(widget); } } FlowPanel linkedNarrativePanel = new FlowPanel(); if (rightPanel.getWidgetCount() > 0) { linkedNarrativePanel.add(rightPanel); } linkedNarrativePanel.add(leftPanel); narrativeWidgetsById.put(narrative.getId(), linkedNarrativePanel); return linkedNarrativePanel; }
private void createData() { for (BaseContentItem dataContentItem : linkedContentItemsByType.get(ContentItemType.DATA)) { data.add(LinkedViewFactory.createView(dataContentItem, contentItem.getAuthorsString())); assignNavLinkString(data, ContentItemType.DATA.getNavLinkString()); } }