List of usage examples for com.google.gwt.user.client.ui Widget addStyleName
public void addStyleName(String style)
From source file:org.eurekastreams.web.client.ui.common.EditPanel.java
License:Apache License
/** * Constructor./* w w w . j a v a 2s . c o m*/ * @param inParent parent (used for hover). * @param inMode edit mode. */ public EditPanel(final Widget inParent, final Mode inMode) { Widget parent = inParent; parent.addStyleName(StaticResourceBundle.INSTANCE.coreCss().editableItem()); this.addStyleName(StaticResourceBundle.INSTANCE.coreCss().editControls()); boolean isEdit = Mode.EDIT.equals(inMode) || Mode.EDIT_AND_DELETE.equals(inMode); boolean isDelete = Mode.DELETE.equals(inMode) || Mode.EDIT_AND_DELETE.equals(inMode); editPanel.setVisible(isEdit); if (isEdit) { editPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().edit()); this.add(editPanel); } deletePanel.setVisible(isDelete); if (isDelete) { deletePanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().delete()); this.add(deletePanel); } }
From source file:org.eurekastreams.web.client.ui.common.GroupPanel.java
License:Apache License
/** * Constructor./*w ww . j av a 2 s. c om*/ * * @param group * to display * @param showFollowers * to display * @param makeLinkable * whether to display it or not * @param showDescription * Whether to display the description line. */ public GroupPanel(final DomainGroupModelView group, final boolean makeLinkable, final boolean showFollowers, final boolean showDescription) { addStyleName(StaticResourceBundle.INSTANCE.coreCss().connectionItem()); addStyleName(StaticResourceBundle.INSTANCE.coreCss().listItem()); addStyleName(StaticResourceBundle.INSTANCE.coreCss().group()); add(new AvatarLinkPanel(EntityType.GROUP, group.getUniqueId(), group.getAvatarId(), Size.Small)); FlowPanel infoPanel = new FlowPanel(); infoPanel.setStyleName(StaticResourceBundle.INSTANCE.coreCss().connectionItemInfo()); if (!group.isPublic()) { Label icon = new Label(); icon.addStyleName(StaticResourceBundle.INSTANCE.coreCss().privateIcon()); icon.setTitle("Private Group"); infoPanel.add(icon); } Widget name; if (makeLinkable) { String nameUrl = Session.getInstance() .generateUrl(new CreateUrlRequest(Page.GROUPS, group.getShortName())); name = new Hyperlink(group.getName(), nameUrl); } else { name = new Label(group.getName()); } name.setTitle(group.getName()); name.addStyleName(StaticResourceBundle.INSTANCE.coreCss().connectionItemName()); name.addStyleName(StaticResourceBundle.INSTANCE.coreCss().ellipsisChild()); infoPanel.add(name); if (showDescription) { String descriptionText = group.getDescription(); if (descriptionText != null && !descriptionText.isEmpty()) { Label about = new Label(descriptionText); about.setTitle(descriptionText); about.addStyleName(StaticResourceBundle.INSTANCE.coreCss().missionStatement()); about.addStyleName(StaticResourceBundle.INSTANCE.coreCss().oneLineDescription()); about.addStyleName(StaticResourceBundle.INSTANCE.coreCss().ellipsis()); infoPanel.add(about); } } if (showFollowers) { FlowPanel followersPanel = new FlowPanel(); followersPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().connectionItemFollowers()); InlineLabel followers = new InlineLabel("Followers: "); followersPanel.add(followers); InlineLabel followersCount = new InlineLabel(Integer.toString(group.getFollowersCount())); followersCount.addStyleName(StaticResourceBundle.INSTANCE.coreCss().connectionItemFollowersData()); followersPanel.add(followersCount); insertActionSeparator(followersPanel); followersPanel.add(new InlineLabel("Added: ")); DateFormatter dateFormatter = new DateFormatter(new Date()); InlineLabel dateAdded = new InlineLabel(dateFormatter.timeAgo(group.getDateAdded(), true)); dateAdded.addStyleName(StaticResourceBundle.INSTANCE.coreCss().connectionItemFollowersData()); followersPanel.add(dateAdded); infoPanel.add(followersPanel); } infoPanel.add(new FollowPanel(group)); this.add(infoPanel); }
From source file:org.eurekastreams.web.client.ui.common.LeftBarPanel.java
License:Apache License
/** * Add a widget to the panel.//from ww w .j av a 2 s. c o m * * @param widget * the new widget */ public void addChildWidget(final Widget widget) { widget.addStyleName(StaticResourceBundle.INSTANCE.coreCss().leftBarChild()); this.add(widget); }
From source file:org.eurekastreams.web.client.ui.common.notification.rendering.NotificationsRenderer.java
License:Apache License
/** * Creates the widgets for a notification. * * @param notif/*from w ww.j av a 2 s . co m*/ * Notification. * @return Widget to display. */ public Widget render(final ApplicationAlertNotification notif) { // build the main panel Panel main = new FlowPanel(); main.addStyleName(StaticResourceBundle.INSTANCE.coreCss().notifEntry()); if (!notif.isRead()) { main.addStyleName(StaticResourceBundle.INSTANCE.coreCss().notifEntryUnread()); } // -- icon side -- Widget icon = new Label(); icon.addStyleName(StaticResourceBundle.INSTANCE.coreCss().icon()); main.add(icon); // -- text side -- Panel textPanel = new FlowPanel(); textPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().notifTextSide()); main.add(textPanel); // build the message text NotificationMessageRenderer msgRenderer = messageRenderers.get(notif.getNotificiationType()); if (msgRenderer != null) { textPanel.add(msgRenderer.render(notif)); main.addStyleName(msgRenderer.getStyleName()); } // build the time Label when = new Label(dateFormatter.timeAgo(notif.getNotificationDate())); when.addStyleName(StaticResourceBundle.INSTANCE.coreCss().notifTimestamp()); textPanel.add(when); return main; }
From source file:org.eurekastreams.web.client.ui.common.PersonPanel.java
License:Apache License
/** * Constructor.//from w w w .j a va2 s .c om * * @param person * to display * @param showFollowers * to display * @param makeLinkable * whether to display it or not * @param showDescription * Whether to display the description line. * @param showEmail * Whether or not the email address should be shown. */ public PersonPanel(final PersonModelView person, final boolean makeLinkable, final boolean showFollowers, final boolean showDescription, final boolean showEmail) { addStyleName(StaticResourceBundle.INSTANCE.coreCss().connectionItem()); addStyleName(StaticResourceBundle.INSTANCE.coreCss().listItem()); addStyleName(StaticResourceBundle.INSTANCE.coreCss().person()); add(AvatarLinkPanel.create(person, Size.Small)); FlowPanel infoPanel = new FlowPanel(); infoPanel.setStyleName(StaticResourceBundle.INSTANCE.coreCss().connectionItemInfo()); Widget name; if (makeLinkable) { String nameUrl = Session.getInstance() .generateUrl(new CreateUrlRequest(Page.PEOPLE, person.getAccountId())); name = new Hyperlink(person.getDisplayName(), nameUrl); } else { name = new Label(person.getDisplayName()); } name.setTitle(person.getDisplayName()); name.addStyleName(StaticResourceBundle.INSTANCE.coreCss().connectionItemName()); name.addStyleName(StaticResourceBundle.INSTANCE.coreCss().ellipsisChild()); Label title = new Label(person.getTitle()); title.addStyleName(StaticResourceBundle.INSTANCE.coreCss().connectionItemTitle()); title.addStyleName(StaticResourceBundle.INSTANCE.coreCss().ellipsis()); infoPanel.add(name); infoPanel.add(title); if (showDescription) { String descriptionText = person.getDescription(); if (descriptionText != null && !descriptionText.isEmpty()) { Label about = new Label(descriptionText); about.setTitle(descriptionText); about.addStyleName(StaticResourceBundle.INSTANCE.coreCss().shortBio()); about.addStyleName(StaticResourceBundle.INSTANCE.coreCss().ellipsis()); infoPanel.add(about); } } if (showFollowers) { FlowPanel followersPanel = new FlowPanel(); followersPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().connectionItemFollowers()); InlineLabel followers = new InlineLabel("Followers: "); followersPanel.add(followers); InlineLabel followersCount = new InlineLabel(Integer.toString(person.getFollowersCount())); followersCount.addStyleName(StaticResourceBundle.INSTANCE.coreCss().connectionItemFollowersData()); followersPanel.add(followersCount); insertActionSeparator(followersPanel); followersPanel.add(new InlineLabel("Added: ")); DateFormatter dateFormatter = new DateFormatter(new Date()); InlineLabel dateAdded = new InlineLabel(dateFormatter.timeAgo(person.getDateAdded(), true)); dateAdded.addStyleName(StaticResourceBundle.INSTANCE.coreCss().connectionItemFollowersData()); followersPanel.add(dateAdded); infoPanel.add(followersPanel); } if (showEmail) { String emailText = person.getEmail(); if (emailText != null && !emailText.isEmpty()) { Label email = new Label(emailText); email.addStyleName(StaticResourceBundle.INSTANCE.coreCss().email()); email.addStyleName(StaticResourceBundle.INSTANCE.coreCss().extendedInfo()); infoPanel.add(email); } } if (Session.getInstance().getCurrentPerson().getId() != person.getId()) { infoPanel.add(new FollowPanel(person)); } this.add(infoPanel); }
From source file:org.eurekastreams.web.client.ui.common.stream.comments.CommentPanel.java
License:Apache License
/** * Default constructor.//from www . jav a 2 s. c o m * * @param comment * the comment. * @param truncate * If long comments should be truncated. */ public CommentPanel(final CommentDTO comment, final boolean truncate) { final FlowPanel commentContainer = new FlowPanel(); commentContainer.addStyleName(StaticResourceBundle.INSTANCE.coreCss().messageComment()); StreamEntityDTO author = new StreamEntityDTO(EntityType.PERSON, comment.getAuthorAccountId()); author.setAvatarId(comment.getAuthorAvatarId()); author.setActive(comment.isAuthorActive()); author.setDisplayName(comment.getAuthorDisplayName()); commentContainer.add(AvatarLinkPanel.create(author, Size.VerySmall)); FlowPanel body = new FlowPanel(); body.addStyleName(StaticResourceBundle.INSTANCE.coreCss().body()); commentContainer.add(body); Widget authorName = RenderUtilities.renderEntityName(author, ""); authorName.addStyleName(StaticResourceBundle.INSTANCE.coreCss().messageCommentAuthor()); body.add(authorName); // parse the comment content ContentSegment segments = new ContentParser().split(comment.getBody().trim()); boolean oversize = truncate && isTooLong(segments); // build/display the comment content, truncating if too long final ComplexPanel textContainer = new FlowPanel(); textContainer.addStyleName(StaticResourceBundle.INSTANCE.coreCss().messageCommentText()); body.add(textContainer); // render only up to the limit Widget shortTextWidget = null; int size = 0; ContentSegment segment = segments; for (; segment != null; segment = segment.getNext()) { // check for when to stop if (oversize && !segment.isTag()) { int spaceLeft = TRUNCATE_LENGTH - size; int contentLength = segment.getContent().length(); if (contentLength > spaceLeft) { if (segment.isText()) { String shortText = getTruncatedText(segment.getContent(), spaceLeft); if (shortText != null) { shortTextWidget = new InlineLabel(shortText); textContainer.add(shortTextWidget); } } break; } size += contentLength; } contentRenderer.renderSegment(segment, textContainer, searchLinkBuilder); } final ContentSegment remainingSegments = segment; final Widget shortTextToReplace = shortTextWidget; // if too long, add a ... and "show more" link if (oversize) { final InlineLabel ellipsis = new InlineLabel("..."); body.add(ellipsis); final InlineLabel more = new InlineLabel("show more"); more.addStyleName(StaticResourceBundle.INSTANCE.coreCss().showMoreCommentLink()); more.addStyleName(StaticResourceBundle.INSTANCE.coreCss().linkedLabel()); more.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent inEvent) { // remove the truncated segment, ... and "show more" if (shortTextToReplace != null) { shortTextToReplace.removeFromParent(); } more.removeFromParent(); ellipsis.removeFromParent(); // render the rest of the content contentRenderer.renderList(remainingSegments, textContainer, searchLinkBuilder); } }); body.add(more); } // timestamp and actions Panel timestampActions = new FlowPanel(); timestampActions.addStyleName(StaticResourceBundle.INSTANCE.coreCss().commentTimestamp()); body.add(timestampActions); DateFormatter dateFormatter = new DateFormatter(new Date()); Label dateLink = new InlineLabel(dateFormatter.timeAgo(comment.getTimeSent())); dateLink.addStyleName(StaticResourceBundle.INSTANCE.coreCss().commentTimestamp()); timestampActions.add(dateLink); Panel actionsPanel = new FlowPanel(); timestampActions.add(actionsPanel); if (comment.isDeletable()) { Label sep = new InlineLabel("\u2219"); sep.addStyleName(StaticResourceBundle.INSTANCE.coreCss().actionLinkSeparator()); actionsPanel.add(sep); Label deleteLink = new InlineLabel("Delete"); deleteLink.addStyleName(StaticResourceBundle.INSTANCE.coreCss().delete()); deleteLink.addStyleName(StaticResourceBundle.INSTANCE.coreCss().linkedLabel()); actionsPanel.add(deleteLink); deleteLink.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent event) { if (jsniFacade.confirm("Are you sure you want to delete this comment?")) { Session.getInstance().getActionProcessor().makeRequest("deleteComment", comment.getId(), new AsyncCallback<Boolean>() { /* * implement the async call back methods */ public void onFailure(final Throwable caught) { // No failure state. } public void onSuccess(final Boolean result) { effects.fadeOut(commentContainer.getElement(), true); Session.getInstance().getEventBus() .notifyObservers(new CommentDeletedEvent(comment.getActivityId())); } }); } } }); } initWidget(commentContainer); }
From source file:org.eurekastreams.web.client.ui.common.stream.comments.PostCommentPanel.java
License:Apache License
/** * Activate the control.// ww w . j ava2 s .c om */ public void activate() { clear(); this.setVisible(true); Widget avatar = new AvatarWidget(Session.getInstance().getCurrentPerson().getAvatarId(), EntityType.PERSON, Size.VerySmall); avatar.addStyleName(StaticResourceBundle.INSTANCE.coreCss().avatar()); this.add(avatar); FlowPanel body = new FlowPanel(); body.addStyleName(StaticResourceBundle.INSTANCE.coreCss().body()); SimplePanel boxWrapper = new SimplePanel(); boxWrapper.addStyleName(StaticResourceBundle.INSTANCE.coreCss().boxWrapper()); commentBox = new ExtendedTextArea(true); boxWrapper.add(commentBox); body.add(boxWrapper); commentBox.setFocus(true); countDown = new Label(Integer.toString(MAXLENGTH)); countDown.addStyleName(StaticResourceBundle.INSTANCE.coreCss().charactersRemaining()); body.add(countDown); post = new PushButton("post"); post.addStyleName(StaticResourceBundle.INSTANCE.coreCss().postButton()); post.addStyleName(StaticResourceBundle.INSTANCE.coreCss().inactive()); body.add(post); final FlowPanel warning = new FlowPanel(); warning.addStyleName(StaticResourceBundle.INSTANCE.coreCss().warning()); warning.addStyleName(StaticResourceBundle.INSTANCE.coreCss().hidden()); body.add(warning); Session.getInstance().getEventBus().addObserver(GotSystemSettingsResponseEvent.class, new Observer<GotSystemSettingsResponseEvent>() { public void update(final GotSystemSettingsResponseEvent event) { String text = event.getResponse().getContentWarningText(); if (text != null && !text.isEmpty()) { warning.removeStyleName(StaticResourceBundle.INSTANCE.coreCss().hidden()); warning.getElement().setInnerHTML(text); } } }); SystemSettingsModel.getInstance().fetch(null, true); post.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent event) { fullCollapse = false; if (!inactive) { unActivate(); CommentDTO comment = new CommentDTO(); comment.setBody(commentBox.getText()); comment.setActivityId(messageId); Session.getInstance().getActionProcessor().makeRequest("postActivityCommentAction", comment, new AsyncCallback<CommentDTO>() { /* implement the async call back methods */ public void onFailure(final Throwable caught) { } public void onSuccess(final CommentDTO result) { ActivityModel.getInstance().clearCache(); Session.getInstance().getEventBus() .notifyObservers(new CommentAddedEvent(result, messageId)); } }); } } }); this.add(body); commentBox.setFocus(true); nativeSetFocus(commentBox.getElement()); commentBox.addBlurHandler(new BlurHandler() { public void onBlur(final BlurEvent arg0) { TimerFactory timerFactory = new TimerFactory(); timerFactory.runTimer(BLUR_DELAY, new TimerHandler() { public void run() { if (commentBox.getText().length() == 0) { unActivate(); } } }); } }); commentBox.addKeyDownHandler(new KeyDownHandler() { public void onKeyDown(final KeyDownEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) { unActivate(); } else if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER && event.isControlKeyDown()) { post.getElement().dispatchEvent( Document.get().createClickEvent(1, 0, 0, 0, 0, false, false, false, false)); event.preventDefault(); event.stopPropagation(); } } }); commentBox.addKeyUpHandler(new KeyUpHandler() { public void onKeyUp(final KeyUpEvent event) { onCommentChanges(); } }); commentBox.addValueChangeHandler(new ValueChangeHandler<String>() { public void onValueChange(final ValueChangeEvent<String> inArg0) { onCommentChanges(); } }); commentBox.addChangeHandler(new ChangeHandler() { public void onChange(final ChangeEvent event) { onCommentChanges(); } }); }
From source file:org.eurekastreams.web.client.ui.common.stream.renderers.object.FileRenderer.java
License:Apache License
/** * {@inheritDoc}/*from w w w .ja v a 2 s. c om*/ */ public Widget getAttachmentWidget(final ActivityDTO activity) { HashMap<String, String> props = activity.getBaseObjectProperties(); String title = props.get("targetTitle"); String url = props.get("targetUrl"); String source = props.get("source"); String fileExt = getFileExt(url); FlowPanel mainPanel = new FlowPanel(); mainPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().icon()); mainPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().messageLink()); mainPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().hasThumbnail()); if (fileExt != null) { mainPanel.addStyleName("icon-" + fileExt); } FlowPanel line; Label text; Widget link; link = new Anchor(title, url); link.addStyleName(StaticResourceBundle.INSTANCE.coreCss().title()); mainPanel.add(link); // source line line = new FlowPanel(); line.addStyleName(StaticResourceBundle.INSTANCE.coreCss().url()); text = new InlineLabel("source: "); line.add(text); link = new Anchor(source, source); line.add(link); mainPanel.add(line); // "modified by" line String authorName = props.get("modifiedByDisplayName"); if (authorName != null) { String authorAccountId = props.get("modifiedByAccountId"); if (authorAccountId != null) { line = new FlowPanel(); line.addStyleName(StaticResourceBundle.INSTANCE.coreCss().url()); text = new InlineLabel("Modified by: "); line.add(text); String authorUrl = Session.getInstance() .generateUrl(new CreateUrlRequest(Page.PEOPLE, authorAccountId)); link = new InlineHyperlink(authorName, authorUrl); line.add(link); mainPanel.add(line); } else { text = new Label("Modified by: " + authorName); text.addStyleName(StaticResourceBundle.INSTANCE.coreCss().url()); mainPanel.add(text); } } return mainPanel; }
From source file:org.eurekastreams.web.client.ui.common.stream.renderers.StickyActivityRenderer.java
License:Apache License
/** * Builds the action links line.// w w w . java2s . c o m * * @param msg * The message. * @param verbRenderer * Renderer for the message's verb. * @return The actions panel. */ private Widget buildActionsLine(final ActivityDTO msg, final VerbRenderer verbRenderer) { StreamEntityDTO destinationStream = msg.getDestinationStream(); // timestamp and actions Panel timestampActions = new FlowPanel(); timestampActions.addStyleName(StaticResourceBundle.INSTANCE.coreCss().messageTimestampActionsArea()); // Hijack this property and use to show lock icon for private activity. if (!msg.isShareable()) { Label lockIcon = new Label(""); lockIcon.addStyleName(StaticResourceBundle.INSTANCE.coreCss().privateIcon()); timestampActions.add(lockIcon); } // create timestamp as permalink String date = new DateFormatter(new Date()).timeAgo(msg.getPostedTime()); Widget dateLink; String permalinkUrl = activityLinkBuilder.buildActivityPermalink(msg.getId(), destinationStream.getType(), destinationStream.getUniqueIdentifier()); dateLink = new InlineHyperlink(date, permalinkUrl); dateLink.addStyleName(StaticResourceBundle.INSTANCE.coreCss().messageTimestampLink()); timestampActions.add(dateLink); if (msg.getAppName() != null) { String appSource = msg.getAppSource(); if (appSource != null) { FlowPanel viaPanel = new FlowPanel(); viaPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().viaMetadata()); viaPanel.add(new InlineLabel("via ")); viaPanel.add(new Anchor(msg.getAppName(), appSource)); timestampActions.add(viaPanel); } else { InlineLabel viaLine = new InlineLabel("via " + msg.getAppName()); viaLine.addStyleName(StaticResourceBundle.INSTANCE.coreCss().viaMetadata()); timestampActions.add(viaLine); } // TODO: If appSource is not supplied, the link should go to the respective galleries for apps and plugins. // However, the app galery requires knowing the start page tab id, and the worthwhile plugin gallery is only // available to coordinators. } ComplexPanel actionsPanel = new FlowPanel(); actionsPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().messageActionsArea()); // Show comments InlineHyperlink showCommentsLink = new InlineHyperlink("Show Comments", permalinkUrl); actionsPanel.add(showCommentsLink); // Share if (verbRenderer.getAllowShare() && msg.isShareable()) { insertActionSeparator(actionsPanel, null); Label shareLink = new InlineLabel("Share"); shareLink.addStyleName(StaticResourceBundle.INSTANCE.coreCss().linkedLabel()); actionsPanel.add(shareLink); shareLink.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent event) { Dialog.showCentered(new ShareMessageDialogContent(msg)); } }); } // Unstick // Note: using the cheating way: always create the link, let CSS hide it unless the user is actually a // coordinator insertActionSeparator(actionsPanel, StaticResourceBundle.INSTANCE.coreCss().ownerOnlyInline()); Label link = new InlineLabel("Unstick"); link.addStyleName(StaticResourceBundle.INSTANCE.coreCss().linkedLabel()); link.addStyleName(StaticResourceBundle.INSTANCE.coreCss().ownerOnlyInline()); actionsPanel.add(link); link.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent event) { GroupStickyActivityModel.getInstance().delete(msg.getDestinationStream().getDestinationEntityId()); } }); timestampActions.add(actionsPanel); return timestampActions; }
From source file:org.eurekastreams.web.client.ui.common.stream.renderers.StreamMessageItemRenderer.java
License:Apache License
/** * Render a message item.//w w w.j ava 2 s . c o m * * @param msg * the message item. * * @return the rendered item as a FlowPanel. */ public Panel render(final ActivityDTO msg) { boolean showRecipientInThisInstance; switch (showRecipientInStream) { case YES: // YES: show recipients unless it's a user posting to their own stream (don't want to see // "John Doe to John Doe") showRecipientInThisInstance = msg.getDestinationStream().getType() != msg.getActor().getEntityType() || !msg.getDestinationStream().getUniqueIdentifier() .equals(msg.getActor().getUniqueIdentifier()); break; case RESOURCE_ONLY: // RESOURCE_ONLY: Only show the destination if it was a post to a resource stream - this is to handle posts // from the Comment Widget to resource streams which are being shown in the author's personal stream due to // the user selecting the "Post to Eureka" box. The condition in the code doesn't exactly match the // described condition -- the code only checks for resource posts -- but that is the only scenario in which // resource posts will be encountered here. showRecipientInThisInstance = (msg.getDestinationStream().getType() == EntityType.RESOURCE); break; case NO: default: showRecipientInThisInstance = false; // @SuppressWarnings("unused") // int thisIsImpossibleBecauseThereAreNoOtherValuesButCheckstyleIsTooAnnoyingToUnderstandThat = 1; } Panel mainPanel = new FlowPanel(); mainPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().streamMessageItem()); mainPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().listItem()); mainPanel.addStyleName(state.toString()); VerbRenderer verbRenderer = verbDictionary.get(msg.getVerb()); verbRenderer.setup(objectDictionary, msg, state, showRecipientInThisInstance); boolean doManageFlagged = showManageFlagged && !state.equals(State.READONLY) && msg.isDeletable(); // left column items Panel leftColumn = null; if (doManageFlagged) { leftColumn = new FlowPanel(); leftColumn.addStyleName(StaticResourceBundle.INSTANCE.coreCss().leftColumn()); mainPanel.add(leftColumn); } // avatar Widget avatar = verbRenderer.getAvatar(); if (avatar != null) { Panel parent = leftColumn == null ? mainPanel : leftColumn; parent.add(avatar); } if (doManageFlagged) { leftColumn.add(buildManageFlaggedControls(msg, mainPanel)); } FlowPanel msgContent = new FlowPanel(); msgContent.addStyleName(StaticResourceBundle.INSTANCE.coreCss().description()); mainPanel.add(msgContent); FlowPanel xPanel = new FlowPanel(); xPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().messageXPanel()); msgContent.add(xPanel); FlowPanel xPanelOptions = new FlowPanel(); xPanel.add(xPanelOptions); // Delete if (!state.equals(State.READONLY) && msg.isDeletable()) { Label deleteLink = new Label("Delete"); xPanelOptions.add(deleteLink); setupDeleteClickHandler(deleteLink, msg, mainPanel); } CommentsListPanel commentsPanel = null; if (!state.equals(State.READONLY)) { commentsPanel = new CommentsListPanel(msg.getCommentCount(), msg.getEntityId(), msg.isCommentable(), !singleView); } // row for who posted Panel sourceMetaData = new FlowPanel(); sourceMetaData.addStyleName(StaticResourceBundle.INSTANCE.coreCss().messageMetadataSource()); for (StatefulRenderer itemRenderer : verbRenderer.getSourceMetaDataItemRenderers()) { Widget metaDataItem = itemRenderer.render(); if (metaDataItem != null) { sourceMetaData.add(metaDataItem); } } msgContent.add(sourceMetaData); // content FlowPanel nonMetaData = new FlowPanel(); nonMetaData.addStyleName(state.toString()); Widget content = verbRenderer.getContent(); if (content != null) { nonMetaData.add(content); msgContent.add(nonMetaData); } // additional metadata FlowPanel metaData = new FlowPanel(); metaData.addStyleName(StaticResourceBundle.INSTANCE.coreCss().messageMetadataAdditional()); for (StatefulRenderer itemRenderer : verbRenderer.getMetaDataItemRenderers()) { Widget metaDataItem = itemRenderer.render(); if (metaDataItem != null) { metaData.add(metaDataItem); } } if (metaData.getWidgetCount() > 0) { msgContent.add(metaData); } // timestamp and actions Panel timestampActions = new FlowPanel(); timestampActions.addStyleName(StaticResourceBundle.INSTANCE.coreCss().messageTimestampActionsArea()); // Hijack this property and use to show lock icon for private activity. if (!msg.isShareable()) { Label lockIcon = new Label(""); lockIcon.addStyleName(StaticResourceBundle.INSTANCE.coreCss().privateIcon()); timestampActions.add(lockIcon); } String date = new DateFormatter(new Date()).timeAgo(msg.getPostedTime()); Widget dateLink; if (createPermalink) { String permalinkUrl = activityLinkBuilder.buildActivityPermalink(msg.getId(), msg.getDestinationStream().getType(), msg.getDestinationStream().getUniqueIdentifier()); dateLink = new InlineHyperlink(date, permalinkUrl); } else { dateLink = new InlineLabel(date); } dateLink.addStyleName(StaticResourceBundle.INSTANCE.coreCss().messageTimestampLink()); timestampActions.add(dateLink); if (msg.getAppName() != null) { String appSource = msg.getAppSource(); if (appSource != null) { FlowPanel viaPanel = new FlowPanel(); viaPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().viaMetadata()); viaPanel.add(new InlineLabel("via ")); viaPanel.add(new Anchor(msg.getAppName(), appSource)); timestampActions.add(viaPanel); } else { InlineLabel viaLine = new InlineLabel("via " + msg.getAppName()); viaLine.addStyleName(StaticResourceBundle.INSTANCE.coreCss().viaMetadata()); timestampActions.add(viaLine); } // TODO: If appSource is not supplied, the link should go to the respective galleries for apps and plugins. // However, the app galery requires knowing the start page tab id, and the worthwhile plugin gallery is only // available to coordinators. } if (verbRenderer.getAllowLike()) { LikeCountWidget likeCount = new LikeCountWidget(msg.getEntityId(), msg.getLikeCount(), msg.getLikers(), msg.isLiked()); timestampActions.add(likeCount); } timestampActions.add(buildActions(msg, mainPanel, commentsPanel, verbRenderer)); msgContent.add(timestampActions); // comments if (commentsPanel != null) { mainPanel.add(commentsPanel); if (msg.getComments() != null && !msg.getComments().isEmpty()) { commentsPanel.renderAllComments(msg.getComments()); } else { commentsPanel.renderFirstLast(msg.getFirstComment(), msg.getLastComment(), msg.getDestinationStream().getType(), msg.getDestinationStream().getUniqueIdentifier(), activityLinkBuilder); } if (showComment) { commentsPanel.activatePostComment(); } } return mainPanel; }