Search in sources :

Example 1 with StudyEditorFactoryListener

use of com.jetbrains.edu.learning.editor.StudyEditorFactoryListener in project intellij-community by JetBrains.

the class StudyProjectComponent method initComponent.

@Override
public void initComponent() {
    EditorFactory.getInstance().addEditorFactoryListener(new StudyEditorFactoryListener(), myProject);
    ActionManager.getInstance().addAnActionListener(new AnActionListener() {

        @Override
        public void beforeActionPerformed(AnAction action, DataContext dataContext, AnActionEvent event) {
            AnAction[] newGroupActions = ((ActionGroup) ActionManager.getInstance().getAction("NewGroup")).getChildren(null);
            for (AnAction newAction : newGroupActions) {
                if (newAction == action) {
                    myListener = new FileCreatedByUserListener();
                    VirtualFileManager.getInstance().addVirtualFileListener(myListener);
                    break;
                }
            }
        }

        @Override
        public void afterActionPerformed(AnAction action, DataContext dataContext, AnActionEvent event) {
            AnAction[] newGroupActions = ((ActionGroup) ActionManager.getInstance().getAction("NewGroup")).getChildren(null);
            for (AnAction newAction : newGroupActions) {
                if (newAction == action) {
                    VirtualFileManager.getInstance().removeVirtualFileListener(myListener);
                }
            }
        }

        @Override
        public void beforeEditorTyping(char c, DataContext dataContext) {
        }
    });
}
Also used : StudyEditorFactoryListener(com.jetbrains.edu.learning.editor.StudyEditorFactoryListener) AnActionListener(com.intellij.openapi.actionSystem.ex.AnActionListener)

Aggregations

AnActionListener (com.intellij.openapi.actionSystem.ex.AnActionListener)1 StudyEditorFactoryListener (com.jetbrains.edu.learning.editor.StudyEditorFactoryListener)1