use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.
the class XDebuggerSmartStepIntoHandler method perform.
@Override
protected void perform(@NotNull XDebugSession session, DataContext dataContext) {
XSmartStepIntoHandler<?> handler = session.getDebugProcess().getSmartStepIntoHandler();
XSourcePosition position = session.getTopFramePosition();
if (position == null || handler == null)
return;
FileEditor editor = FileEditorManager.getInstance(session.getProject()).getSelectedEditor(position.getFile());
if (editor instanceof TextEditor) {
doSmartStepInto(handler, position, session, ((TextEditor) editor).getEditor());
}
}
use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.
the class XDebuggerInlayUtil method createInlay.
public static void createInlay(@NotNull Project project, @NotNull VirtualFile file, int offset, String inlayText) {
UIUtil.invokeLaterIfNeeded(() -> {
FileEditor editor = FileEditorManager.getInstance(project).getSelectedEditor(file);
if (editor instanceof TextEditor) {
Editor e = ((TextEditor) editor).getEditor();
CharSequence text = e.getDocument().getImmutableCharSequence();
int insertOffset = offset;
while (insertOffset < text.length() && Character.isJavaIdentifierPart(text.charAt(insertOffset))) insertOffset++;
List<Inlay> existing = e.getInlayModel().getInlineElementsInRange(insertOffset, insertOffset);
for (Inlay inlay : existing) {
if (inlay.getRenderer() instanceof MyRenderer) {
Disposer.dispose(inlay);
}
}
e.getInlayModel().addInlineElement(insertOffset, new MyRenderer(inlayText));
}
});
}
use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.
the class UndoRedoAction method update.
public void update(AnActionEvent event) {
Presentation presentation = event.getPresentation();
DataContext dataContext = event.getDataContext();
FileEditor editor = PlatformDataKeys.FILE_EDITOR.getData(dataContext);
// do not allow global undo in dialogs
if (editor == null) {
final Boolean isModalContext = PlatformDataKeys.IS_MODAL_CONTEXT.getData(dataContext);
if (isModalContext != null && isModalContext) {
presentation.setEnabled(false);
return;
}
}
UndoManager undoManager = getUndoManager(editor, dataContext);
if (undoManager == null) {
presentation.setEnabled(false);
return;
}
presentation.setEnabled(isAvailable(editor, undoManager));
Pair<String, String> pair = getActionNameAndDescription(editor, undoManager);
presentation.setText(pair.first);
presentation.setDescription(pair.second);
}
use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.
the class UndoRedoAction method actionPerformed.
public void actionPerformed(AnActionEvent e) {
DataContext dataContext = e.getDataContext();
FileEditor editor = PlatformDataKeys.FILE_EDITOR.getData(dataContext);
UndoManager undoManager = getUndoManager(editor, dataContext);
perform(editor, undoManager);
}
use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.
the class DiffSideView method setEditorSource.
public void setEditorSource(final Project project, final EditorSource source) {
MyState state = new MyState();
myEditorSource = source;
myLineMarker.attach(myEditorSource);
Editor editor = myEditorSource.getEditor();
final FileEditor fileEditor = myEditorSource.getFileEditor();
if (editor == null) {
insertComponent(fileEditor == null ? MOCK_COMPONENT : fileEditor.getComponent());
DataManager.registerDataProvider(myPanel, new DataProvider() {
@Override
public Object getData(@NonNls String dataId) {
if (CommonDataKeys.PROJECT.is(dataId)) {
return project;
}
if (PlatformDataKeys.FILE_EDITOR.is(dataId)) {
return fileEditor;
}
return null;
}
});
if (fileEditor != null) {
ScrollUtil.scrollVertically(fileEditor.getComponent(), 0);
ScrollUtil.scrollHorizontally(fileEditor.getComponent(), 0);
UIUtil.removeScrollBorder(fileEditor.getComponent());
}
} else {
DataManager.removeDataProvider(myPanel);
editor.getScrollingModel().scrollHorizontally(0);
insertComponent(editor.getComponent());
applyHighlighter();
setMouseListeners(source);
MyEditorFocusListener.install(this);
UIUtil.removeScrollBorder(editor.getComponent());
state.restore();
}
}
Aggregations