Search in sources :

Example 1 with PROJECT

use of com.redhat.devtools.intellij.common.CommonConstants.PROJECT in project intellij-tekton by redhat-developer.

the class VirtualFileHelper method innerOpenVirtualFileInEditor.

public static void innerOpenVirtualFileInEditor(Project project, String namespace, String name, String content, String kind, boolean edit, boolean readOnly, boolean clean) throws IOException {
    Optional<FileEditor> editor = Arrays.stream(FileEditorManager.getInstance(project).getAllEditors()).filter(fileEditor -> fileEditor.getFile().getName().startsWith(name)).findFirst();
    if (!clean) {
        clean = SettingsState.getInstance().displayCleanedYAMLInEditor;
    }
    if (!editor.isPresent()) {
        createAndOpenVirtualFile(project, namespace, name, content, kind, null, readOnly, clean);
    } else {
        Editor openedEditor = FileEditorManager.getInstance(project).openTextEditor(new OpenFileDescriptor(project, editor.get().getFile()), true);
        if (edit) {
            content = cleanContent(content);
            openedEditor.getDocument().setText(content);
        }
    }
}
Also used : AllowNonProjectEditing(com.redhat.devtools.intellij.common.editor.AllowNonProjectEditing) Arrays(java.util.Arrays) CONTENT(com.redhat.devtools.intellij.common.CommonConstants.CONTENT) VirtualFile(com.intellij.openapi.vfs.VirtualFile) IOException(java.io.IOException) KIND_PIPELINERUN(com.redhat.devtools.intellij.tektoncd.Constants.KIND_PIPELINERUN) SettingsState(com.redhat.devtools.intellij.tektoncd.settings.SettingsState) CLEANED(com.redhat.devtools.intellij.common.CommonConstants.CLEANED) ParentableNode(com.redhat.devtools.intellij.tektoncd.tree.ParentableNode) Editor(com.intellij.openapi.editor.Editor) FileEditor(com.intellij.openapi.fileEditor.FileEditor) TARGET_NODE(com.redhat.devtools.intellij.tektoncd.Constants.TARGET_NODE) FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) VirtualFileHelper.createTempFile(com.redhat.devtools.intellij.common.utils.VirtualFileHelper.createTempFile) Project(com.intellij.openapi.project.Project) Optional(java.util.Optional) VirtualFileHelper.cleanContent(com.redhat.devtools.intellij.common.utils.VirtualFileHelper.cleanContent) KIND_TASKRUN(com.redhat.devtools.intellij.tektoncd.Constants.KIND_TASKRUN) PROJECT(com.redhat.devtools.intellij.common.CommonConstants.PROJECT) KIND_PLURAL(com.redhat.devtools.intellij.tektoncd.Constants.KIND_PLURAL) NAMESPACE(com.redhat.devtools.intellij.tektoncd.Constants.NAMESPACE) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) FileEditor(com.intellij.openapi.fileEditor.FileEditor) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor) Editor(com.intellij.openapi.editor.Editor) FileEditor(com.intellij.openapi.fileEditor.FileEditor)

Aggregations

Editor (com.intellij.openapi.editor.Editor)1 FileEditor (com.intellij.openapi.fileEditor.FileEditor)1 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)1 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 LightVirtualFile (com.intellij.testFramework.LightVirtualFile)1 CLEANED (com.redhat.devtools.intellij.common.CommonConstants.CLEANED)1 CONTENT (com.redhat.devtools.intellij.common.CommonConstants.CONTENT)1 PROJECT (com.redhat.devtools.intellij.common.CommonConstants.PROJECT)1 AllowNonProjectEditing (com.redhat.devtools.intellij.common.editor.AllowNonProjectEditing)1 VirtualFileHelper.cleanContent (com.redhat.devtools.intellij.common.utils.VirtualFileHelper.cleanContent)1 VirtualFileHelper.createTempFile (com.redhat.devtools.intellij.common.utils.VirtualFileHelper.createTempFile)1 KIND_PIPELINERUN (com.redhat.devtools.intellij.tektoncd.Constants.KIND_PIPELINERUN)1 KIND_PLURAL (com.redhat.devtools.intellij.tektoncd.Constants.KIND_PLURAL)1 KIND_TASKRUN (com.redhat.devtools.intellij.tektoncd.Constants.KIND_TASKRUN)1 NAMESPACE (com.redhat.devtools.intellij.tektoncd.Constants.NAMESPACE)1 TARGET_NODE (com.redhat.devtools.intellij.tektoncd.Constants.TARGET_NODE)1 SettingsState (com.redhat.devtools.intellij.tektoncd.settings.SettingsState)1 ParentableNode (com.redhat.devtools.intellij.tektoncd.tree.ParentableNode)1