use of jetbrains.communicator.ide.CanceledException 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);
}
}
use of jetbrains.communicator.ide.CanceledException in project intellij-plugins by JetBrains.
the class Helper method doGetProjectsData.
public static ProjectsData doGetProjectsData(final Transport transport, final User user, IDEFacade ideFacade) {
final ProjectsData[] result = new ProjectsData[] { ProjectsData.NULL };
if (user.isOnline()) {
try {
UIUtil.run(ideFacade, StringUtil.getMsg("ViewFilesCommand.title", user.getDisplayName()), new Runnable() {
@Override
public void run() {
final Semaphore semaphore = new Semaphore(1);
try {
semaphore.acquire();
transport.sendXmlMessage(user, new GetProjectsDataXmlMessage(result) {
@Override
public void processResponse(Element responseElement) {
super.processResponse(responseElement);
semaphore.release();
}
});
semaphore.tryAcquire(getWaitTimeout(), TimeUnit.MILLISECONDS);
} catch (InterruptedException ignored) {
}
}
});
} catch (CanceledException ignored) {
//
}
}
return result[0];
}
use of jetbrains.communicator.ide.CanceledException in project intellij-plugins by JetBrains.
the class Helper method fillVFileContent.
public static void fillVFileContent(final Transport transport, final User user, final VFile vFile, IDEFacade ideFacade) {
if (user.isOnline()) {
try {
UIUtil.run(ideFacade, StringUtil.getMsg("GetVFileContents.title"), new Runnable() {
@Override
public void run() {
final Semaphore semaphore = new Semaphore(1);
try {
semaphore.acquire();
transport.sendXmlMessage(user, new GetVFileContentsXmlMessage(vFile) {
@Override
public void processResponse(Element responseElement) {
super.processResponse(responseElement);
semaphore.release();
}
});
semaphore.tryAcquire(getWaitTimeout(), TimeUnit.MILLISECONDS);
} catch (InterruptedException ignored) {
// noop
}
}
});
} catch (CanceledException e) {
LOG.info(e.getMessage(), e);
}
if (vFile.getContents() == null) {
String secondParamForFailMessage = user.getDisplayName();
String address = transport.getAddressString(user);
if (!com.intellij.openapi.util.text.StringUtil.isEmptyOrSpaces(address)) {
secondParamForFailMessage += " from " + address;
}
ideFacade.showMessage(StringUtil.FAILED_TITLE, StringUtil.getMsg("GetVFileContents.fail", vFile.getDisplayName(), secondParamForFailMessage));
}
}
}
Aggregations