use of com.intellij.openapi.fileEditor.impl.EditorWindow in project ActiveTabHighlighterPlugin by tobszarny.
the class TabHighlighterFileEditorListener method selectionChanged.
@Override
public void selectionChanged(@NotNull FileEditorManagerEvent fileEditorManagerEvent) {
final Project project = fileEditorManagerEvent.getManager().getProject();
final FileEditorManagerEx manager = FileEditorManagerEx.getInstanceEx(project);
final FileColorManager fileColorManager = FileColorManager.getInstance(project);
final HighlighterSettingsConfig highlighterSettingsConfig = HighlighterSettingsConfig.getInstance();
final VirtualFile oldFile = fileEditorManagerEvent.getOldFile();
final VirtualFile newFile = fileEditorManagerEvent.getNewFile();
for (EditorWindow editorWindow : manager.getWindows()) {
setUnfocusedTabWithColorManagerDefaultColor(fileColorManager, oldFile, editorWindow);
setFocusedTabHighlighterColor(highlighterSettingsConfig, newFile, editorWindow);
}
}
use of com.intellij.openapi.fileEditor.impl.EditorWindow in project oxy-template-support-plugin by mutant-industries.
the class CompiledPreviewController method showCompiledCode.
public boolean showCompiledCode(@NotNull final PsiFile originalFile) {
PsiFile psiFile;
Document document = null;
VirtualFile virtualFile = null;
EditorWindow editorWindow = null;
boolean result, newTabCreated = false;
FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(myProject);
// check for already opened editor with compiled source first
for (FileEditor fileEditor : fileEditorManager.getAllEditors()) {
if (!(fileEditor instanceof TextEditor)) {
continue;
}
EditorEx editor = (EditorEx) ((TextEditor) fileEditor).getEditor();
virtualFile = editor.getVirtualFile();
psiFile = PsiManager.getInstance(myProject).findFile(virtualFile);
if (psiFile != null && originalFile.isEquivalentTo(psiFile.getUserData(ORIGINAL_FILE_KEY))) {
document = editor.getDocument();
// find editor window where the file is opened
for (EditorWindow window : fileEditorManager.getWindows()) {
if (findFileIndex(window, virtualFile) != -1) {
editorWindow = window;
break;
}
}
break;
}
}
// create new editor
if (document == null) {
virtualFile = new LightVirtualFile(originalFile.getName() + COMPILED_FILE_SUFFIX);
((LightVirtualFile) virtualFile).setLanguage(CompiledPreview.INSTANCE);
((LightVirtualFile) virtualFile).setFileType(CompiledPreviewFileType.INSTANCE);
psiFile = PsiManager.getInstance(myProject).findFile(virtualFile);
assert psiFile != null;
document = PsiDocumentManager.getInstance(myProject).getDocument(psiFile);
assert document != null;
psiFile.putUserData(ORIGINAL_FILE_KEY, originalFile);
editorWindow = fileEditorManager.getCurrentWindow();
newTabCreated = true;
}
assert editorWindow != null;
if (result = showCompiledCode(originalFile, document)) {
if (newTabCreated) {
editorWindow.split(SwingConstants.HORIZONTAL, false, virtualFile, false);
}
if (findFileIndex(editorWindow, virtualFile) == -1) {
fileEditorManager.openFile(virtualFile, false);
}
// switch to editor with recompiled source
editorWindow.setEditor(editorWindow.findFileComposite(virtualFile), false);
}
return result;
}
use of com.intellij.openapi.fileEditor.impl.EditorWindow in project ideavim by JetBrains.
the class WindowGroup method selectWindowInRow.
public void selectWindowInRow(@NotNull DataContext context, int relativePosition, boolean vertical) {
final FileEditorManagerEx fileEditorManager = getFileEditorManager(context);
final EditorWindow currentWindow = fileEditorManager.getCurrentWindow();
if (currentWindow != null) {
final EditorWindow[] windows = fileEditorManager.getWindows();
final List<EditorWindow> row = findWindowsInRow(currentWindow, Arrays.asList(windows), vertical);
selectWindow(currentWindow, row, relativePosition);
}
}
use of com.intellij.openapi.fileEditor.impl.EditorWindow in project ideavim by JetBrains.
the class WindowGroup method splitWindow.
private void splitWindow(int orientation, @NotNull DataContext context, @NotNull String filename) {
final Project project = PlatformDataKeys.PROJECT.getData(context);
final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
VirtualFile virtualFile = null;
if (filename.length() > 0 && project != null) {
virtualFile = VimPlugin.getFile().findFile(filename, project);
if (virtualFile == null) {
VimPlugin.showMessage("Could not find file: " + filename);
return;
}
}
final EditorWindow editorWindow = fileEditorManager.getSplitters().getCurrentWindow();
if (editorWindow != null) {
editorWindow.split(orientation, true, virtualFile, true);
}
}
use of com.intellij.openapi.fileEditor.impl.EditorWindow in project ideavim by JetBrains.
the class WindowGroup method selectWindow.
public void selectWindow(@NotNull DataContext context, int index) {
final FileEditorManagerEx fileEditorManager = getFileEditorManager(context);
final EditorWindow[] windows = fileEditorManager.getWindows();
if (index - 1 < windows.length) {
windows[index - 1].setAsCurrentWindow(true);
}
}
Aggregations