use of jetbrains.communicator.ide.ProgressIndicator 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);
}
}
Aggregations