Search in sources :

Example 6 with CodePointer

use of jetbrains.communicator.core.vfs.CodePointer in project intellij-plugins by JetBrains.

the class SendCodePointerCommandTest method testEnabled.

public void testEnabled() throws Exception {
    assertFalse(myCommand.isEnabled());
    myCommand.setCodePointer(new CodePointer(0, 0));
    assertFalse(myCommand.isEnabled());
    myCommand.setVFile(VFile.create("a path"));
    assertFalse(myCommand.isEnabled());
    myCommand.setUser(new MockUser());
    assertTrue("Now codePointer, file, user are selected - ready to send", myCommand.isEnabled());
}
Also used : CodePointer(jetbrains.communicator.core.vfs.CodePointer) MockUser(jetbrains.communicator.mock.MockUser)

Example 7 with CodePointer

use of jetbrains.communicator.core.vfs.CodePointer in project intellij-plugins by JetBrains.

the class SendCodePointerCommandTest method testExecute_WithMessage.

public void testExecute_WithMessage() throws Exception {
    final CodePointer codePointerToSend = new CodePointer(0, 0);
    final VFile fileToSend = VFile.create("a path");
    final boolean[] sent = new boolean[1];
    MockUser user = new MockUser() {

        @Override
        public void sendCodeIntervalPointer(VFile file, CodePointer pointer, String comment, EventBroadcaster eventBroadcaster) {
            sent[0] = true;
            assertSame(fileToSend, file);
            assertSame(codePointerToSend, pointer);
            assertEquals("some message", comment);
        }
    };
    myCommand.setCodePointer(codePointerToSend);
    myCommand.setVFile(fileToSend);
    myCommand.setUser(user);
    myFacadeMock.expects(once()).method("getMessage").will(returnValue("some message"));
    myFacadeMock.expects(once()).method("fillFileContents").with(eq(fileToSend));
    myCommand.execute();
    assertTrue("Should call sendCodeIntervalPointer", sent[0]);
}
Also used : EventBroadcaster(jetbrains.communicator.core.EventBroadcaster) CodePointer(jetbrains.communicator.core.vfs.CodePointer) VFile(jetbrains.communicator.core.vfs.VFile) MockUser(jetbrains.communicator.mock.MockUser)

Example 8 with CodePointer

use of jetbrains.communicator.core.vfs.CodePointer in project intellij-plugins by JetBrains.

the class SendCodePointerCommandTest method testExecute_LocalMessage.

public void testExecute_LocalMessage() throws Exception {
    addEventListener();
    final CodePointer codePointerToSend = new CodePointer(0, 0);
    final VFile fileToSend = VFile.create("a path");
    User user = UserImpl.create("user", MockTransport.NAME);
    myCommand.setCodePointer(codePointerToSend);
    myCommand.setVFile(fileToSend);
    myCommand.setUser(user);
    myFacadeMock.expects(once()).method("getMessage").will(returnValue("some message"));
    myFacadeMock.expects(once()).method("fillFileContents").with(eq(fileToSend));
    myCommand.execute();
    verifySendMessageLocalEvent(user, "some message");
    assertSame(fileToSend, ((SendCodePointerEvent) myEvents.get(0)).getFile());
    assertSame(codePointerToSend, ((SendCodePointerEvent) myEvents.get(0)).getCodePointer());
}
Also used : User(jetbrains.communicator.core.users.User) MockUser(jetbrains.communicator.mock.MockUser) CodePointer(jetbrains.communicator.core.vfs.CodePointer) VFile(jetbrains.communicator.core.vfs.VFile)

Example 9 with CodePointer

use of jetbrains.communicator.core.vfs.CodePointer in project intellij-plugins by JetBrains.

the class SendCodePointerAction method prepareCommand.

protected void prepareCommand(FileCommand command, Editor editor, MutablePicoContainer container) {
    CodePointer codePointer = ActionUtil.getCodePointer(editor);
    ((SendCodePointerCommand) command).setCodePointer(codePointer);
}
Also used : SendCodePointerCommand(jetbrains.communicator.commands.SendCodePointerCommand) CodePointer(jetbrains.communicator.core.vfs.CodePointer)

Example 10 with CodePointer

use of jetbrains.communicator.core.vfs.CodePointer in project intellij-plugins by JetBrains.

the class SendToAction method doActionCommand.

protected void doActionCommand(final User user, final VirtualFile file, final Editor editor) {
    VFile vFile = VFSUtil.createFileFrom(file, editor.getProject());
    if (vFile == null) {
        LOG.info("Unable to send code pointer for " + file);
        return;
    }
    CodePointer codePointer = ActionUtil.getCodePointer(editor);
    SendCodePointerCommand command = Pico.getCommandManager().getCommand(SendCodePointerCommand.class, BaseAction.getContainer(editor.getProject()));
    command.setCodePointer(codePointer);
    command.setVFile(vFile);
    command.setUser(user);
    command.execute();
}
Also used : SendCodePointerCommand(jetbrains.communicator.commands.SendCodePointerCommand) CodePointer(jetbrains.communicator.core.vfs.CodePointer) VFile(jetbrains.communicator.core.vfs.VFile)

Aggregations

CodePointer (jetbrains.communicator.core.vfs.CodePointer)10 VFile (jetbrains.communicator.core.vfs.VFile)6 MockUser (jetbrains.communicator.mock.MockUser)4 SendCodePointerCommand (jetbrains.communicator.commands.SendCodePointerCommand)2 EventBroadcaster (jetbrains.communicator.core.EventBroadcaster)2 LogicalPosition (com.intellij.openapi.editor.LogicalPosition)1 EventVisitor (jetbrains.communicator.core.EventVisitor)1 IDEtalkAdapter (jetbrains.communicator.core.IDEtalkAdapter)1 IDEtalkEvent (jetbrains.communicator.core.IDEtalkEvent)1 LocalMessage (jetbrains.communicator.core.dispatcher.LocalMessage)1 CodePointerEvent (jetbrains.communicator.core.transport.CodePointerEvent)1 User (jetbrains.communicator.core.users.User)1 SendCodePointerEvent (jetbrains.communicator.ide.SendCodePointerEvent)1 IncomingLocalMessage (jetbrains.communicator.idea.sendMessage.IncomingLocalMessage)1 WaitFor (jetbrains.communicator.util.WaitFor)1