Search in sources :

Example 1 with RedisCachePropertyView

use of com.microsoft.azure.toolkit.intellij.redis.RedisCachePropertyView in project azure-tools-for-java by Microsoft.

the class UIHelperImpl method openRedisPropertyView.

@Override
public void openRedisPropertyView(@NotNull RedisCacheNode node) {
    EventUtil.executeWithLog(TelemetryConstants.REDIS, TelemetryConstants.REDIS_READPROP, (operation) -> {
        String redisName = node.getName() != null ? node.getName() : RedisCacheNode.TYPE;
        String sid = node.getSubscriptionId();
        String resId = node.getResourceId();
        if (isSubscriptionIdAndResourceIdEmpty(sid, resId)) {
            return;
        }
        Project project = (Project) node.getProject();
        FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
        if (fileEditorManager == null) {
            showError(CANNOT_GET_FILE_EDITOR_MANAGER, UNABLE_TO_OPEN_EDITOR_WINDOW);
            return;
        }
        LightVirtualFile itemVirtualFile = searchExistingFile(fileEditorManager, RedisCachePropertyViewProvider.TYPE, resId);
        if (itemVirtualFile == null) {
            itemVirtualFile = createVirtualFile(redisName, sid, resId);
            itemVirtualFile.setFileType(new AzureFileType(RedisCachePropertyViewProvider.TYPE, AzureIconLoader.loadIcon(AzureIconSymbol.RedisCache.MODULE)));
        }
        FileEditor[] editors = fileEditorManager.openFile(itemVirtualFile, true, true);
        for (FileEditor editor : editors) {
            if (editor.getName().equals(RedisCachePropertyView.ID) && editor instanceof RedisCachePropertyView) {
                ((RedisCachePropertyView) editor).onReadProperty(sid, resId);
            }
        }
    });
}
Also used : Project(com.intellij.openapi.project.Project) 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) RedisCachePropertyView(com.microsoft.azure.toolkit.intellij.redis.RedisCachePropertyView) LightVirtualFile(com.intellij.testFramework.LightVirtualFile)

Aggregations

FileEditor (com.intellij.openapi.fileEditor.FileEditor)1 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)1 Project (com.intellij.openapi.project.Project)1 LightVirtualFile (com.intellij.testFramework.LightVirtualFile)1 RedisCachePropertyView (com.microsoft.azure.toolkit.intellij.redis.RedisCachePropertyView)1 BlobExplorerFileEditor (com.microsoft.intellij.helpers.storage.BlobExplorerFileEditor)1 QueueFileEditor (com.microsoft.intellij.helpers.storage.QueueFileEditor)1 TableFileEditor (com.microsoft.intellij.helpers.storage.TableFileEditor)1