PersonModelView person = Session.getInstance().getCurrentPerson();
StreamScope defaultStreamScope = new StreamScope(person.getDisplayName(), ScopeType.PERSON,
person.getAccountId(), person.getStreamId());
final PostToPanel postToPanel = new PostToPanel(defaultStreamScope);
widget.add(postToPanel);
// -- Setup the link display panel (thumbnail selector, field to update title) --
title.addStyleName(StaticResourceBundle.INSTANCE.coreCss().attachLinkTitleEntry());
linkUrlDisplay.addStyleName(StaticResourceBundle.INSTANCE.coreCss().url());
linkDesc.addStyleName(StaticResourceBundle.INSTANCE.coreCss().metaDescription());
FlowPanel linkInfoPanel = new FlowPanel();
linkInfoPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().messageLink());
linkInfoPanel.add(title);
linkInfoPanel.add(linkUrlDisplay);
linkInfoPanel.add(linkDesc);
displayPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().linkPanel());
displayPanel.add(selector);
displayPanel.add(linkInfoPanel);
displayPanel.add(selector.getPagingControls());
widget.add(displayPanel);
final LinkInformation link = new LinkInformation();
link.setDescription(desc);
link.setTitle(inTitle);
link.setUrl(resourceUrl);
try
{
link.setSource(resourceUrl.substring(0, resourceUrl.indexOf('/', 7)));
}
catch (Exception e)
{
link.setSource(resourceUrl);
}
if (thumbs != null)
{
HashSet<String> thumbsSet = new HashSet<String>();
for (String thumb : thumbs)
{
thumbsSet.add(thumb);
}
link.setImageUrls(thumbsSet);
link.setLargestImageUrl(thumbs[0]);
}
onLinkAdded(link);
final FlowPanel postContainer = new FlowPanel();
postContainer.getElement().setAttribute("id", "post-to-stream");
postContainer.addStyleName(StaticResourceBundle.INSTANCE.coreCss().postToStream());
postContainer.addStyleName(StaticResourceBundle.INSTANCE.coreCss().small());
postContainer.addStyleName(StaticResourceBundle.INSTANCE.coreCss().postToStreamContainer());
FlowPanel postInfoContainer = new FlowPanel();
postInfoContainer.addStyleName(StaticResourceBundle.INSTANCE.coreCss().postInfoContainer());
postButton.addStyleName(StaticResourceBundle.INSTANCE.coreCss().postButton());
postInfoContainer.add(postButton);
countDown.setText(Integer.toString(MAXLENGTH));
countDown.addStyleName(StaticResourceBundle.INSTANCE.coreCss().charactersRemaining());
postInfoContainer.add(countDown);
message.setText(defaultText);
// user clicked in message text box
message.addFocusHandler(new FocusHandler()
{
public void onFocus(final FocusEvent inEvent)
{
if ((" " + postContainer.getStyleName() + " ")
.contains(StaticResourceBundle.INSTANCE.coreCss().small()))
{
postContainer.removeStyleName(StaticResourceBundle.INSTANCE.coreCss().small());
message.setText("");
}
}
});
// changes to the message for character countdown
message.addKeystrokeHandler(new KeyUpHandler()
{
public void onKeyUp(final KeyUpEvent inEvent)
{
onCommentChanges();
}
});
message.addValueChangedHandler(new ValueChangeHandler<String>()
{
public void onValueChange(final ValueChangeEvent<String> inEvent)
{
onCommentChanges();
}
});
AvatarWidget avatar = new AvatarWidget(person, EntityType.PERSON, Size.VerySmall);
avatar.addStyleName(StaticResourceBundle.INSTANCE.coreCss().postEntryAvatar());
Panel entryPanel = new FlowPanel();
entryPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().postEntryPanel());
entryPanel.add(avatar);
entryPanel.add(postInfoContainer);
entryPanel.add(message);
postContainer.add(entryPanel);
FlowPanel contentWarningContainer = new FlowPanel();
contentWarningContainer.addStyleName(StaticResourceBundle.INSTANCE.coreCss().contentWarning());
contentWarningContainer.add(new SimplePanel());
final FlowPanel contentWarning = new FlowPanel();
contentWarningContainer.add(contentWarning);
postContainer.add(contentWarningContainer);
Session.getInstance().getEventBus()
.addObserver(GotSystemSettingsResponseEvent.class, new Observer<GotSystemSettingsResponseEvent>()
{
public void update(final GotSystemSettingsResponseEvent event)
{
contentWarning.getElement().setInnerHTML(event.getResponse().getContentWarningText());
}
});
SystemSettingsModel.getInstance().fetch(null, true);
widget.add(postContainer);
EventBus.getInstance().addObserver(MessageStreamAppendEvent.class, new Observer<MessageStreamAppendEvent>()
{
public void update(final MessageStreamAppendEvent arg1)
{
closeWindow();
}
});
postButton.addClickHandler(new ClickHandler()
{
public void onClick(final ClickEvent event)
{
StreamScope scope = postToPanel.getPostScope();
if (scope == null)
{
ErrorPostingMessageToNullScopeEvent error = new ErrorPostingMessageToNullScopeEvent();
error.setErrorMsg("The stream name you entered could not be found");
Session.getInstance().getEventBus().notifyObservers(error);