Java Code Examples for com.intellij.openapi.editor.event.EditorFactoryEvent#getEditor()

The following examples show how to use com.intellij.openapi.editor.event.EditorFactoryEvent#getEditor() . 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: CoverageDataManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@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 2
Source File: HighlightBracketPairApplicationComponent.java    From HighlightBracketPair with Apache License 2.0 5 votes vote down vote up
/**
 * 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 3
Source File: LineStatusTrackerManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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 4
Source File: LineStatusTrackerManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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 5
Source File: TemplateManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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: ParticleContainerManager.java    From power-mode-intellij-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public void editorCreated(@NotNull EditorFactoryEvent event) {
    final Editor editor = event.getEditor();
    particleContainers.put(editor, new ParticleContainer(editor));
}
 
Example 7
Source File: EditorBackgroundListener.java    From intellij-background-chibichara with MIT License 4 votes vote down vote up
@Override
public void editorCreated(EditorFactoryEvent event) {
    editor = event.getEditor();
    editorComponent = editor.getContentComponent();
    refreshBackgroundImageBorder();
}
 
Example 8
Source File: CoverageDataManagerImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@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 9
Source File: EditorTracker.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void editorReleased(@Nonnull EditorFactoryEvent event) {
  final Editor editor = event.getEditor();
  if (editor.getProject() != null && editor.getProject() != myProject) return;
  unregisterEditor(editor);
  executeOnRelease(editor);
}