Search in sources :

Example 1 with User

use of jetbrains.communicator.core.users.User in project intellij-plugins by JetBrains.

the class FindUsersCommand method execute.

public void execute() {
    final List<User>[] finalUsers = new List[1];
    try {
        myIdeFacade.runLongProcess(StringUtil.getMsg("FindUsersCommand.dialog.title"), new IDEFacade.Process() {

            public void run(ProgressIndicator indicator) {
                List<User> result = new ArrayList<>();
                for (Transport transport : myTransports) {
                    result.addAll(Arrays.asList(transport.findUsers(indicator)));
                }
                finalUsers[0] = result;
            }
        });
    } catch (CanceledException e) {
        return;
    }
    List<User> users = finalUsers[0];
    if (users == null)
        return;
    for (Iterator<User> it = users.iterator(); it.hasNext(); ) {
        User user = it.next();
        if (user.isSelf() || myUserModel.hasUser(user)) {
            it.remove();
        }
    }
    if (users.size() < 1) {
        showNoUsersFoundMessage();
        return;
    }
    UsersInfo usersInfo = myIdeFacade.chooseUsersToBeAdded(users, myUserModel.getGroups());
    User[] toBeAdded = usersInfo.getUsers();
    for (User user : toBeAdded) {
        String group = usersInfo.getGroup();
        if (UserModel.AUTO_GROUP.equals(group)) {
            String[] userProjects = user.getProjects();
            group = userProjects.length > 0 ? userProjects[0] : UserModel.DEFAULT_GROUP;
        }
        user.setGroup(group, myUserModel);
        myUserModel.addUser(user);
    }
}
Also used : CanceledException(jetbrains.communicator.ide.CanceledException) User(jetbrains.communicator.core.users.User) ProgressIndicator(jetbrains.communicator.ide.ProgressIndicator) ArrayList(java.util.ArrayList) List(java.util.List) Transport(jetbrains.communicator.core.transport.Transport) IDEFacade(jetbrains.communicator.ide.IDEFacade)

Example 2 with User

use of jetbrains.communicator.core.users.User in project intellij-plugins by JetBrains.

the class ToggleFileAccessCommand method isSelected.

public boolean isSelected() {
    final Boolean[] val = new Boolean[1];
    doForSelected(new UserAction() {

        public boolean executeAndContinue(User user) {
            val[0] = user.canAccessMyFiles();
            return false;
        }
    });
    return val[0] != null && val[0];
}
Also used : UserAction(jetbrains.communicator.core.users.UserAction) User(jetbrains.communicator.core.users.User)

Example 3 with User

use of jetbrains.communicator.core.users.User in project intellij-plugins by JetBrains.

the class BaseSendCommand method getDefaultTargetUsers.

protected User[] getDefaultTargetUsers() {
    Object[] selectedNodes = myUserListComponent.getSelectedNodes();
    List selectedUsers = new ArrayList();
    for (Object selectedNode : selectedNodes) {
        if (selectedNode instanceof User) {
            selectedUsers.add(selectedNode);
        }
    }
    if (myDefaultTargetUser != null) {
        selectedUsers.add(myDefaultTargetUser);
    }
    return (User[]) selectedUsers.toArray(new User[selectedUsers.size()]);
}
Also used : User(jetbrains.communicator.core.users.User) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 4 with User

use of jetbrains.communicator.core.users.User in project intellij-plugins by JetBrains.

the class JabberUserFinderTest method testRegisterAndFindUser.

public void testRegisterAndFindUser() throws Throwable {
    URL url = new URL(JabberUserFinderImpl.TEST_URL);
    try {
        url.getContent();
    } catch (IOException e) {
        System.out.println("WARNING: " + JabberUserFinderImpl.TEST_URL + " not available");
        return;
    }
    myUserFinder.registerForProject("kir@localhost");
    Thread.sleep(400);
    User[] users = myUserFinder.findUsers(new NullProgressIndicator());
    assertEquals(1, users.length);
    assertEquals("kir@localhost", users[0].getName());
}
Also used : User(jetbrains.communicator.core.users.User) NullProgressIndicator(jetbrains.communicator.ide.NullProgressIndicator) IOException(java.io.IOException) URL(java.net.URL)

Example 5 with User

use of jetbrains.communicator.core.users.User in project intellij-plugins by JetBrains.

the class P2PTransport_SelfOnline_Test method createAnotherOnlineUser.

@Override
protected User createAnotherOnlineUser() throws UnknownHostException {
    mySelf = createSelf();
    User user = myTransport.createUser("kir123@localhost", new OnlineUserInfo(InetAddress.getLocalHost(), myTransport.getPort()));
    myTransport.setOnlineUsers(Arrays.asList(mySelf, user));
    return user;
}
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