use of jetbrains.communicator.core.users.User in project intellij-plugins by JetBrains.
the class FindUsersCommandTest method testOnlySelfFound.
public void testOnlySelfFound() throws Exception {
final BaseUserImpl self = new MockUser();
myTransportMock.expects(once()).method("findUsers").will(returnValue(new User[] { self }));
myTransportMock1.expects(once()).method("findUsers").will(returnValue(new User[] { self }));
myCommand.execute();
assertTrue(myIDEFacade.getAndClearLog().startsWith("showMessage"));
}
use of jetbrains.communicator.core.users.User in project intellij-plugins by JetBrains.
the class FindUsersCommandTest method testNewUserFound_AddThisUserToModel.
public void testNewUserFound_AddThisUserToModel() throws Exception {
final BaseUserImpl teddy = setTeddyUserIsFound();
myUserModelMock.expects(once()).method("hasUser").with(eq(teddy)).will(returnValue(false));
myUserModelMock.expects(once()).method("getGroups").will(returnValue(null));
final List<User> userList = new ArrayList<>();
userList.add(teddy);
myIDEFacade.setReturnedData(new FindUsersCommand.UsersInfo(new User[] { teddy }, "new group"));
myUserModelMock.expects(once()).method("addUser").with(eq(teddy));
myUserModelMock.expects(once()).method("findUser").with(eq(teddy.getName()), eq(teddy.getTransportCode())).will(returnValue(teddy));
myCommand.execute();
assertEquals("User group should be updated", "new group", teddy.getGroup());
}
use of jetbrains.communicator.core.users.User in project intellij-plugins by JetBrains.
the class BaseEditorPopup method getChildren.
@NotNull
public AnAction[] getChildren(AnActionEvent e) {
if (e == null)
return EMPTY_ARRAY;
final Editor editor = getEditor(e);
final VirtualFile file = getFile(e);
if (file == null || editor == null)
return EMPTY_ARRAY;
List<AnAction> result = new ArrayList<>();
final UserModel userModel = getUserModel();
String[] groups = userModel.getGroups();
List<String> groupsWithUsers = new ArrayList<>();
for (String group : groups) {
if (userModel.getUsers(group).length > 0) {
groupsWithUsers.add(group);
}
}
if (groupsWithUsers.size() == 1) {
User[] users = userModel.getUsers(groupsWithUsers.get(0));
fillWithUserActions(users, result, file, editor);
} else {
for (String groupsWithUser : groupsWithUsers) {
ActionGroup actionGroup = createGroupWithUsersActionGroup(groupsWithUser, userModel, file, editor);
result.add(actionGroup);
}
}
return result.toArray(new AnAction[result.size()]);
}
use of jetbrains.communicator.core.users.User in project intellij-plugins by JetBrains.
the class SearchHistoryAction method update.
public void update(AnActionEvent e) {
super.update(e);
Project project = getProject(e);
MutablePicoContainer container = getContainer(project);
SearchHistoryCommand command = getCommand(e);
User selectedUser;
if (container != null && project != null && command != null) {
boolean focused = false;
if (IDEtalkMessagesWindowImpl.PLACE_TOOLBAR.equals(e.getPlace())) {
IDEtalkMessagesWindow messagesWindow = project.getComponent(IDEtalkMessagesWindow.class);
selectedUser = messagesWindow.getSelectedUser();
focused = messagesWindow.hasFocus();
} else {
UserListComponent userList = (UserListComponent) container.getComponentInstanceOfType(UserListComponent.class);
selectedUser = userList.getSelectedUser();
focused = userList.getComponent().hasFocus();
}
command.setUser(selectedUser);
e.getPresentation().setEnabled(command.isEnabled() && focused);
}
}
use of jetbrains.communicator.core.users.User in project intellij-plugins by JetBrains.
the class BaseUserImpl method setGroup.
@Override
public void setGroup(final String group, UserModel userModel) {
final String fixedGroup = StringUtil.fixGroup(group);
if (userModel != null) {
User inModel = userModel.findUser(getName(), getTransportCode());
if (inModel != null) {
((BaseUserImpl) inModel).setGroupWithEvent(fixedGroup, userModel.getBroadcaster());
}
}
myGroup = fixedGroup;
}
Aggregations