use of jetbrains.communicator.core.transport.Transport 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.core.transport.Transport in project intellij-plugins by JetBrains.
the class IDEtalkToolWindow method initializeTransports.
private void initializeTransports(String projectName) {
java.util.List transports = Pico.getInstance().getComponentInstancesOfType(Transport.class);
for (Object transport1 : transports) {
Transport transport = (Transport) transport1;
transport.initializeProject(projectName, myContainer);
}
}
use of jetbrains.communicator.core.transport.Transport in project intellij-plugins by JetBrains.
the class UserActivityMonitor method run.
@Override
public void run() {
try {
myThreadDisposed = false;
while (!myStop) {
UserPresence userPresence = calculatePresence();
LOG.debug("Calculated own presence: " + userPresence);
for (Object o : Pico.getInstance().getComponentInstancesOfType(Transport.class)) {
Transport transport = (Transport) o;
if (transport.isOnline()) {
transport.setOwnPresence(userPresence);
}
}
synchronized (myMonitor) {
myMonitor.wait(myRefreshInterval);
}
}
} catch (InterruptedException e) {
LOG.info("Interrupted");
} finally {
myThreadDisposed = true;
}
}
use of jetbrains.communicator.core.transport.Transport in project intellij-plugins by JetBrains.
the class FindUsersCommandTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
myUserModelMock = mock(UserModel.class);
myTransportMock = mock(Transport.class);
myTransportMock1 = mock(Transport.class);
myIDEFacade = new MockIDEFacade();
myUserModelMock.stubs().method("getBroadcaster").will(returnValue(getBroadcaster()));
myCommand = new FindUsersCommand((UserModel) myUserModelMock.proxy(), new Transport[] { (Transport) myTransportMock.proxy(), (Transport) myTransportMock1.proxy() }, myIDEFacade);
assertTrue(myCommand.isEnabled());
assertNotNull(myCommand.getName());
}
use of jetbrains.communicator.core.transport.Transport in project intellij-plugins by JetBrains.
the class TestUtil method testSendXmlMessage_Functional.
public static void testSendXmlMessage_Functional(BaseTestCase testCase, User self, final boolean checkResponse) {
final String[] log = new String[] { "" };
log[0] = "";
final String comment = "��� mes&&<>sage";
MockXmlMessage message = new MockXmlMessage("tagName", "myNamespace") {
@Override
public boolean needsResponse() {
return checkResponse;
}
@Override
public void fillRequest(Element element) {
element.setText(comment);
}
@Override
public void processResponse(Element responseElement) {
log[0] += responseElement.getAttributeValue("foo");
}
};
final MockXmlResponseProvider mockXmlResponseProvider = new MockXmlResponseProvider("tagName", "myNamespace", testCase.getBroadcaster()) {
@Override
public boolean processAndFillResponse(Element response, Element request, Transport transport, String remoteUser) {
log[0] += remoteUser + " " + request.getName() + " " + request.getText();
assertEquals("root element expected", "tagName", request.getName());
response.setAttribute("foo", "gar");
return true;
}
};
Pico.getInstance().registerComponentInstance(mockXmlResponseProvider);
testCase.disposeOnTearDown(new Disposable() {
@Override
public void dispose() {
Pico.getInstance().unregisterComponentByInstance(mockXmlResponseProvider);
}
});
self.sendXmlMessage(message);
new WaitFor(500) {
@Override
protected boolean condition() {
if (checkResponse) {
return log[0].endsWith("gar");
} else {
return log[0].length() > 0;
}
}
};
String expectedLog = self.getName() + " tagName " + comment;
expectedLog += checkResponse ? "gar" : "";
assertEquals("Message expected", expectedLog, log[0]);
}
Aggregations