Search in sources :

Example 51 with User

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

the class UserTest method testSetGroupWithUserModel.

public void testSetGroupWithUserModel() throws Throwable {
    assertEquals(UserModel.DEFAULT_GROUP, myUser.getGroup());
    addEventListener();
    myUser.setGroup("anotherGroup", myUserModel);
    assertEquals("No events expected when user is not in model", 0, myEvents.size());
    assertEquals("Group should be changed", "anotherGroup", myUser.getGroup());
    myUserModel.addUser(myUser);
    myEvents.clear();
    User userCopy = UserImpl.create("someUser", MockTransport.NAME);
    userCopy.setGroup("alexandria", myUserModel);
    assertEquals("Group should be changed", "alexandria", userCopy.getGroup());
    assertEquals("Group should be changed for user in Model", "alexandria", myUser.getGroup());
    verifyUpdateEvent("group", "anotherGroup", "alexandria");
}
Also used : User(jetbrains.communicator.core.users.User)

Example 52 with User

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

the class UserTree method getToolTipText.

public String getToolTipText(MouseEvent e) {
    TreePath pathForLocation = getPathForLocation(e.getX(), e.getY());
    if (pathForLocation != null) {
        Object userObject = TreeUtils.getUserObject(pathForLocation);
        if (userObject instanceof User) {
            User user = (User) userObject;
            StringBuffer result = new StringBuffer();
            if (!user.getName().equals(user.getDisplayName())) {
                result.append(StringUtil.getMsg("user.tooltip", user.getName())).append("\n");
            }
            Message[] pendingMessages = myLocalMessageDispatcher.getPendingMessages(user);
            if (pendingMessages.length > 0) {
                IdeaLocalMessage ideaLocalMessage = (IdeaLocalMessage) pendingMessages[0];
                result.append(ideaLocalMessage.getTitle());
                if (result.length() > 0 && ideaLocalMessage.getComment().length() > 0) {
                    result.append(": ");
                }
                result.append(ideaLocalMessage.getComment());
            }
            return result.length() == 0 ? super.getToolTipText(e) : result.toString();
        }
    }
    return super.getToolTipText(e);
}
Also used : IdeaLocalMessage(jetbrains.communicator.idea.IdeaLocalMessage) User(jetbrains.communicator.core.users.User) TreePath(javax.swing.tree.TreePath) Message(jetbrains.communicator.core.dispatcher.Message) IdeaLocalMessage(jetbrains.communicator.idea.IdeaLocalMessage)

Example 53 with User

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

the class UserTreeTransferHandler method processUsersImport.

private void processUsersImport(JComponent comp, Transferable t) throws UnsupportedFlavorException, IOException {
    final String targetGroup = getTargetGroup(comp);
    final User[] movedUsers = (User[]) t.getTransferData(UsersTransferable.getMyDataFlavor());
    for (User movedUser : movedUsers) {
        movedUser.setGroup(targetGroup, myUserModel);
    }
}
Also used : User(jetbrains.communicator.core.users.User)

Example 54 with User

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

the class UserTree method onClick.

protected void onClick(TreePath path, Object pathComponent, MouseEvent e) {
    super.onClick(path, pathComponent, e);
    if (e.isShiftDown() || e.isControlDown() || e.isAltDown())
        return;
    myDelivered = false;
    Object userObject = TreeUtils.getUserObject(pathComponent);
    if (userObject instanceof User) {
        User user = (User) userObject;
        deliverLocalMessage(user, path, e);
    }
}
Also used : User(jetbrains.communicator.core.users.User)

Example 55 with User

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

the class JabberUserFinderImpl method findUsers.

@Override
public User[] findUsers(ProgressIndicator progressIndicator) {
    final String currentProjectId = myIdeFacade.getCurrentProjectId();
    List<User> users = new ArrayList<>();
    if (currentProjectId != null) {
        try {
            progressIndicator.setText(StringUtil.getMsg("jabber.findUsers.text"));
            URL url = new URL(myRegistryUrl + "?id=" + currentProjectId);
            InputStream inputStream = url.openStream();
            BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
            String csv = reader.readLine();
            inputStream.close();
            if (csv != null) {
                String[] strings = csv.split(",");
                for (String userId : strings) {
                    if (!com.intellij.openapi.util.text.StringUtil.isEmptyOrSpaces(userId)) {
                        users.add(myUserModel.createUser(userId, JabberTransport.CODE));
                    }
                }
            }
        } catch (MalformedURLException e) {
            LOG.debug(e.getMessage(), e);
        } catch (IOException e) {
            LOG.debug(e.getMessage(), e);
        }
    }
    return users.toArray(new User[users.size()]);
}
Also used : MalformedURLException(java.net.MalformedURLException) User(jetbrains.communicator.core.users.User) InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) URL(java.net.URL)

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