String displayName = results[3];
ScopeType entityType = ScopeType.valueOf(results[0]);
String uniqueId = results[1];
long streamScopeId = Long.parseLong(results[2]);
typedInScope = new StreamScope(displayName, entityType, uniqueId, streamScopeId);
other.setChecked(true);
autoComplete.setVisible(false);
autoComplete.setDefaultText(OTHER_TEXT);
scopePanel = new StreamScopePanel(typedInScope);
thisBuffered.add(scopePanel);
}
else
{
typedInScope = null;
}
}
});
autoComplete.setDefaultText(OTHER_TEXT);
this.add(autoComplete);
EventBus.getInstance().addObserver(StreamScopeDeletedEvent.getEvent(),
new Observer<StreamScopeDeletedEvent>()
{
public void update(final StreamScopeDeletedEvent event)
{
try
{
if (typedInScope.equals(event.getScope()))
{
autoComplete.setVisible(true);
autoComplete.setDefaultText(OTHER_TEXT);
thisBuffered.remove(scopePanel);
typedInScope = null;
}
}
catch (final Exception ex)
{
int x = 0;
// no logging Im client side. This means a scope
// closed that doesnt have an ID
// Usually by a user who just entered it into
// the create list modal.
// This is necessary because we use a little
// long vs a big Long.
}
}
});
EventBus.getInstance().addObserver(SwitchedToCustomStreamEvent.class,
new Observer<SwitchedToCustomStreamEvent>()
{
public void update(final SwitchedToCustomStreamEvent arg1)
{
if (other.isChecked())
{
selectMyActivityStream();
}
}
});
EventBus.getInstance().addObserver(SwitchedToGroupStreamEvent.getEvent(),
new Observer<SwitchedToGroupStreamEvent>()
{
public void update(final SwitchedToGroupStreamEvent arg1)
{
GroupStreamDTO group = arg1.getView();
// If the group has disabled posting, make "my activity stream" the default destination. The
// one case where this would be the incorrect thing to do is if the user is a group or org
// coordinator. But it is better for coordinators to have to explicitly choose the group
// than the alternative: a non-postable group pre-selected for regular users and their posts
// just going nowhere.
if (!group.isPostable())
{
selectMyActivityStream();
}
else
{
other.setChecked(true);
autoComplete.setVisible(false);
autoComplete.setDefaultText(OTHER_TEXT);
removeScopePanel(thisBuffered);
typedInScope = new StreamScope(ScopeType.GROUP, group.getShortName());
typedInScope.setDisplayName(group.getName());
scopePanel = new StreamScopePanel(typedInScope);
thisBuffered.add(scopePanel);
}