Search in sources :

Example 11 with User

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"));
}
Also used : User(jetbrains.communicator.core.users.User) MockUser(jetbrains.communicator.mock.MockUser) BaseUserImpl(jetbrains.communicator.core.impl.users.BaseUserImpl) MockUser(jetbrains.communicator.mock.MockUser)

Example 12 with User

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());
}
Also used : User(jetbrains.communicator.core.users.User) MockUser(jetbrains.communicator.mock.MockUser) ArrayList(java.util.ArrayList) BaseUserImpl(jetbrains.communicator.core.impl.users.BaseUserImpl)

Example 13 with User

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()]);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) UserModel(jetbrains.communicator.core.users.UserModel) User(jetbrains.communicator.core.users.User) ActionGroup(com.intellij.openapi.actionSystem.ActionGroup) ArrayList(java.util.ArrayList) Editor(com.intellij.openapi.editor.Editor) AnAction(com.intellij.openapi.actionSystem.AnAction) NotNull(org.jetbrains.annotations.NotNull)

Example 14 with User

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);
    }
}
Also used : Project(com.intellij.openapi.project.Project) MutablePicoContainer(org.picocontainer.MutablePicoContainer) User(jetbrains.communicator.core.users.User) SearchHistoryCommand(jetbrains.communicator.commands.SearchHistoryCommand) IDEtalkMessagesWindow(jetbrains.communicator.idea.IDEtalkMessagesWindow) UserListComponent(jetbrains.communicator.ide.UserListComponent)

Example 15 with User

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;
}
Also used : User(jetbrains.communicator.core.users.User)

Aggregations

User (jetbrains.communicator.core.users.User)64 MockUser (jetbrains.communicator.mock.MockUser)25 UserPresence (jetbrains.communicator.core.users.UserPresence)6 ArrayList (java.util.ArrayList)5 UserEvent (jetbrains.communicator.core.users.UserEvent)5 TreeNode (javax.swing.tree.TreeNode)4 BaseUserImpl (jetbrains.communicator.core.impl.users.BaseUserImpl)4 MockTransport (jetbrains.communicator.mock.MockTransport)4 WaitFor (jetbrains.communicator.util.WaitFor)4 Project (com.intellij.openapi.project.Project)3 TreePath (javax.swing.tree.TreePath)3 IOException (java.io.IOException)2 URL (java.net.URL)2 List (java.util.List)2 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 IDEtalkEvent (jetbrains.communicator.core.IDEtalkEvent)2 LocalMessage (jetbrains.communicator.core.dispatcher.LocalMessage)2 Message (jetbrains.communicator.core.dispatcher.Message)2 Transport (jetbrains.communicator.core.transport.Transport)2 ProjectsData (jetbrains.communicator.core.vfs.ProjectsData)2