com.intellij.openapi.editor.event.EditorFactoryEvent Java Examples
The following examples show how to use
com.intellij.openapi.editor.event.EditorFactoryEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EditorFactoryImpl.java From consulo with Apache License 2.0 | 6 votes |
@Override public void releaseEditor(@Nonnull Editor editor) { try { EditorFactoryEvent event = new EditorFactoryEvent(this, editor); myEditorFactoryEventDispatcher.getMulticaster().editorReleased(event); EP.forEachExtensionSafe(it -> it.editorReleased(event)); } finally { try { ((DesktopEditorImpl)editor).release(); } finally { myEditors.remove(editor); if (LOG.isDebugEnabled()) { LOG.debug("number of Editors after release: " + myEditors.size()); } } } }
Example #2
Source File: EditorFactoryImpl.java From consulo with Apache License 2.0 | 6 votes |
private Editor createEditor(@Nonnull Document document, boolean isViewer, Project project, @Nonnull EditorKind kind) { Document hostDocument = document instanceof DocumentWindow ? ((DocumentWindow)document).getDelegate() : document; DesktopEditorImpl editor = new DesktopEditorImpl(hostDocument, isViewer, project, kind); myEditors.add(editor); myEditorEventMulticaster.registerEditor(editor); EditorFactoryEvent event = new EditorFactoryEvent(this, editor); myEditorFactoryEventDispatcher.getMulticaster().editorCreated(event); EP.forEachExtensionSafe(it -> it.editorCreated(event)); if (LOG.isDebugEnabled()) { LOG.debug("number of Editors after create: " + myEditors.size()); } return editor; }
Example #3
Source File: EditorUtil.java From consulo with Apache License 2.0 | 6 votes |
public static void disposeWithEditor(@Nonnull Editor editor, @Nonnull Disposable disposable) { ApplicationManager.getApplication().assertIsDispatchThread(); if (Disposer.isDisposed(disposable)) return; if (editor.isDisposed()) { Disposer.dispose(disposable); return; } // for injected editors disposal will happen only when host editor is disposed, // but this seems to be the best we can do (there are no notifications on disposal of injected editor) Editor hostEditor = editor instanceof EditorWindow ? ((EditorWindow)editor).getDelegate() : editor; EditorFactory.getInstance().addEditorFactoryListener(new EditorFactoryAdapter() { @Override public void editorReleased(@Nonnull EditorFactoryEvent event) { if (event.getEditor() == hostEditor) { Disposer.dispose(disposable); } } }, disposable); }
Example #4
Source File: CoverageDataManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
@Override public void editorReleased(@Nonnull EditorFactoryEvent event) { final Editor editor = event.getEditor(); if (editor.getProject() != myProject) return; try { final SrcFileAnnotator fileAnnotator; synchronized (ANNOTATORS_LOCK) { fileAnnotator = myAnnotators.remove(editor); } if (fileAnnotator != null) { Disposer.dispose(fileAnnotator); } } finally { final Runnable request = myCurrentEditors.remove(editor); if (request != null) { myAlarm.cancelRequest(request); } } }
Example #5
Source File: TemplateManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public void editorReleased(@Nonnull EditorFactoryEvent event) { Editor editor = event.getEditor(); Project project = editor.getProject(); if (project == null || project.isDisposed() || !project.isOpen()) { return; } TemplateState state = getTemplateState(editor); if (state != null) { state.gotoEnd(); } clearTemplateState(editor); }
Example #6
Source File: EditorTracker.java From consulo with Apache License 2.0 | 5 votes |
@Override public void editorReleased(@Nonnull EditorFactoryEvent event) { Project project = event.getEditor().getProject(); if (project != null) { getInstance(project).editorReleased(event); } }
Example #7
Source File: EditorTracker.java From consulo with Apache License 2.0 | 5 votes |
@Override public void editorCreated(@Nonnull EditorFactoryEvent event) { Project project = event.getEditor().getProject(); if (project != null) { getInstance(project).editorCreated(event); } }
Example #8
Source File: LineStatusTrackerManager.java From consulo with Apache License 2.0 | 5 votes |
@Override public void editorReleased(@Nonnull EditorFactoryEvent event) { final Editor editor = event.getEditor(); if (editor.getProject() != null && editor.getProject() != myProject) return; final Document doc = editor.getDocument(); final Editor[] editors = event.getFactory().getEditors(doc, myProject); if (editors.length == 0 || (editors.length == 1 && editor == editors[0])) { releaseTracker(doc); } }
Example #9
Source File: LineStatusTrackerManager.java From consulo with Apache License 2.0 | 5 votes |
@Override public void editorCreated(@Nonnull EditorFactoryEvent event) { // note that in case of lazy loading of configurables, this event can happen // outside of EDT, so the EDT check mustn't be done here Editor editor = event.getEditor(); if (editor.getProject() != null && editor.getProject() != myProject) return; final Document document = editor.getDocument(); final VirtualFile virtualFile = FileDocumentManager.getInstance().getFile(document); if (virtualFile == null) return; if (shouldBeInstalled(virtualFile)) { installTracker(virtualFile, document); } }
Example #10
Source File: EncodingManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
public EncodingManagerImpl() { ApplicationManager.getApplication().getMessageBus().connect().subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener() { @Override public void appClosing() { // should call before dispose in write action // prevent any further re-detection and wait for the queue to clear myDisposed.set(true); clearDocumentQueue(); } }); EditorFactory editorFactory = EditorFactory.getInstance(); editorFactory.getEventMulticaster().addDocumentListener(new DocumentListener() { @Override public void documentChanged(@Nonnull DocumentEvent e) { Document document = e.getDocument(); if (isEditorOpenedFor(document)) { queueUpdateEncodingFromContent(document); } } }, this); editorFactory.addEditorFactoryListener(new EditorFactoryListener() { @Override public void editorCreated(@Nonnull EditorFactoryEvent event) { queueUpdateEncodingFromContent(event.getEditor().getDocument()); } }, this); }
Example #11
Source File: OREditorTracker.java From reasonml-idea-plugin with MIT License | 5 votes |
@Override public void editorReleased(@NotNull EditorFactoryEvent event) { Project project = event.getEditor().getProject(); if (project != null) { getInstance(project); } }
Example #12
Source File: OREditorTracker.java From reasonml-idea-plugin with MIT License | 5 votes |
@Override public void editorCreated(@NotNull EditorFactoryEvent event) { Project project = event.getEditor().getProject(); if (project != null) { getInstance(project); } }
Example #13
Source File: HighlightBracketPairApplicationComponent.java From HighlightBracketPair with Apache License 2.0 | 5 votes |
/** * Invoked when the editor is released, and dissolve the relationship * between the {@link Editor} editor and {@link HighlightEditorComponent} component, * and dispose the component. * * @param editorFactoryEvent */ @Override public void editorReleased(@NotNull EditorFactoryEvent editorFactoryEvent) { HighlightEditorComponent editorComponent = editorHighlightEditorComponentMap.remove(editorFactoryEvent.getEditor()); if (editorComponent == null) { return; } editorComponent.dispose(); }
Example #14
Source File: HighlightBracketPairApplicationComponent.java From HighlightBracketPair with Apache License 2.0 | 5 votes |
/** * Invoked when the editor is created, and establish the relationship * between the {@link Editor} editor and {@link HighlightEditorComponent} component. * * @param editorFactoryEvent editor factory event. */ @Override public void editorCreated(@NotNull EditorFactoryEvent editorFactoryEvent) { Editor editor = editorFactoryEvent.getEditor(); if (editor.getProject() == null) { return; } HighlightEditorComponent highlightEditorComponent = new HighlightEditorComponent(editor); editorHighlightEditorComponentMap.put(editor, highlightEditorComponent); }
Example #15
Source File: CoverageDataManagerImpl.java From consulo with Apache License 2.0 | 4 votes |
@Override public void editorCreated(@Nonnull EditorFactoryEvent event) { synchronized (myLock) { if (myIsProjectClosing) return; } final Editor editor = event.getEditor(); if (editor.getProject() != myProject) return; final PsiFile psiFile = ApplicationManager.getApplication().runReadAction(new Computable<PsiFile>() { @Nullable @Override public PsiFile compute() { if (myProject.isDisposed()) return null; final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(myProject); final Document document = editor.getDocument(); return documentManager.getPsiFile(document); } }); if (psiFile != null && myCurrentSuitesBundle != null && psiFile.isPhysical()) { final CoverageEngine engine = myCurrentSuitesBundle.getCoverageEngine(); if (!engine.coverageEditorHighlightingApplicableTo(psiFile)) { return; } SrcFileAnnotator annotator = getAnnotator(editor); if (annotator == null) { annotator = new SrcFileAnnotator(psiFile, editor); } final SrcFileAnnotator finalAnnotator = annotator; synchronized (ANNOTATORS_LOCK) { myAnnotators.put(editor, finalAnnotator); } final Runnable request = new Runnable() { @Override public void run() { if (myProject.isDisposed()) return; if (myCurrentSuitesBundle != null) { if (engine.acceptedByFilters(psiFile, myCurrentSuitesBundle)) { finalAnnotator.showCoverageInformation(myCurrentSuitesBundle); } } } }; myCurrentEditors.put(editor, request); myAlarm.addRequest(request, 100); } }
Example #16
Source File: EditorBackgroundListener.java From intellij-background-chibichara with MIT License | 4 votes |
@Override public void editorReleased(EditorFactoryEvent event) { event.getEditor().getContentComponent().setBorder(null); }
Example #17
Source File: EditorBackgroundListener.java From intellij-background-chibichara with MIT License | 4 votes |
@Override public void editorCreated(EditorFactoryEvent event) { editor = event.getEditor(); editorComponent = editor.getContentComponent(); refreshBackgroundImageBorder(); }
Example #18
Source File: ParticleContainerManager.java From power-mode-intellij-plugin with Apache License 2.0 | 4 votes |
@Override public void editorReleased(@NotNull EditorFactoryEvent event) { particleContainers.remove(event.getEditor()); }
Example #19
Source File: ParticleContainerManager.java From power-mode-intellij-plugin with Apache License 2.0 | 4 votes |
@Override public void editorCreated(@NotNull EditorFactoryEvent event) { final Editor editor = event.getEditor(); particleContainers.put(editor, new ParticleContainer(editor)); }
Example #20
Source File: LSPEditorListener.java From lsp4intellij with Apache License 2.0 | 4 votes |
public void editorCreated(@NotNull EditorFactoryEvent editorFactoryEvent) { IntellijLanguageClient.editorOpened(editorFactoryEvent.getEditor()); }
Example #21
Source File: EditorTracker.java From consulo with Apache License 2.0 | 4 votes |
private void editorReleased(@Nonnull EditorFactoryEvent event) { final Editor editor = event.getEditor(); if (editor.getProject() != null && editor.getProject() != myProject) return; unregisterEditor(editor); executeOnRelease(editor); }
Example #22
Source File: LSPEditorListener.java From lsp4intellij with Apache License 2.0 | 4 votes |
public void editorReleased(@NotNull EditorFactoryEvent editorFactoryEvent) { IntellijLanguageClient.editorClosed(editorFactoryEvent.getEditor()); }