Exemplo n.º 1
0
 @Override
 public void editorCreated(@NotNull EditorFactoryEvent event) {
   Document document = event.getEditor().getDocument();
   VirtualFile file = FileDocumentManager.getInstance().getFile(document);
   if (file != null && file.getFileType() instanceof CoqFileType) {
     checkForUpdates();
   }
 }
  @Override
  public void editorReleased(@NotNull EditorFactoryEvent editorFactoryEvent) {
    Editor editor = editorFactoryEvent.getEditor();
    JComponent contentComponent = editor.getContentComponent();

    editorsList.remove(editor);

    contentComponent.setBorder(null);
  }
  /** ******************** EditorFactoryListener ******************** */
  @Override
  public void editorCreated(@NotNull EditorFactoryEvent editorFactoryEvent) {
    Editor editor = editorFactoryEvent.getEditor();
    JComponent contentComponent = editor.getContentComponent();

    editorsList.add(editor);

    contentComponent.setBorder(new BackgroundImageBorder());
    loadImage(editor);
  }
    public void editorCreated(@NotNull 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);
      }
    }
 public void editorReleased(@NotNull 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);
     }
   }
 }