com.intellij.openapi.editor.event.EditorEventMulticaster Java Examples

The following examples show how to use com.intellij.openapi.editor.event.EditorEventMulticaster. 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: JSGraphQLQueryContextCaretListener.java    From js-graphql-intellij-plugin with MIT License 6 votes vote down vote up
@Override
public void runActivity(@NotNull Project project) {
    if (!ApplicationManager.getApplication().isHeadlessEnvironment()) {
        final EditorEventMulticaster eventMulticaster = EditorFactory.getInstance().getEventMulticaster();
        final PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(project);
        eventMulticaster.addCaretListener(new CaretListener() {
            @Override
            public void caretPositionChanged(CaretEvent e) {
                final PsiFile psiFile = psiDocumentManager.getPsiFile(e.getEditor().getDocument());
                if (psiFile instanceof GraphQLFile) {
                    int offset = e.getEditor().logicalPositionToOffset(e.getNewPosition());
                    psiFile.putUserData(CARET_OFFSET, offset);
                }
            }
        }, project);
    }
}
 
Example #2
Source File: WidgetIndentsHighlightingPassFactory.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public WidgetIndentsHighlightingPassFactory(@NotNull Project project) {
  this.project = project;
  flutterDartAnalysisService = FlutterDartAnalysisServer.getInstance(project);
  this.editorOutlineService = ActiveEditorsOutlineService.getInstance(project);
  this.inspectorGroupManagerService = InspectorGroupManagerService.getInstance(project);
  this.editorEventService = EditorMouseEventService.getInstance(project);
  this.editorPositionService = EditorPositionService.getInstance(project);
  this.settingsListener = new SettingsListener();
  this.outlineListener = this::updateEditor;

  TextEditorHighlightingPassRegistrar.getInstance(project)
    .registerTextEditorHighlightingPass(this, TextEditorHighlightingPassRegistrar.Anchor.AFTER, Pass.UPDATE_FOLDING, false, false);

  syncSettings(FlutterSettings.getInstance());
  FlutterSettings.getInstance().addListener(settingsListener);

  final EditorEventMulticaster eventMulticaster = EditorFactory.getInstance().getEventMulticaster();
  eventMulticaster.addCaretListener(new CaretListener() {
    @Override
    public void caretPositionChanged(@NotNull CaretEvent event) {
      final Editor editor = event.getEditor();
      if (editor.getProject() != project) return;
      if (editor.isDisposed() || project.isDisposed()) return;
      if (!(editor instanceof EditorEx)) return;
      final EditorEx editorEx = (EditorEx)editor;
      WidgetIndentsHighlightingPass.onCaretPositionChanged(editorEx, event.getCaret());
    }
  }, this);
  editorOutlineService.addListener(outlineListener);
}
 
Example #3
Source File: WidgetIndentsHighlightingPassFactory.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public WidgetIndentsHighlightingPassFactory(@NotNull Project project) {
  this.project = project;
  flutterDartAnalysisService = FlutterDartAnalysisServer.getInstance(project);
  this.editorOutlineService = ActiveEditorsOutlineService.getInstance(project);
  this.inspectorGroupManagerService = InspectorGroupManagerService.getInstance(project);
  this.editorEventService = EditorMouseEventService.getInstance(project);
  this.editorPositionService = EditorPositionService.getInstance(project);
  this.settingsListener = new SettingsListener();
  this.outlineListener = this::updateEditor;

  TextEditorHighlightingPassRegistrar.getInstance(project)
    .registerTextEditorHighlightingPass(this, TextEditorHighlightingPassRegistrar.Anchor.AFTER, Pass.UPDATE_FOLDING, false, false);

  syncSettings(FlutterSettings.getInstance());
  FlutterSettings.getInstance().addListener(settingsListener);

  final EditorEventMulticaster eventMulticaster = EditorFactory.getInstance().getEventMulticaster();
  eventMulticaster.addCaretListener(new CaretListener() {
    @Override
    public void caretPositionChanged(@NotNull CaretEvent event) {
      final Editor editor = event.getEditor();
      if (editor.getProject() != project) return;
      if (editor.isDisposed() || project.isDisposed()) return;
      if (!(editor instanceof EditorEx)) return;
      final EditorEx editorEx = (EditorEx)editor;
      WidgetIndentsHighlightingPass.onCaretPositionChanged(editorEx, event.getCaret());
    }
  }, this);
  editorOutlineService.addListener(outlineListener);
}
 
Example #4
Source File: SassLintConfigFileListener.java    From sass-lint-plugin with MIT License 5 votes vote down vote up
private void startListener() {
    if (LISTENING.compareAndSet(false, true))
        ApplicationManager.getApplication().invokeLater(new Runnable() {
            public void run() {
                ApplicationManager.getApplication().runWriteAction(new Runnable() {
                    public void run() {
                        VirtualFileManager.getInstance().addVirtualFileListener(new SassLintConfigFileVfsListener(), SassLintConfigFileListener.this.project);
                        EditorEventMulticaster multicaster = EditorFactory.getInstance().getEventMulticaster();
                        multicaster.addDocumentListener(new SassLintConfigFileDocumentListener(), SassLintConfigFileListener.this.project);
                    }
                });
            }
        });
}
 
Example #5
Source File: ESLintConfigFileListener.java    From eslint-plugin with MIT License 5 votes vote down vote up
private void startListener() {
    if (LISTENING.compareAndSet(false, true))
        ApplicationManager.getApplication().invokeLater(new Runnable() {
            public void run() {
                ApplicationManager.getApplication().runWriteAction(new Runnable() {
                    public void run() {
                        VirtualFileManager.getInstance().addVirtualFileListener(new ESLintConfigFileVfsListener(), ESLintConfigFileListener.this.project);
                        EditorEventMulticaster multicaster = EditorFactory.getInstance().getEventMulticaster();
                        multicaster.addDocumentListener(new ESLintConfigFileDocumentListener(), ESLintConfigFileListener.this.project);
                    }
                });
            }
        });
}
 
Example #6
Source File: ColumnSelectionModePanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void install(@Nonnull StatusBar statusBar) {
  super.install(statusBar);
  KeyboardFocusManager.getCurrentKeyboardFocusManager()
          .addPropertyChangeListener(SWING_FOCUS_OWNER_PROPERTY, evt -> propertyChange(new PropertyChangeEvent(evt.getSource(), evt.getPropertyName(), evt.getOldValue(), evt.getNewValue())));
  Disposer.register(this, () -> KeyboardFocusManager.getCurrentKeyboardFocusManager()
          .removePropertyChangeListener(SWING_FOCUS_OWNER_PROPERTY, evt -> propertyChange(new PropertyChangeEvent(evt.getSource(), evt.getPropertyName(), evt.getOldValue(), evt.getNewValue()))));
  EditorEventMulticaster multicaster = EditorFactory.getInstance().getEventMulticaster();
  if (multicaster instanceof EditorEventMulticasterEx) {
    ((EditorEventMulticasterEx)multicaster).addPropertyChangeListener(this, this);
  }
}
 
Example #7
Source File: MockEditorFactory.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
@Nonnull
public EditorEventMulticaster getEventMulticaster() {
  return new MockEditorEventMulticaster();
}
 
Example #8
Source File: EditorFactoryImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
@Nonnull
public EditorEventMulticaster getEventMulticaster() {
  return myEditorEventMulticaster;
}
 
Example #9
Source File: EditorFactory.java    From consulo with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the service for attaching event listeners to all editor instances.
 */
@Nonnull
public abstract EditorEventMulticaster getEventMulticaster();