use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.
the class QuickEditHandler method navigate.
public void navigate(int injectedOffset) {
if (myAction.isShowInBalloon()) {
final JComponent component = myAction.createBalloonComponent(myNewFile);
if (component != null)
showBalloon(myEditor, myNewFile, component);
} else {
final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(myProject);
final FileEditor[] editors = fileEditorManager.getEditors(myNewVirtualFile);
if (editors.length == 0) {
final EditorWindow curWindow = fileEditorManager.getCurrentWindow();
mySplittedWindow = curWindow.split(SwingConstants.HORIZONTAL, false, myNewVirtualFile, true);
}
Editor editor = fileEditorManager.openTextEditor(new OpenFileDescriptor(myProject, myNewVirtualFile, injectedOffset), true);
// fold missing values
if (editor != null) {
editor.putUserData(QuickEditAction.QUICK_EDIT_HANDLER, this);
final FoldingModel foldingModel = editor.getFoldingModel();
foldingModel.runBatchFoldingOperation(() -> {
for (RangeMarker o : ContainerUtil.reverse(((DocumentEx) myNewDocument).getGuardedBlocks())) {
String replacement = o.getUserData(REPLACEMENT_KEY);
if (StringUtil.isEmpty(replacement))
continue;
FoldRegion region = foldingModel.addFoldRegion(o.getStartOffset(), o.getEndOffset(), replacement);
if (region != null)
region.setExpanded(false);
}
});
}
SwingUtilities.invokeLater(() -> myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE));
}
}
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();
}
}
use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.
the class DiffSideView method getFocusableComponent.
public JComponent getFocusableComponent() {
Editor editor = getEditor();
if (editor != null)
return editor.getContentComponent();
FileEditor fileEditor = myEditorSource.getFileEditor();
if (fileEditor != null)
return fileEditor.getComponent();
return MOCK_COMPONENT;
}
Aggregations