use of com.intellij.openapi.fileEditor.FileEditor in project android by JetBrains.
the class EditorFixture method getMergedManifestEditor.
@NotNull
public MergedManifestFixture getMergedManifestEditor() {
return GuiQuery.getNonNull(() -> {
FileEditor[] editors = FileEditorManager.getInstance(myFrame.getProject()).getSelectedEditors();
checkState(editors.length > 0, "no selected editors");
Component manifestPanel = editors[0].getComponent().getComponent(0);
checkState(manifestPanel instanceof ManifestPanel, "not a %s: %s", ManifestPanel.class.getSimpleName(), manifestPanel);
return new MergedManifestFixture(robot, (ManifestPanel) manifestPanel);
});
}
use of com.intellij.openapi.fileEditor.FileEditor in project android by JetBrains.
the class GenerateLayoutTestSkeletonAction method getSurface.
@Nullable
private static DesignSurface getSurface(@NotNull Project project) {
FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
FileEditor[] editors = fileEditorManager.getSelectedEditors();
for (FileEditor fileEditor : editors) {
if (fileEditor instanceof NlEditor) {
return ((NlEditor) fileEditor).getComponent().getSurface();
}
}
Editor editor = fileEditorManager.getSelectedTextEditor();
if (editor == null) {
return null;
}
NlPreviewManager previewManager = NlPreviewManager.getInstance(project);
if (previewManager.isWindowVisible()) {
return previewManager.getPreviewForm().getSurface();
}
PsiFile file = PsiUtilBase.getPsiFileInEditor(editor, project);
if (file == null) {
return null;
}
for (FileEditor fileEditor : fileEditorManager.getEditors(file.getVirtualFile())) {
if (fileEditor instanceof NlEditor) {
return ((NlEditor) fileEditor).getComponent().getSurface();
}
}
return null;
}
use of com.intellij.openapi.fileEditor.FileEditor in project android by JetBrains.
the class HprofEditorFixture method findByFileName.
@NotNull
public static HprofEditorFixture findByFileName(@NotNull Robot robot, @NotNull final IdeFrameFixture frame, @NotNull final String hprofFileName) {
HprofEditor hprofEditor = GuiQuery.getNonNull(() -> {
FileEditor[] openEditors = null;
FileEditorManagerImpl fileEditorManager = (FileEditorManagerImpl) FileEditorManager.getInstance(frame.getProject());
for (EditorsSplitters splitters : fileEditorManager.getAllSplitters()) {
for (EditorWindow window : splitters.getWindows()) {
for (EditorWithProviderComposite editorWithProviderComposite : window.getEditors()) {
if (editorWithProviderComposite.getFile().getName().endsWith(hprofFileName)) {
if (openEditors != null) {
throw new ComponentLookupException(String.format("More than one Hprof editor for file '%s' found", hprofFileName));
}
openEditors = editorWithProviderComposite.getEditors();
}
}
}
}
if (openEditors == null) {
throw new ComponentLookupException(String.format("Cannot find any open Hprof editors for file '%s'", hprofFileName));
}
HprofEditor targetEditor = null;
for (FileEditor editor : openEditors) {
if (editor instanceof HprofEditor) {
if (targetEditor != null) {
throw new ComponentLookupException(String.format("More than one Hprof editor pane for file '%s' found", hprofFileName));
} else {
targetEditor = (HprofEditor) editor;
}
}
}
return targetEditor;
});
return new HprofEditorFixture(robot, frame, hprofEditor);
}
use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.
the class AnnotateLocalFileAction method perform.
private static void perform(AnActionEvent e, boolean selected) {
final VcsContext context = VcsContextFactory.SERVICE.getInstance().createContextOn(e);
if (!selected) {
for (Editor editor : getEditors(context)) {
editor.getGutter().closeAllAnnotations();
}
} else {
Project project = assertNotNull(context.getProject());
VirtualFile selectedFile = assertNotNull(context.getSelectedFile());
Editor editor = context.getEditor();
if (editor == null) {
FileEditor[] fileEditors = FileEditorManager.getInstance(project).openFile(selectedFile, false);
for (FileEditor fileEditor : fileEditors) {
if (fileEditor instanceof TextEditor) {
editor = ((TextEditor) fileEditor).getEditor();
}
}
}
LOG.assertTrue(editor != null);
doAnnotate(editor, project);
}
}
use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.
the class EditorNotificationsImpl method createTask.
@Nullable
private ReadTask createTask(@NotNull final ProgressIndicator indicator, @NotNull final VirtualFile file) {
List<FileEditor> editors = ContainerUtil.filter(FileEditorManager.getInstance(myProject).getAllEditors(file), editor -> !(editor instanceof TextEditor) || AsyncEditorLoader.isEditorLoaded(((TextEditor) editor).getEditor()));
if (editors.isEmpty())
return null;
return new ReadTask() {
private boolean isOutdated() {
if (myProject.isDisposed() || !file.isValid() || indicator != getCurrentProgress(file)) {
return true;
}
for (FileEditor editor : editors) {
if (!editor.isValid()) {
return true;
}
}
return false;
}
@Nullable
@Override
public Continuation performInReadAction(@NotNull ProgressIndicator indicator) throws ProcessCanceledException {
if (isOutdated())
return null;
final List<Provider> providers = DumbService.getInstance(myProject).filterByDumbAwareness(EXTENSION_POINT_NAME.getExtensions(myProject));
final List<Runnable> updates = ContainerUtil.newArrayList();
for (final FileEditor editor : editors) {
for (final Provider<?> provider : providers) {
final JComponent component = provider.createNotificationPanel(file, editor);
updates.add(() -> updateNotification(editor, provider.getKey(), component));
}
}
return new Continuation(() -> {
if (!isOutdated()) {
file.putUserData(CURRENT_UPDATES, null);
for (Runnable update : updates) {
update.run();
}
}
}, ModalityState.any());
}
@Override
public void onCanceled(@NotNull ProgressIndicator ignored) {
if (getCurrentProgress(file) == indicator) {
updateNotifications(file);
}
}
};
}
Aggregations