Search in sources :

Example 1 with VFile

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

the class TestUtil method testSendCodePointer_Functional.

public static void testSendCodePointer_Functional(BaseTestCase testCase, User self) {
    final String[] log = new String[] { "" };
    testCase.getBroadcaster().addListener(new IDEtalkAdapter() {

        @Override
        public void afterChange(IDEtalkEvent event) {
            event.accept(new EventVisitor() {

                @Override
                public void visitCodePointerEvent(CodePointerEvent event) {
                    log[0] += event.getRemoteUser() + ' ';
                    log[0] += event.getComment();
                    log[0] += event.getCodePointer().toString();
                    log[0] += event.getFile().toString();
                }
            });
        }
    });
    testCase.markLastListenerForCleanup();
    log[0] = "";
    CodePointer pointer = new CodePointer(0, 1);
    VFile file = VFile.create("path");
    self.sendCodeIntervalPointer(file, pointer, "comment���< && 53", testCase.getBroadcaster());
    new WaitFor(2000) {

        @Override
        protected boolean condition() {
            return log[0].length() > 0;
        }
    };
    Assert.assertEquals("Code Pointer expected", self.getName() + " comment���< && 53" + pointer + file, log[0]);
}
Also used : EventVisitor(jetbrains.communicator.core.EventVisitor) WaitFor(jetbrains.communicator.util.WaitFor) IDEtalkEvent(jetbrains.communicator.core.IDEtalkEvent) CodePointerEvent(jetbrains.communicator.core.transport.CodePointerEvent) CodePointer(jetbrains.communicator.core.vfs.CodePointer) IDEtalkAdapter(jetbrains.communicator.core.IDEtalkAdapter) VFile(jetbrains.communicator.core.vfs.VFile)

Example 2 with VFile

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

the class ShowDiffCommandTest method testEnabled.

public void testEnabled() throws Exception {
    assertFalse(myCommand.isEnabled());
    myCommand.setUser(new MockUser());
    assertFalse(myCommand.isEnabled());
    VFile vFile = VFile.create("a path");
    myCommand.setVFile(vFile);
    myFacadeMock.expects(once()).method("hasFile").with(eq(vFile)).will(returnValue(false));
    assertFalse(myCommand.isEnabled());
    myFacadeMock.expects(once()).method("hasFile").with(eq(vFile)).will(returnValue(true));
    assertTrue(myCommand.isEnabled());
}
Also used : MockUser(jetbrains.communicator.mock.MockUser) VFile(jetbrains.communicator.core.vfs.VFile)

Example 3 with VFile

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

the class ShowDiffCommandTest method testExecute.

public void testExecute() throws Exception {
    final VFile vFile = VFile.create("a file");
    MockUser user = new MockUser() {

        @Override
        public String getVFile(VFile file, IDEFacade ideFacade) {
            assertSame(vFile, file);
            return "something";
        }
    };
    myCommand.setUser(user);
    myCommand.setVFile(vFile);
    myFacadeMock.expects(once()).method("showDiffFor").with(eq(user), eq(vFile), eq("something"));
    myCommand.execute();
}
Also used : IDEFacade(jetbrains.communicator.ide.IDEFacade) VFile(jetbrains.communicator.core.vfs.VFile) MockUser(jetbrains.communicator.mock.MockUser)

Example 4 with VFile

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

the class AbstractTransportTestCase method testGetFileContent_NoSuchFile.

public void testGetFileContent_NoSuchFile() throws Exception {
    VFile vFile = VFile.create("a path");
    String text = mySelf.getVFile(vFile, myIdeFacade);
    assertNull("No file - no text", text);
}
Also used : VFile(jetbrains.communicator.core.vfs.VFile)

Example 5 with VFile

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

the class BaseEditorAction method update.

public void update(AnActionEvent e) {
    FileEditorManager editorManager = FileEditorManager.getInstance(getProject(e));
    Editor editor = editorManager.getSelectedTextEditor();
    T command = getCommand(e);
    MutablePicoContainer container = getContainer(e);
    if (command != null && editor != null && container != null) {
        VirtualFile file = FileDocumentManager.getInstance().getFile(editor.getDocument());
        if (file != null) {
            VFile vFile = VFSUtil.createFileFrom(file, editor.getProject());
            if (vFile == null) {
                return;
            }
            command.setVFile(vFile);
            setUser(container, command);
            prepareCommand(command, editor, container);
        }
    }
    super.update(e);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) MutablePicoContainer(org.picocontainer.MutablePicoContainer) Editor(com.intellij.openapi.editor.Editor) VFile(jetbrains.communicator.core.vfs.VFile)

Aggregations

VFile (jetbrains.communicator.core.vfs.VFile)24 CodePointer (jetbrains.communicator.core.vfs.CodePointer)6 MockUser (jetbrains.communicator.mock.MockUser)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 EventBroadcaster (jetbrains.communicator.core.EventBroadcaster)2 IDEFacade (jetbrains.communicator.ide.IDEFacade)2 Document (com.intellij.openapi.editor.Document)1 Editor (com.intellij.openapi.editor.Editor)1 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)1 Project (com.intellij.openapi.project.Project)1 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)1 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 SendCodePointerCommand (jetbrains.communicator.commands.SendCodePointerCommand)1 ShowDiffCommand (jetbrains.communicator.commands.ShowDiffCommand)1 EventVisitor (jetbrains.communicator.core.EventVisitor)1 IDEtalkAdapter (jetbrains.communicator.core.IDEtalkAdapter)1 IDEtalkEvent (jetbrains.communicator.core.IDEtalkEvent)1 CodePointerEvent (jetbrains.communicator.core.transport.CodePointerEvent)1