Search in sources :

Example 11 with OpenFileDescriptor

use of com.intellij.openapi.fileEditor.OpenFileDescriptor in project smali by JesusFreke.

the class SmaliCodeFragmentFactoryTest method createEditor.

protected Editor createEditor(@NotNull VirtualFile file) {
    PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
    Editor editor = FileEditorManager.getInstance(getProject()).openTextEditor(new OpenFileDescriptor(getProject(), file, 0), false);
    DaemonCodeAnalyzer.getInstance(getProject()).restart();
    ((EditorImpl) editor).setCaretActive();
    return editor;
}
Also used : EditorImpl(com.intellij.openapi.editor.impl.EditorImpl) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor) Editor(com.intellij.openapi.editor.Editor)

Example 12 with OpenFileDescriptor

use of com.intellij.openapi.fileEditor.OpenFileDescriptor in project intellij-community by JetBrains.

the class NewErrorTreeViewPanel method addMessage.

@Override
public void addMessage(int type, @NotNull String[] text, @Nullable String groupName, @NotNull Navigatable navigatable, @Nullable String exportTextPrefix, @Nullable String rendererTextPrefix, @Nullable Object data) {
    if (myIsDisposed) {
        return;
    }
    VirtualFile file = data instanceof VirtualFile ? (VirtualFile) data : null;
    if (file == null && navigatable instanceof OpenFileDescriptor) {
        file = ((OpenFileDescriptor) navigatable).getFile();
    }
    final String exportPrefix = exportTextPrefix == null ? "" : exportTextPrefix;
    final String renderPrefix = rendererTextPrefix == null ? "" : rendererTextPrefix;
    final ErrorTreeElementKind kind = ErrorTreeElementKind.convertMessageFromCompilerErrorType(type);
    myErrorViewStructure.addNavigatableMessage(groupName, navigatable, kind, text, data, exportPrefix, renderPrefix, file);
    myBuilder.updateTree();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor)

Example 13 with OpenFileDescriptor

use of com.intellij.openapi.fileEditor.OpenFileDescriptor in project intellij-community by JetBrains.

the class TestsUIUtil method getOpenFileDescriptor.

private static Navigatable getOpenFileDescriptor(final AbstractTestProxy proxy, final TestConsoleProperties testConsoleProperties, final boolean openFailureLine) {
    final Project project = testConsoleProperties.getProject();
    if (proxy != null) {
        final Location location = proxy.getLocation(project, testConsoleProperties.getScope());
        if (openFailureLine) {
            return proxy.getDescriptor(location, testConsoleProperties);
        }
        final OpenFileDescriptor openFileDescriptor = location == null ? null : location.getOpenFileDescriptor();
        if (openFileDescriptor != null && openFileDescriptor.getFile().isValid()) {
            return openFileDescriptor;
        }
    }
    return null;
}
Also used : Project(com.intellij.openapi.project.Project) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor) Location(com.intellij.execution.Location)

Example 14 with OpenFileDescriptor

use of com.intellij.openapi.fileEditor.OpenFileDescriptor in project intellij-community by JetBrains.

the class OpenFileAction method openFile.

public static void openFile(VirtualFile file, @NotNull Project project) {
    FileEditorProvider[] providers = FileEditorProviderManager.getInstance().getProviders(project, file);
    if (providers.length == 0) {
        String message = IdeBundle.message("error.files.of.this.type.cannot.be.opened", ApplicationNamesInfo.getInstance().getProductName());
        Messages.showErrorDialog(project, message, IdeBundle.message("title.cannot.open.file"));
        return;
    }
    NonProjectFileWritingAccessProvider.allowWriting(file);
    OpenFileDescriptor descriptor = new OpenFileDescriptor(project, file);
    FileEditorManager.getInstance(project).openTextEditor(descriptor, true);
}
Also used : FileEditorProvider(com.intellij.openapi.fileEditor.FileEditorProvider) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor)

Example 15 with OpenFileDescriptor

use of com.intellij.openapi.fileEditor.OpenFileDescriptor in project intellij-community by JetBrains.

the class LightPlatformCodeInsightTestCase method createEditor.

@NotNull
protected static Editor createEditor(@NotNull VirtualFile file) {
    PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
    Editor editor = FileEditorManager.getInstance(getProject()).openTextEditor(new OpenFileDescriptor(getProject(), file, 0), false);
    DaemonCodeAnalyzer.getInstance(getProject()).restart();
    assertNotNull(editor);
    ((EditorImpl) editor).setCaretActive();
    return editor;
}
Also used : EditorImpl(com.intellij.openapi.editor.impl.EditorImpl) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor) Editor(com.intellij.openapi.editor.Editor) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)155 VirtualFile (com.intellij.openapi.vfs.VirtualFile)97 Project (com.intellij.openapi.project.Project)40 Editor (com.intellij.openapi.editor.Editor)30 PsiElement (com.intellij.psi.PsiElement)27 PsiFile (com.intellij.psi.PsiFile)21 Navigatable (com.intellij.pom.Navigatable)19 Nullable (org.jetbrains.annotations.Nullable)18 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)10 Document (com.intellij.openapi.editor.Document)9 FileEditor (com.intellij.openapi.fileEditor.FileEditor)9 TextRange (com.intellij.openapi.util.TextRange)9 IncorrectOperationException (com.intellij.util.IncorrectOperationException)9 File (java.io.File)9 Result (com.intellij.openapi.application.Result)8 EditorImpl (com.intellij.openapi.editor.impl.EditorImpl)8 NotNull (org.jetbrains.annotations.NotNull)6 TemplateBuilder (com.intellij.codeInsight.template.TemplateBuilder)5 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)5 XmlTag (com.intellij.psi.xml.XmlTag)5