Java Code Examples for com.intellij.openapi.fileEditor.FileEditor#getFile()
The following examples show how to use
com.intellij.openapi.fileEditor.FileEditor#getFile() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ViewStructureAction.java From consulo with Apache License 2.0 | 6 votes |
@Override public void actionPerformed(@Nonnull AnActionEvent e) { Project project = e.getData(CommonDataKeys.PROJECT); if (project == null) return; FileEditor fileEditor = e.getData(PlatformDataKeys.FILE_EDITOR); if (fileEditor == null) return; VirtualFile virtualFile = fileEditor.getFile(); Editor editor = fileEditor instanceof TextEditor ? ((TextEditor)fileEditor).getEditor() : e.getData(CommonDataKeys.EDITOR); if (editor != null) { PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument()); } FeatureUsageTracker.getInstance().triggerFeatureUsed("navigation.popup.file.structure"); FileStructurePopup popup = createPopup(project, fileEditor); if (popup == null) return; String title = virtualFile == null ? fileEditor.getName() : virtualFile.getName(); popup.setTitle(title); popup.show(); }
Example 2
Source File: ScopeChooserCombo.java From IntelliJDeodorant with MIT License | 5 votes |
private AnalysisScope getCurrentFileScope() { FileEditor currentEditor = FileEditorManager.getInstance(project).getSelectedEditor(); if (currentEditor != null) { VirtualFile currentFile = currentEditor.getFile(); PsiFile file = PsiManager.getInstance(project).findFile(currentFile); if (file instanceof PsiJavaFile) return new AnalysisScope(project, Collections.singletonList(currentFile)); } return null; }
Example 3
Source File: ComponentStructureView.java From litho with Apache License 2.0 | 5 votes |
@Nullable private static PsiFile getSelectedFile(@Nullable FileEditor editor, Project project) { if (editor == null) return null; final VirtualFile vf = editor.getFile(); if (vf == null) return null; return PsiManager.getInstance(project).findFile(vf); }
Example 4
Source File: BlameUiSubscriber.java From GitToolBox with Apache License 2.0 | 5 votes |
@Nullable private VirtualFile getFileForSelectedEditor() { FileEditor editor = FileEditorManager.getInstance(project).getSelectedEditor(); if (editor != null) { return editor.getFile(); } return null; }
Example 5
Source File: DvcsUtil.java From consulo with Apache License 2.0 | 5 votes |
/** * Returns the currently selected file, based on which VcsBranch or StatusBar components will identify the current repository root. */ @javax.annotation.Nullable public static VirtualFile getSelectedFile(@Nonnull Project project) { StatusBar statusBar = WindowManager.getInstance().getStatusBar(project); final FileEditor fileEditor = StatusBarUtil.getCurrentFileEditor(project, statusBar); VirtualFile result = null; if (fileEditor != null) { if (fileEditor instanceof TextEditor) { Document document = ((TextEditor)fileEditor).getEditor().getDocument(); result = FileDocumentManager.getInstance().getFile(document); } else { result = fileEditor.getFile(); } } if (result == null) { final FileEditorManager manager = FileEditorManager.getInstance(project); if (manager != null) { Editor editor = manager.getSelectedTextEditor(); if (editor != null) { result = FileDocumentManager.getInstance().getFile(editor.getDocument()); } } } return result; }
Example 6
Source File: ViewStructureAction.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static StructureViewModel createStructureViewModel(@Nonnull Project project, @Nonnull FileEditor fileEditor, @Nonnull StructureView structureView) { StructureViewModel treeModel; VirtualFile virtualFile = fileEditor.getFile(); if (structureView instanceof StructureViewComposite && virtualFile != null) { StructureViewComposite.StructureViewDescriptor[] views = ((StructureViewComposite)structureView).getStructureViews(); PsiFile psiFile = ObjectUtils.notNull(PsiManager.getInstance(project).findFile(virtualFile)); treeModel = new StructureViewCompositeModel(psiFile, EditorUtil.getEditorEx(fileEditor), Arrays.asList(views)); Disposer.register(structureView, treeModel); } else { treeModel = structureView.getTreeModel(); } return treeModel; }