use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.
the class RunIdeConsoleAction method configureConsole.
public static void configureConsole(@NotNull VirtualFile file, @NotNull FileEditorManager source) {
MyRunAction runAction = new MyRunAction();
for (FileEditor fileEditor : source.getEditors(file)) {
if (!(fileEditor instanceof TextEditor))
continue;
Editor editor = ((TextEditor) fileEditor).getEditor();
runAction.registerCustomShortcutSet(CommonShortcuts.CTRL_ENTER, editor.getComponent());
}
}
use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.
the class FindManagerImpl method findNextUsageInFile.
private boolean findNextUsageInFile(@NotNull FileEditor fileEditor, @NotNull SearchResults.Direction direction) {
if (fileEditor instanceof TextEditor) {
TextEditor textEditor = (TextEditor) fileEditor;
Editor editor = textEditor.getEditor();
editor.getCaretModel().removeSecondaryCarets();
if (tryToFindNextUsageViaEditorSearchComponent(editor, direction)) {
return true;
}
RangeHighlighter[] highlighters = ((HighlightManagerImpl) HighlightManager.getInstance(myProject)).getHighlighters(editor);
if (highlighters.length > 0) {
return highlightNextHighlighter(highlighters, editor, editor.getCaretModel().getOffset(), direction == SearchResults.Direction.DOWN, false);
}
}
if (direction == SearchResults.Direction.DOWN) {
return myFindUsagesManager.findNextUsageInFile(fileEditor);
}
return myFindUsagesManager.findPreviousUsageInFile(fileEditor);
}
use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.
the class FindManagerImpl method findUsagesInEditor.
@Override
public void findUsagesInEditor(@NotNull PsiElement element, @NotNull FileEditor fileEditor) {
if (fileEditor instanceof TextEditor) {
TextEditor textEditor = (TextEditor) fileEditor;
Editor editor = textEditor.getEditor();
Document document = editor.getDocument();
PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(document);
myFindUsagesManager.findUsages(element, psiFile, fileEditor, false, null);
}
}
use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.
the class StructureViewWrapperImpl method rebuild.
public void rebuild() {
if (myProject.isDisposed())
return;
Dimension referenceSize = null;
if (myStructureView != null) {
if (myStructureView instanceof StructureView.Scrollable) {
referenceSize = ((StructureView.Scrollable) myStructureView).getCurrentSize();
}
myStructureView.storeState();
Disposer.dispose(myStructureView);
myStructureView = null;
myFileEditor = null;
}
if (myModuleStructureComponent != null) {
Disposer.dispose(myModuleStructureComponent);
myModuleStructureComponent = null;
}
final ContentManager contentManager = myToolWindow.getContentManager();
contentManager.removeAllContents(true);
if (!isStructureViewShowing()) {
return;
}
VirtualFile file = myFile;
if (file == null) {
final VirtualFile[] selectedFiles = FileEditorManager.getInstance(myProject).getSelectedFiles();
if (selectedFiles.length > 0) {
file = selectedFiles[0];
}
}
String[] names = { "" };
if (file != null && file.isValid()) {
if (file.isDirectory()) {
if (ProjectRootsUtil.isModuleContentRoot(file, myProject)) {
Module module = ModuleUtilCore.findModuleForFile(file, myProject);
if (module != null && !(ModuleUtil.getModuleType(module) instanceof InternalModuleType)) {
myModuleStructureComponent = new ModuleStructureComponent(module);
createSinglePanel(myModuleStructureComponent.getComponent());
Disposer.register(this, myModuleStructureComponent);
}
}
} else {
FileEditor editor = FileEditorManager.getInstance(myProject).getSelectedEditor(file);
boolean needDisposeEditor = false;
if (editor == null) {
editor = createTempFileEditor(file);
needDisposeEditor = true;
}
if (editor != null && editor.isValid()) {
final StructureViewBuilder structureViewBuilder = editor.getStructureViewBuilder();
if (structureViewBuilder != null) {
myStructureView = structureViewBuilder.createStructureView(editor, myProject);
myFileEditor = editor;
Disposer.register(this, myStructureView);
updateHeaderActions(myStructureView);
if (myStructureView instanceof StructureView.Scrollable) {
((StructureView.Scrollable) myStructureView).setReferenceSizeWhileInitializing(referenceSize);
}
if (myStructureView instanceof StructureViewComposite) {
final StructureViewComposite composite = (StructureViewComposite) myStructureView;
final StructureViewComposite.StructureViewDescriptor[] views = composite.getStructureViews();
myPanels = new JPanel[views.length];
names = new String[views.length];
for (int i = 0; i < myPanels.length; i++) {
myPanels[i] = createContentPanel(views[i].structureView.getComponent());
names[i] = views[i].title;
}
} else {
createSinglePanel(myStructureView.getComponent());
}
myStructureView.restoreState();
myStructureView.centerSelectedRow();
}
}
if (needDisposeEditor && editor != null) {
Disposer.dispose(editor);
}
}
}
if (myModuleStructureComponent == null && myStructureView == null) {
createSinglePanel(new JLabel(IdeBundle.message("message.nothing.to.show.in.structure.view"), SwingConstants.CENTER));
}
for (int i = 0; i < myPanels.length; i++) {
final Content content = ContentFactory.SERVICE.getInstance().createContent(myPanels[i], names[i], false);
contentManager.addContent(content);
if (i == 0 && myStructureView != null) {
Disposer.register(content, myStructureView);
}
}
if (myPendingSelection != null) {
Runnable selection = myPendingSelection;
myPendingSelection = null;
selection.run();
}
}
use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.
the class MacroManager method getCorrectContext.
private static DataContext getCorrectContext(DataContext dataContext) {
if (PlatformDataKeys.FILE_EDITOR.getData(dataContext) != null) {
return dataContext;
}
Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project == null) {
return dataContext;
}
FileEditorManager editorManager = FileEditorManager.getInstance(project);
VirtualFile[] files = editorManager.getSelectedFiles();
if (files.length == 0) {
return dataContext;
}
FileEditor fileEditor = editorManager.getSelectedEditor(files[0]);
return fileEditor == null ? dataContext : DataManager.getInstance().getDataContext(fileEditor.getComponent());
}
Aggregations