use of com.android.tools.idea.uibuilder.editor.NlPreviewManager 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;
}
Aggregations