public TemplateManagerImpl(Project project) { myProject = project; final EditorFactoryListener myEditorFactoryListener = new EditorFactoryAdapter() { @Override public void editorReleased(@NotNull EditorFactoryEvent event) { Editor editor = event.getEditor(); if (editor.getProject() != null && editor.getProject() != myProject) return; if (myProject.isDisposed() || !myProject.isOpen()) return; TemplateState state = getTemplateState(editor); if (state != null) { state.gotoEnd(); } clearTemplateState(editor); } }; EditorFactory.getInstance().addEditorFactoryListener(myEditorFactoryListener, myProject); }
@Override public void projectOpened() { final EditorFactoryListener myEditorFactoryListener = new EditorFactoryAdapter() { @Override public void editorReleased(@NotNull EditorFactoryEvent event) { Editor editor = event.getEditor(); if (editor.getProject() != null && editor.getProject() != myProject) return; if (myProject.isDisposed() || !myProject.isOpen()) return; TemplateState tState = getTemplateState(editor); if (tState != null) { tState.gotoEnd(); } editor.putUserData(TEMPLATE_STATE_KEY, null); } }; EditorFactory.getInstance().addEditorFactoryListener(myEditorFactoryListener, myProject); }
public EncodingManagerImpl(@Nonnull EditorFactory editorFactory) { editorFactory.getEventMulticaster().addDocumentListener(new DocumentAdapter() { @Override public void documentChanged(DocumentEvent e) { Document document = e.getDocument(); if (isEditorOpenedFor(document)) { queueUpdateEncodingFromContent(document); } } }, this); editorFactory.addEditorFactoryListener(new EditorFactoryAdapter() { @Override public void editorCreated(@Nonnull EditorFactoryEvent event) { queueUpdateEncodingFromContent(event.getEditor().getDocument()); } }, this); }
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); }
public TemplateManagerImpl(Project project) { myProject = project; final EditorFactoryListener myEditorFactoryListener = new EditorFactoryAdapter() { @Override public void editorReleased(@Nonnull EditorFactoryEvent event) { Editor editor = event.getEditor(); if (editor.getProject() != null && editor.getProject() != myProject) return; if (myProject.isDisposed() || !myProject.isOpen()) return; TemplateState state = getTemplateState(editor); if (state != null) { state.gotoEnd(); } clearTemplateState(editor); } }; EditorFactory.getInstance().addEditorFactoryListener(myEditorFactoryListener, myProject); }
public EncodingManagerImpl(@NotNull EditorFactory editorFactory) { editorFactory.getEventMulticaster().addDocumentListener(new DocumentAdapter() { @Override public void documentChanged(DocumentEvent e) { queueUpdateEncodingFromContent(e.getDocument()); } }, this); editorFactory.addEditorFactoryListener(new EditorFactoryAdapter() { @Override public void editorCreated(@NotNull EditorFactoryEvent event) { queueUpdateEncodingFromContent(event.getEditor().getDocument()); } }, this); }
public XmlTagNameSynchronizer(EditorFactory editorFactory, FileDocumentManager manager, CommandProcessor processor) { myFileDocumentManager = manager; editorFactory.addEditorFactoryListener(new EditorFactoryAdapter() { @Override public void editorCreated(@NotNull EditorFactoryEvent event) { installSynchronizer(event.getEditor()); } }, ApplicationManager.getApplication()); processor.addCommandListener(this); }