use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.
the class CopyHandler method updateSelectionInActiveProjectView.
static void updateSelectionInActiveProjectView(PsiElement newElement, Project project, boolean selectInActivePanel) {
String id = ToolWindowManager.getInstance(project).getActiveToolWindowId();
if (id != null) {
ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(id);
Content selectedContent = window.getContentManager().getSelectedContent();
if (selectedContent != null) {
JComponent component = selectedContent.getComponent();
if (component instanceof TwoPaneIdeView) {
((TwoPaneIdeView) component).selectElement(newElement, selectInActivePanel);
return;
}
}
}
if (ToolWindowId.PROJECT_VIEW.equals(id)) {
ProjectView.getInstance(project).selectPsiElement(newElement, true);
} else if (ToolWindowId.STRUCTURE_VIEW.equals(id)) {
VirtualFile virtualFile = newElement.getContainingFile().getVirtualFile();
FileEditor editor = FileEditorManager.getInstance(newElement.getProject()).getSelectedEditor(virtualFile);
StructureViewFactoryEx.getInstanceEx(project).getStructureViewWrapper().selectCurrentElement(editor, virtualFile, true);
}
}
use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.
the class IntentionWrapper method applyFix.
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
VirtualFile virtualFile = myFile.getVirtualFile();
if (virtualFile != null) {
FileEditor editor = FileEditorManager.getInstance(project).getSelectedEditor(virtualFile);
myAction.invoke(project, editor instanceof TextEditor ? ((TextEditor) editor).getEditor() : null, myFile);
}
}
use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.
the class EditorOptionsPanel method clearAllIdentifierHighlighters.
private static void clearAllIdentifierHighlighters() {
for (Project project : ProjectManager.getInstance().getOpenProjects()) {
for (FileEditor fileEditor : FileEditorManager.getInstance(project).getAllEditors()) {
if (fileEditor instanceof TextEditor) {
Document document = ((TextEditor) fileEditor).getEditor().getDocument();
IdentifierHighlighterPass.clearMyHighlights(document, project);
}
}
}
}
use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.
the class CreateFileFix method openFile.
protected void openFile(@NotNull Project project, PsiDirectory directory, PsiFile newFile, String text) {
final FileEditorManager editorManager = FileEditorManager.getInstance(directory.getProject());
final FileEditor[] fileEditors = editorManager.openFile(newFile.getVirtualFile(), true);
if (text != null) {
for (FileEditor fileEditor : fileEditors) {
if (fileEditor instanceof TextEditor) {
// JSP is not safe to edit via Psi
final Document document = ((TextEditor) fileEditor).getEditor().getDocument();
document.setText(text);
if (ApplicationManager.getApplication().isUnitTestMode()) {
FileDocumentManager.getInstance().saveDocument(document);
}
PsiDocumentManager.getInstance(project).commitDocument(document);
break;
}
}
}
}
use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.
the class SdkSetupNotificationTestBase method configureBySdkAndText.
protected EditorNotificationPanel configureBySdkAndText(@Nullable Sdk sdk, boolean moduleSdk, @NotNull String name, @NotNull String text) {
final PsiFile psiFile = myFixture.configureByText(name, text);
final FileEditor[] editors = FileEditorManagerEx.getInstanceEx(getProject()).openFile(psiFile.getVirtualFile(), true);
assertSize(1, editors);
if (moduleSdk) {
ModuleRootModificationUtil.setModuleSdk(myModule, sdk);
} else {
setProjectSdk(sdk);
ModuleRootModificationUtil.setSdkInherited(myModule);
}
return editors[0].getUserData(SdkSetupNotificationProvider.KEY);
}
Aggregations