uniqueKeys.add(scope.getUniqueKey());
}
scopeListPanel = new StreamScopeListPanel(inScopes);
final AutoCompleteEntityDropDownPanel autoComplete = new AutoCompleteEntityDropDownPanel(inAutoCompleteUrl);
autoComplete.setMaxLength(inMaxLength);
autoComplete.setOnItemSelectedCommand(new AutoCompleteEntityDropDownPanel.OnItemSelectedCommand()
{
public void itemSelected(final JavaScriptObject obj)
{
if (!getEntityType(obj.toString()).equals("NOTSET"))
{
EventBus.getInstance().notifyObservers(
new StreamScopeAddedEvent(new StreamScope(getDisplayName(obj.toString()), ScopeType
.valueOf(getEntityType(obj.toString())), getUniqueId(obj.toString()), Long
.parseLong(getStreamScopeId(obj.toString())))));
}
}
});
EventBus.getInstance().addObserver(StreamScopeAddedEvent.getEvent(), new Observer<StreamScopeAddedEvent>()
{
public void update(final StreamScopeAddedEvent obj)
{
uniqueKeys.add(obj.getScope().getUniqueKey());
autoComplete.clearText();
if (!allowMultiple || uniqueKeys.size() >= maxItems)
{
autoComplete.setVisible(false);
instructions.setVisible(false);
}
}
});
EventBus.getInstance().addObserver(StreamScopeDeletedEvent.getEvent(), new Observer<StreamScopeDeletedEvent>()
{
public void update(final StreamScopeDeletedEvent obj)
{
uniqueKeys.remove(obj.getScope().getUniqueKey());
if (!allowMultiple || uniqueKeys.size() < maxItems)
{
autoComplete.setVisible(true);
instructions.setVisible(true);
}
}
});
if ((!allowMultiple && !inScopes.isEmpty()) || uniqueKeys.size() >= maxItems)
{
autoComplete.setVisible(false);
instructions.setVisible(false);
}
this.add(listMembers);
this.add(scopeListPanel);