use of com.intellij.openapi.fileEditor.TextEditor in project intellij-community by JetBrains.
the class DaemonRespondToChangesTest method testCodeFoldingInSplittedWindowAppliesToAllEditors.
public void testCodeFoldingInSplittedWindowAppliesToAllEditors() throws Exception {
final Set<Editor> applied = new THashSet<>();
final Set<Editor> collected = new THashSet<>();
registerFakePass(applied, collected);
configureByText(PlainTextFileType.INSTANCE, "");
Editor editor1 = getEditor();
final Editor editor2 = EditorFactory.getInstance().createEditor(editor1.getDocument(), getProject());
Disposer.register(getProject(), () -> EditorFactory.getInstance().releaseEditor(editor2));
TextEditor textEditor1 = new PsiAwareTextEditorProvider().getTextEditor(editor1);
TextEditor textEditor2 = new PsiAwareTextEditorProvider().getTextEditor(editor2);
List<HighlightInfo> errors = myDaemonCodeAnalyzer.runPasses(myFile, editor1.getDocument(), Arrays.asList(textEditor1, textEditor2), new int[0], false, null);
assertEmpty(errors);
assertEquals(collected, ContainerUtil.newHashSet(editor1, editor2));
assertEquals(applied, ContainerUtil.newHashSet(editor1, editor2));
}
use of com.intellij.openapi.fileEditor.TextEditor in project intellij-community by JetBrains.
the class JvmSmartStepIntoHandler method handleTargets.
protected final boolean handleTargets(SourcePosition position, DebuggerSession session, TextEditor fileEditor, List<SmartStepTarget> targets) {
if (!targets.isEmpty()) {
SmartStepTarget firstTarget = targets.get(0);
if (targets.size() == 1) {
doStepInto(session, Registry.is("debugger.single.smart.step.force"), firstTarget);
} else {
Editor editor = fileEditor.getEditor();
PsiMethodListPopupStep popupStep = new PsiMethodListPopupStep(editor, targets, chosenTarget -> doStepInto(session, true, chosenTarget));
ListPopupImpl popup = new ListPopupImpl(popupStep);
DebuggerUIUtil.registerExtraHandleShortcuts(popup, XDebuggerActions.STEP_INTO, XDebuggerActions.SMART_STEP_INTO);
popup.setAdText(DebuggerUIUtil.getSelectionShortcutsAdText(XDebuggerActions.STEP_INTO, XDebuggerActions.SMART_STEP_INTO));
UIUtil.maybeInstall(popup.getList().getInputMap(JComponent.WHEN_FOCUSED), "selectNextRow", KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
popup.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
popupStep.getScopeHighlighter().dropHighlight();
if (!e.getValueIsAdjusting()) {
final SmartStepTarget selectedTarget = (SmartStepTarget) ((JBList) e.getSource()).getSelectedValue();
if (selectedTarget != null) {
highlightTarget(popupStep, selectedTarget);
}
}
}
});
highlightTarget(popupStep, firstTarget);
DebuggerUIUtil.showPopupForEditorLine(popup, editor, position.getLine());
}
return true;
}
return false;
}
use of com.intellij.openapi.fileEditor.TextEditor in project intellij-community by JetBrains.
the class GroovyConsoleRootType method fileOpened.
@Override
public void fileOpened(@NotNull final VirtualFile file, @NotNull FileEditorManager source) {
final Project project = source.getProject();
final GroovyConsoleStateService projectConsole = GroovyConsoleStateService.getInstance(project);
for (FileEditor fileEditor : source.getAllEditors(file)) {
if (!(fileEditor instanceof TextEditor))
continue;
final Editor editor = ((TextEditor) fileEditor).getEditor();
final JPanel panel = new EditorHeaderComponent();
final DefaultActionGroup actionGroup = new DefaultActionGroup(EXECUTE_ACTION, new GrSelectModuleAction(projectConsole, file));
final ActionToolbar menu = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, actionGroup, true);
panel.add(menu.getComponent());
editor.setHeaderComponent(panel);
EXECUTE_ACTION.registerCustomShortcutSet(CommonShortcuts.CTRL_ENTER, editor.getComponent());
}
}
use of com.intellij.openapi.fileEditor.TextEditor in project intellij-community by JetBrains.
the class MvcProjectViewPane method scrollFromSource.
public void scrollFromSource() {
FileEditorManager fileEditorManager = FileEditorManager.getInstance(myProject);
Editor selectedTextEditor = fileEditorManager.getSelectedTextEditor();
if (selectedTextEditor != null) {
selectElementAtCaret(selectedTextEditor, false);
return;
}
final FileEditor[] editors = fileEditorManager.getSelectedEditors();
for (FileEditor fileEditor : editors) {
if (fileEditor instanceof TextEditor) {
Editor editor = ((TextEditor) fileEditor).getEditor();
selectElementAtCaret(editor, false);
return;
}
}
final VirtualFile[] selectedFiles = fileEditorManager.getSelectedFiles();
if (selectedFiles.length > 0) {
PsiFile file = PsiManager.getInstance(myProject).findFile(selectedFiles[0]);
selectFile(file, false);
}
}
use of com.intellij.openapi.fileEditor.TextEditor in project intellij-community by JetBrains.
the class AnnotateRevisionAction method getEditor.
@Nullable
@Override
protected Editor getEditor(@NotNull AnActionEvent e) {
Project project = e.getProject();
if (project == null)
return null;
FilePath filePath = e.getData(VcsDataKeys.FILE_PATH);
if (filePath == null)
return null;
VirtualFile virtualFile = filePath.getVirtualFile();
if (virtualFile == null)
return null;
Editor editor = e.getData(CommonDataKeys.EDITOR);
if (editor != null) {
VirtualFile editorFile = FileDocumentManager.getInstance().getFile(editor.getDocument());
if (Comparing.equal(editorFile, virtualFile))
return editor;
}
FileEditor fileEditor = FileEditorManager.getInstance(project).getSelectedEditor(virtualFile);
if (fileEditor instanceof TextEditor) {
return ((TextEditor) fileEditor).getEditor();
}
return null;
}
Aggregations