use of com.intellij.openapi.fileEditor.impl.EditorWindow in project intellij-community by JetBrains.
the class SplitAction method update.
public void update(final AnActionEvent event) {
final Project project = event.getData(CommonDataKeys.PROJECT);
final EditorWindow window = event.getData(EditorWindow.DATA_KEY);
final int minimum = myCloseSource ? 2 : 1;
final boolean enabled = project != null && window != null && window.getTabCount() >= minimum && !window.getOwner().isPreview();
event.getPresentation().setEnabled(enabled);
}
use of com.intellij.openapi.fileEditor.impl.EditorWindow 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.impl.EditorWindow in project intellij-community by JetBrains.
the class FileDropHandler method findEditorWindow.
@Nullable
private EditorWindow findEditorWindow(Project project) {
final Document document = myEditor.getDocument();
final VirtualFile file = FileDocumentManager.getInstance().getFile(document);
if (file != null) {
final FileEditorManagerEx fileEditorManager = (FileEditorManagerEx) FileEditorManager.getInstance(project);
final EditorWindow[] windows = fileEditorManager.getWindows();
for (EditorWindow window : windows) {
final EditorWithProviderComposite composite = window.findFileComposite(file);
if (composite == null) {
continue;
}
for (FileEditor editor : composite.getEditors()) {
if (editor instanceof TextEditor && ((TextEditor) editor).getEditor() == myEditor) {
return window;
}
}
}
}
return null;
}
Aggregations