Search in sources :

Example 91 with LightVirtualFile

use of com.intellij.testFramework.LightVirtualFile in project Perl5-IDEA by Camelcade.

the class PerlInterpreterEditorNotification method createNotificationPanel.

@Nullable
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile virtualFile, @NotNull FileEditor fileEditor) {
    if (virtualFile.getFileType() instanceof PerlFileType && !(virtualFile instanceof LightVirtualFile)) {
        final PerlLocalSettings perlLocalSettings = PerlLocalSettings.getInstance(myProject);
        if (perlLocalSettings.DISABLE_NO_INTERPRETER_WARNING) {
            return null;
        }
        EditorNotificationPanel panel;
        String sdkPath = PerlProjectManager.getSdkPath(myProject, virtualFile);
        if (sdkPath != null && VfsUtil.findFileByIoFile(new File(sdkPath), true) != null) {
            return null;
        }
        panel = new EditorNotificationPanel();
        panel.setText(PerlBundle.message("perl.notification.sdk.not.configured"));
        panel.createActionLabel(PerlBundle.message("perl.notification.configure"), () -> Perl5SettingsConfigurable.open(myProject));
        panel.createActionLabel(PerlBundle.message("perl.notification.disable.notification"), () -> {
            perlLocalSettings.DISABLE_NO_INTERPRETER_WARNING = true;
            EditorNotifications.getInstance(myProject).updateAllNotifications();
        });
        return panel;
    }
    return null;
}
Also used : PerlFileType(com.perl5.lang.perl.fileTypes.PerlFileType) EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) PerlLocalSettings(com.perl5.lang.perl.idea.configuration.settings.PerlLocalSettings) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) Nullable(org.jetbrains.annotations.Nullable)

Example 92 with LightVirtualFile

use of com.intellij.testFramework.LightVirtualFile in project azure-tools-for-java by Microsoft.

the class IDEHelperImpl method createVirtualFile.

@SneakyThrows
private LightVirtualFile createVirtualFile(final String fileId, final String fullName, FileEditorManager manager) {
    final LightVirtualFile virtualFile = new LightVirtualFile(fullName);
    virtualFile.setFileType(FileTypeManager.getInstance().getFileTypeByFileName(fullName));
    virtualFile.setCharset(StandardCharsets.UTF_8);
    virtualFile.putUserData(APP_SERVICE_FILE_ID, fileId);
    virtualFile.setWritable(true);
    return virtualFile;
}
Also used : LightVirtualFile(com.intellij.testFramework.LightVirtualFile) SneakyThrows(lombok.SneakyThrows)

Example 93 with LightVirtualFile

use of com.intellij.testFramework.LightVirtualFile in project azure-tools-for-java by Microsoft.

the class UIHelperImpl method closeSpringCloudAppPropertyView.

public void closeSpringCloudAppPropertyView(@NotNull Object projectObject, String appId) {
    final FileEditorManager fileEditorManager = FileEditorManager.getInstance((Project) projectObject);
    LightVirtualFile file = searchExistingFile(fileEditorManager, SPRING_CLOUD_APP_PROPERTY_TYPE, appId);
    if (file != null) {
        AzureTaskManager.getInstance().runLater(() -> fileEditorManager.closeFile(file));
    }
}
Also used : FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) LightVirtualFile(com.intellij.testFramework.LightVirtualFile)

Example 94 with LightVirtualFile

use of com.intellij.testFramework.LightVirtualFile in project azure-tools-for-java by Microsoft.

the class UIHelperImpl method openSqlServerPropertyView.

@Override
public void openSqlServerPropertyView(@NotNull String id, @NotNull Object project) {
    EventUtil.executeWithLog(ActionConstants.SqlServer.SHOW_PROPERTIES, (operation) -> {
        final ResourceId resourceId = ResourceId.fromString(id);
        final FileEditorManager fileEditorManager = getFileEditorManager(resourceId.subscriptionId(), resourceId.id(), (Project) project);
        if (fileEditorManager == null) {
            return;
        }
        LightVirtualFile itemVirtualFile = searchExistingFile(fileEditorManager, SqlServerPropertyViewProvider.TYPE, resourceId.id());
        if (itemVirtualFile == null) {
            itemVirtualFile = createVirtualFile(resourceId.name(), resourceId.subscriptionId(), resourceId.id());
            itemVirtualFile.setFileType(new AzureFileType(SqlServerPropertyViewProvider.TYPE, AzureIconLoader.loadIcon(AzureIconSymbol.SqlServer.MODULE)));
        }
        FileEditor[] editors = fileEditorManager.openFile(itemVirtualFile, true, true);
        for (FileEditor editor : editors) {
            if (editor.getName().equals(SqlServerPropertyView.ID) && editor instanceof SqlServerPropertyView) {
                ((SqlServerPropertyView) editor).onReadProperty(resourceId.subscriptionId(), resourceId.resourceGroupName(), resourceId.name());
            }
        }
    });
}
Also used : FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) TableFileEditor(com.microsoft.intellij.helpers.storage.TableFileEditor) FileEditor(com.intellij.openapi.fileEditor.FileEditor) QueueFileEditor(com.microsoft.intellij.helpers.storage.QueueFileEditor) BlobExplorerFileEditor(com.microsoft.intellij.helpers.storage.BlobExplorerFileEditor) SqlServerPropertyView(com.microsoft.azure.toolkit.intellij.sqlserver.properties.SqlServerPropertyView) ResourceId(com.azure.resourcemanager.resources.fluentcore.arm.ResourceId) LightVirtualFile(com.intellij.testFramework.LightVirtualFile)

Example 95 with LightVirtualFile

use of com.intellij.testFramework.LightVirtualFile in project azure-tools-for-java by Microsoft.

the class WhatsNewAction method createVirtualFile.

@Nonnull
private static LightVirtualFile createVirtualFile(String content) {
    final FileType fileType = FileTypeManagerEx.getInstance().getFileTypeByExtension("md");
    final LightVirtualFile virtualFile = new LightVirtualFile(AZURE_TOOLKIT_FOR_JAVA);
    virtualFile.setFileType(fileType);
    virtualFile.setContent(null, content, true);
    virtualFile.putUserData(CONTENT_KEY, CONTENT_PATH);
    virtualFile.setWritable(false);
    return virtualFile;
}
Also used : FileType(com.intellij.openapi.fileTypes.FileType) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) Nonnull(javax.annotation.Nonnull)

Aggregations

LightVirtualFile (com.intellij.testFramework.LightVirtualFile)102 VirtualFile (com.intellij.openapi.vfs.VirtualFile)26 NotNull (org.jetbrains.annotations.NotNull)14 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)13 Nullable (org.jetbrains.annotations.Nullable)13 PsiFile (com.intellij.psi.PsiFile)12 Project (com.intellij.openapi.project.Project)11 Document (com.intellij.openapi.editor.Document)9 FileEditor (com.intellij.openapi.fileEditor.FileEditor)8 FileType (com.intellij.openapi.fileTypes.FileType)8 PsiManagerEx (com.intellij.psi.impl.PsiManagerEx)7 FileManager (com.intellij.psi.impl.file.impl.FileManager)7 IpnbFile (org.jetbrains.plugins.ipnb.format.IpnbFile)7 BlobExplorerFileEditor (com.microsoft.intellij.helpers.storage.BlobExplorerFileEditor)6 QueueFileEditor (com.microsoft.intellij.helpers.storage.QueueFileEditor)6 TableFileEditor (com.microsoft.intellij.helpers.storage.TableFileEditor)6 Language (com.intellij.lang.Language)5 PsiFileFactoryImpl (com.intellij.psi.impl.PsiFileFactoryImpl)5 FileElement (com.intellij.psi.impl.source.tree.FileElement)5 FileViewProvider (com.intellij.psi.FileViewProvider)4