Example usage for com.intellij.openapi.editor.actionSystem EditorWriteActionHandler EditorWriteActionHandler

List of usage examples for com.intellij.openapi.editor.actionSystem EditorWriteActionHandler EditorWriteActionHandler

Introduction

In this page you can find the example usage for com.intellij.openapi.editor.actionSystem EditorWriteActionHandler EditorWriteActionHandler.

Prototype

protected EditorWriteActionHandler(boolean runForEachCaret) 

Source Link

Usage

From source file:com.intellij.codeInsight.template.impl.editorActions.ExpandLiveTemplateByTabAction.java

License:Apache License

public ExpandLiveTemplateByTabAction() {
    super(new EditorWriteActionHandler(true) {
        @Override/*from   w ww  . ja  v a  2 s.  c  om*/
        public void executeWriteAction(Editor editor, DataContext dataContext) {
            Project project = editor.getProject();
            assert project != null;
            PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
            TemplateManager.getInstance(project).startTemplate(editor, TemplateSettings.TAB_CHAR);
        }

        @Override
        public boolean isEnabled(Editor editor, DataContext dataContext) {
            Project project = editor.getProject();
            return project != null && ((TemplateManagerImpl) TemplateManager.getInstance(project))
                    .prepareTemplate(editor, TemplateSettings.TAB_CHAR, null) != null;
        }
    });
    setInjectedContext(true);
}