* @param sharedMessage
* the shared message.
*/
public ShareMessageDialogContent(final ActivityDTO sharedMessage)
{
StreamScope postScope = new StreamScope(ScopeType.PERSON, Session.getInstance().getCurrentPerson()
.getAccountId());
processor = Session.getInstance().getActionProcessor();
actionKeys.put(EntityType.GROUP, "postGroupActivityServiceActionTaskHandler");
actionKeys.put(EntityType.PERSON, "postPersonActivityServiceActionTaskHandler");
body.addStyleName(StaticResourceBundle.INSTANCE.coreCss().shareMessageDialogBody());
Label loading = new Label("Share this activity to your stream or another stream");
loading.setStyleName(StaticResourceBundle.INSTANCE.coreCss().formTitle());
body.add(loading);
errorMsg.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formErrorBox());
errorMsg.setVisible(false);
body.add(errorMsg);
postToPanel = new PostToPanel(postScope, true);
body.add(postToPanel);
StreamMessageItemRenderer messageRenderer = new StreamMessageItemRenderer(ShowRecipient.NO, State.READONLY);
body.add(messageRenderer.render(sharedMessage));
Label messageLabel = new Label("Comment:");
messageLabel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formLabel());
body.add(messageLabel);
commentBox.addStyleName(StaticResourceBundle.INSTANCE.coreCss().messageBox());
body.add(commentBox);
countDown.setText(Integer.toString(MAXLENGTH));
countDown.addStyleName(StaticResourceBundle.INSTANCE.coreCss().charactersRemaining());
body.add(countDown);
final FlowPanel warning = new FlowPanel();
warning.addStyleName(StaticResourceBundle.INSTANCE.coreCss().warning());
body.add(warning);
Session.getInstance().getEventBus()
.addObserver(GotSystemSettingsResponseEvent.class, new Observer<GotSystemSettingsResponseEvent>()
{
public void update(final GotSystemSettingsResponseEvent event)
{
warning.getElement().setInnerHTML(event.getResponse().getContentWarningText());
}
});
SystemSettingsModel.getInstance().fetch(null, true);
share = new Hyperlink("share", History.getToken());
share.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formButton());
share.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formShareButton());
Hyperlink cancel = new Hyperlink("Cancel", History.getToken());
cancel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formButton());
cancel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formCancelButton());
cancel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().shareMessageCancel());
body.add(share);
body.add(cancel);
cancel.addClickHandler(new ClickHandler()
{
public void onClick(final ClickEvent event)
{
close();
}
});
commentBox.addKeyUpHandler(new KeyUpHandler()
{
public void onKeyUp(final KeyUpEvent event)
{
onCommentChanges();
}
});
commentBox.addChangeHandler(new ChangeHandler()
{
public void onChange(final ChangeEvent event)
{
onCommentChanges();
}
});
share.addClickHandler(new ClickHandler()
{
public void onClick(final ClickEvent event)
{
if (!inactive)
{
StreamScope scope = postToPanel.getPostScope();
if (scope != null)
{
hideError();
EntityType recipientType;
if (scope.getScopeType().equals(ScopeType.PERSON))
{
recipientType = EntityType.PERSON;
}
else
{
recipientType = EntityType.GROUP;
}
PostActivityRequest postRequest = new PostActivityRequest(new ActivityDTOPopulator()
.getActivityDTO("", recipientType, scope.getUniqueKey(), new SharePopulator(
sharedMessage, commentBox.getText()), null));
processor.makeRequest(actionKeys.get(recipientType), postRequest,
new AsyncCallback<ActivityDTO>()
{