use of com.intellij.openapi.fileEditor.FileEditorManager in project intellij-community by JetBrains.
the class EditorFixture method moveToLine.
/**
* Moves the caret to the start of the given line number (0-based).
*
* @param lineNumber the line number.
*/
@NotNull
public EditorFixture moveToLine(final int lineNumber) {
assertThat(lineNumber).isGreaterThanOrEqualTo(0);
execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
// TODO: Do this via mouse clicks!
FileEditorManager manager = FileEditorManager.getInstance(myFrame.getProject());
Editor editor = manager.getSelectedTextEditor();
if (editor != null) {
Document document = editor.getDocument();
int offset = document.getLineStartOffset(lineNumber);
editor.getCaretModel().moveToOffset(offset);
editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
}
}
});
return this;
}
use of com.intellij.openapi.fileEditor.FileEditorManager in project intellij-community by JetBrains.
the class LightPlatformCodeInsightTestCase method tearDown.
@Override
protected void tearDown() throws Exception {
try {
FileEditorManager editorManager = FileEditorManager.getInstance(getProject());
for (VirtualFile openFile : editorManager.getOpenFiles()) {
editorManager.closeFile(openFile);
}
deleteVFile();
myEditor = null;
myFile = null;
myVFile = null;
} finally {
super.tearDown();
}
}
use of com.intellij.openapi.fileEditor.FileEditorManager in project intellij-community by JetBrains.
the class SrcFileAnnotator method showEditorWarningMessage.
private void showEditorWarningMessage(final String message) {
Editor textEditor = myEditor;
PsiFile file = myFile;
ApplicationManager.getApplication().invokeLater(() -> {
if (textEditor == null || textEditor.isDisposed() || file == null)
return;
final FileEditorManager fileEditorManager = FileEditorManager.getInstance(myProject);
final VirtualFile vFile = file.getVirtualFile();
assert vFile != null;
Map<FileEditor, EditorNotificationPanel> map = file.getCopyableUserData(NOTIFICATION_PANELS);
if (map == null) {
map = new HashMap<>();
file.putCopyableUserData(NOTIFICATION_PANELS, map);
}
final FileEditor[] editors = fileEditorManager.getAllEditors(vFile);
for (final FileEditor editor : editors) {
if (isCurrentEditor(editor)) {
final EditorNotificationPanel panel = new EditorNotificationPanel() {
{
myLabel.setIcon(AllIcons.General.ExclMark);
myLabel.setText(message);
}
};
panel.createActionLabel("Close", () -> fileEditorManager.removeTopComponent(editor, panel));
map.put(editor, panel);
fileEditorManager.addTopComponent(editor, panel);
break;
}
}
});
}
use of com.intellij.openapi.fileEditor.FileEditorManager in project intellij-community by JetBrains.
the class HighlightUtils method showRenameTemplate.
public static void showRenameTemplate(PsiElement context, PsiNameIdentifierOwner element, PsiReference... references) {
context = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(context);
final Project project = context.getProject();
final FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
final Editor editor = fileEditorManager.getSelectedTextEditor();
if (editor == null) {
return;
}
final TemplateBuilderImpl builder = new TemplateBuilderImpl(context);
final Expression macroCallNode = new MacroCallNode(new SuggestVariableNameMacro());
final PsiElement identifier = element.getNameIdentifier();
builder.replaceElement(identifier, "PATTERN", macroCallNode, true);
for (PsiReference reference : references) {
builder.replaceElement(reference, "PATTERN", "PATTERN", false);
}
final Template template = builder.buildInlineTemplate();
final TextRange textRange = context.getTextRange();
final int startOffset = textRange.getStartOffset();
editor.getCaretModel().moveToOffset(startOffset);
final TemplateManager templateManager = TemplateManager.getInstance(project);
templateManager.startTemplate(editor, template);
}
use of com.intellij.openapi.fileEditor.FileEditorManager in project intellij-community by JetBrains.
the class MoveDeclarationIntention method highlightElement.
private static void highlightElement(@NotNull PsiElement element) {
final Project project = element.getProject();
final FileEditorManager editorManager = FileEditorManager.getInstance(project);
final HighlightManager highlightManager = HighlightManager.getInstance(project);
final EditorColorsManager editorColorsManager = EditorColorsManager.getInstance();
final Editor editor = editorManager.getSelectedTextEditor();
final EditorColorsScheme globalScheme = editorColorsManager.getGlobalScheme();
final TextAttributes textattributes = globalScheme.getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
final PsiElement[] elements = new PsiElement[] { element };
highlightManager.addOccurrenceHighlights(editor, elements, textattributes, true, null);
StatusBar.Info.set(IntentionPowerPackBundle.message("status.bar.escape.highlighting.message"), project);
}
Aggregations