private void showEditorWarningMessage(final String message) {
    ApplicationManager.getApplication()
        .invokeLater(
            () -> {
              if (myEditor == null) return;
              final FileEditorManager fileEditorManager = FileEditorManager.getInstance(myProject);
              final VirtualFile vFile = myFile.getVirtualFile();
              assert vFile != null;
              Map<FileEditor, EditorNotificationPanel> map =
                  myFile.getCopyableUserData(NOTIFICATION_PANELS);
              if (map == null) {
                map = new HashMap<FileEditor, EditorNotificationPanel>();
                myFile.putCopyableUserData(NOTIFICATION_PANELS, map);
              }

              final FileEditor[] editors = fileEditorManager.getAllEditors(vFile);
              for (final FileEditor editor : editors) {
                if (isCurrentEditor(editor)) {
                  final EditorNotificationPanel panel =
                      new EditorNotificationPanel() {
                        {
                          myLabel.setIcon(AllIcons.General.ExclMark);
                          myLabel.setText(message);
                        }
                      };
                  panel.createActionLabel(
                      "Close", () -> fileEditorManager.removeTopComponent(editor, panel));
                  map.put(editor, panel);
                  fileEditorManager.addTopComponent(editor, panel);
                  break;
                }
              }
            });
  }
  private static void reinitBreadcrumbsComponent(
      @NotNull final FileEditorManager fileEditorManager, @NotNull VirtualFile file) {
    if (isSuitable(fileEditorManager.getProject(), file)) {
      FileEditor[] fileEditors = fileEditorManager.getAllEditors(file);
      for (final FileEditor fileEditor : fileEditors) {
        if (fileEditor instanceof TextEditor) {
          Editor editor = ((TextEditor) fileEditor).getEditor();
          if (BreadcrumbsXmlWrapper.getBreadcrumbsComponent(editor) != null) {
            continue;
          }
          final BreadcrumbsXmlWrapper wrapper = new BreadcrumbsXmlWrapper(editor);
          final JComponent c = wrapper.getComponent();
          fileEditorManager.addTopComponent(fileEditor, c);

          Disposer.register(
              fileEditor,
              new Disposable() {
                @Override
                public void dispose() {
                  disposeWrapper(fileEditorManager, fileEditor, wrapper);
                }
              });
        }
      }
    } else {
      removeBreadcrumbs(fileEditorManager, file);
    }
  }
 private void renewInformationInEditors() {
   final FileEditorManager fileEditorManager = FileEditorManager.getInstance(myProject);
   final VirtualFile[] openFiles = fileEditorManager.getOpenFiles();
   for (VirtualFile openFile : openFiles) {
     final FileEditor[] allEditors = fileEditorManager.getAllEditors(openFile);
     applyInformationToEditor(allEditors, openFile);
   }
 }
 private static void updateModifiedProperty(@NotNull VirtualFile file) {
   for (Project project : ProjectManager.getInstance().getOpenProjects()) {
     FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
     for (FileEditor editor : fileEditorManager.getAllEditors(file)) {
       if (editor instanceof TextEditorImpl) {
         ((TextEditorImpl) editor).updateModifiedProperty();
       }
     }
   }
 }
 private void installAnathema() {
   myAnathemaThrown = true;
   final FileEditor[] editors = myFileEditorManager.getAllEditors(myVirtualFile);
   for (FileEditor editor : editors) {
     CanNotCalculateDiffPanel panel = editor.getUserData(PANEL_KEY);
     if (panel == null) {
       final CanNotCalculateDiffPanel newPanel = new CanNotCalculateDiffPanel();
       editor.putUserData(PANEL_KEY, newPanel);
       myFileEditorManager.addTopComponent(editor, newPanel);
     }
   }
 }
 private static void removeBreadcrumbs(
     @NotNull FileEditorManager fileEditorManager, @NotNull VirtualFile file) {
   final FileEditor[] fileEditors = fileEditorManager.getAllEditors(file);
   for (FileEditor fileEditor : fileEditors) {
     if (fileEditor instanceof TextEditor) {
       Editor editor = ((TextEditor) fileEditor).getEditor();
       BreadcrumbsXmlWrapper wrapper = BreadcrumbsXmlWrapper.getBreadcrumbsComponent(editor);
       if (wrapper != null) {
         disposeWrapper(fileEditorManager, fileEditor, wrapper);
       }
     }
   }
 }
Ejemplo n.º 7
0
  private void updateAllWarnings(@Nullable VirtualFile vf) {
    if (IdeMain.getTestMode() == TestMode.CORE_TEST) return;

    for (FileEditor editor : myFileEditorManager.getAllEditors()) {
      if (editor instanceof MPSFileNodeEditor) {
        MPSFileNodeEditor mpsEditor = (MPSFileNodeEditor) editor;
        if (!mpsEditor.isDisposed()) {
          if (vf == null || vf.equals(mpsEditor.getFile())) {
            updateWarnings(mpsEditor);
          }
        }
      }
    }
  }
Ejemplo n.º 8
0
 @Override
 public void fileClosed(FileEditorManager source, VirtualFile file) {
   myWarnings.keySet().retainAll(Arrays.asList(source.getAllEditors()));
 }