use of com.intellij.openapi.fileEditor.FileEditor in project android by JetBrains.
the class EditorFixture method getLayoutEditor.
/**
* Returns a fixture around the layout editor, <b>if</b> the currently edited file
* is a layout file and it is currently showing the layout editor tab or the parameter
* requests that it be opened if necessary
*
* @param switchToTabIfNecessary if true, switch to the design tab if it is not already showing
* @throws IllegalStateException if there is no selected editor or it is not a {@link NlEditor}
*/
@NotNull
public NlEditorFixture getLayoutEditor(boolean switchToTabIfNecessary) {
if (switchToTabIfNecessary) {
selectEditorTab(Tab.DESIGN);
}
return GuiQuery.getNonNull(() -> {
FileEditor[] editors = FileEditorManager.getInstance(myFrame.getProject()).getSelectedEditors();
checkState(editors.length > 0, "no selected editors");
FileEditor selected = editors[0];
checkState(selected instanceof NlEditor, "not a %s: %s", NlEditor.class.getSimpleName(), selected);
return new NlEditorFixture(myFrame.robot(), myFrame, (NlEditor) selected);
});
}
use of com.intellij.openapi.fileEditor.FileEditor in project android by JetBrains.
the class EditorFixture method open.
/**
* Opens up a different file. This will run through the "Open File..." dialog to
* find and select the given file.
*
* @param file the file to open
* @param tab which tab to open initially, if there are multiple editors
*/
public EditorFixture open(@NotNull final VirtualFile file, @NotNull final Tab tab) {
execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
// TODO: Use UI to navigate to the file instead
Project project = myFrame.getProject();
FileEditorManager manager = FileEditorManager.getInstance(project);
if (tab == Tab.EDITOR) {
manager.openTextEditor(new OpenFileDescriptor(project, file), true);
} else {
manager.openFile(file, true);
}
}
});
selectEditorTab(tab);
Wait.seconds(5).expecting("file " + quote(file.getPath()) + " to be opened and loaded").until(() -> {
if (!file.equals(getCurrentFile())) {
return false;
}
FileEditor fileEditor = FileEditorManager.getInstance(myFrame.getProject()).getSelectedEditor(file);
JComponent editorComponent = fileEditor.getComponent();
if (editorComponent instanceof JBLoadingPanel) {
return !((JBLoadingPanel) editorComponent).isLoading();
}
return true;
});
myFrame.requestFocusIfLost();
robot.waitForIdle();
return this;
}
use of com.intellij.openapi.fileEditor.FileEditor in project android by JetBrains.
the class EditorFixture method getTranslationsEditor.
/**
* Returns a fixture around the {@link com.android.tools.idea.editors.strings.StringResourceEditor} <b>if</b> the currently
* displayed editor is a translations editor.
*/
@NotNull
public TranslationsEditorFixture getTranslationsEditor() {
return GuiQuery.getNonNull(() -> {
FileEditor[] editors = FileEditorManager.getInstance(myFrame.getProject()).getSelectedEditors();
checkState(editors.length > 0, "no selected editors");
FileEditor selected = editors[0];
checkState(selected instanceof StringResourceEditor, "not a %s: %s", StringResourceEditor.class.getSimpleName(), selected);
return new TranslationsEditorFixture(robot, (StringResourceEditor) selected);
});
}
use of com.intellij.openapi.fileEditor.FileEditor in project android by JetBrains.
the class FloatingToolWindowManager method getActiveWorkBench.
@Nullable
private WorkBench getActiveWorkBench() {
Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if (focusOwner instanceof WorkBench) {
return (WorkBench) focusOwner;
}
WorkBench current = (WorkBench) SwingUtilities.getAncestorOfClass(WorkBench.class, focusOwner);
if (current != null) {
return current;
}
FileEditor[] selectedEditors = myEditorManager.getSelectedEditors();
if (selectedEditors.length == 0) {
return null;
}
if (selectedEditors.length == 1) {
return myWorkBenchMap.get(selectedEditors[0]);
}
if (focusOwner != null) {
for (FileEditor editor : selectedEditors) {
if (SwingUtilities.isDescendingFrom(focusOwner, editor.getComponent())) {
return myWorkBenchMap.get(editor);
}
}
}
return myWorkBenchMap.get(selectedEditors[0]);
}
use of com.intellij.openapi.fileEditor.FileEditor in project idea-handlebars by dmarcotte.
the class HbStructureViewTest method testStructureView.
public void testStructureView(PsiFile file, Consumer<StructureViewComposite> consumer) {
final VirtualFile vFile = file.getVirtualFile();
final FileEditor fileEditor = FileEditorManager.getInstance(getProject()).getSelectedEditor(vFile);
final StructureViewBuilder builder = LanguageStructureViewBuilder.INSTANCE.getStructureViewBuilder(file);
assert builder != null;
StructureViewComposite composite = null;
try {
composite = (StructureViewComposite) builder.createStructureView(fileEditor, file.getProject());
consumer.consume(composite);
} finally {
if (composite != null)
Disposer.dispose(composite);
}
}
Aggregations