public EditorsSplitters(
      final FileEditorManagerImpl manager,
      DockManager dockManager,
      boolean createOwnDockableContainer) {
    super(new BorderLayout());
    setOpaque(false);
    myManager = manager;
    myFocusWatcher = new MyFocusWatcher();
    setFocusTraversalPolicy(new MyFocusTraversalPolicy());
    setTransferHandler(new MyTransferHandler());
    clear();

    if (createOwnDockableContainer) {
      DockableEditorTabbedContainer dockable =
          new DockableEditorTabbedContainer(myManager.getProject(), this, false);
      Disposer.register(manager.getProject(), dockable);
      dockManager.register(dockable);
    }

    UISettings.getInstance()
        .addUISettingsListener(
            new UISettingsListener() {
              @Override
              public void uiSettingsChanged(UISettings source) {
                updateBackground();
              }
            },
            manager.getProject());
    updateBackground();
  }
  EditorsSplitters(
      final FileEditorManagerImpl manager,
      DockManager dockManager,
      boolean createOwnDockableContainer) {
    super(new BorderLayout());
    myManager = manager;
    myFocusWatcher = new MyFocusWatcher();
    setFocusTraversalPolicy(new MyFocusTraversalPolicy());
    clear();

    if (createOwnDockableContainer) {
      DockableEditorTabbedContainer dockable =
          new DockableEditorTabbedContainer(myManager.getProject(), this, false);
      Disposer.register(manager.getProject(), dockable);
      dockManager.register(dockable);
    }
    KeymapManagerListener keymapListener =
        new KeymapManagerListener() {
          @Override
          public void activeKeymapChanged(Keymap keymap) {
            invalidate();
            repaint();
          }
        };
    KeymapManager.getInstance().addKeymapManagerListener(keymapListener, this);
  }
  void updateFileName(@Nullable final VirtualFile updatedFile) {
    final EditorWindow[] windows = getWindows();
    for (int i = 0; i != windows.length; ++i) {
      for (VirtualFile file : windows[i].getFiles()) {
        if (updatedFile == null || file.getName().equals(updatedFile.getName())) {
          windows[i].updateFileName(file);
        }
      }
    }

    Project project = myManager.getProject();

    final IdeFrame frame = getFrame(project);
    if (frame != null) {
      VirtualFile file = getCurrentFile();

      File ioFile = file == null ? null : new File(file.getPresentableUrl());
      String fileTitle = null;
      if (file != null) {
        fileTitle =
            DumbService.isDumb(project)
                ? file.getName()
                : FrameTitleBuilder.getInstance().getFileTitle(project, file);
      }

      frame.setFileTitle(fileTitle, ioFile);
    }
  }
 @Override
 public void uiSettingsChanged(UISettings source) {
   if (!myManager.getProject().isOpen()) return;
   for (VirtualFile file : getOpenFiles()) {
     updateFileBackgroundColor(file);
     updateFileIcon(file);
     updateFileColor(file);
   }
 }
 private void updateFileIconLater(VirtualFile file) {
   myFilesToUpdateIconsFor.add(file);
   myIconUpdaterAlarm.cancelAllRequests();
   myIconUpdaterAlarm.addRequest(
       () -> {
         if (myManager.getProject().isDisposed()) return;
         for (VirtualFile file1 : myFilesToUpdateIconsFor) {
           updateFileIconImmediately(file1);
         }
         myFilesToUpdateIconsFor.clear();
       },
       200,
       ModalityState.stateForComponent(this));
 }
  public void updateFileName(final VirtualFile updatedFile) {
    final EditorWindow[] windows = getWindows();
    for (int i = 0; i != windows.length; ++i) {
      windows[i].updateFileName(updatedFile);
    }

    Project project = myManager.getProject();

    final IdeFrame frame = getFrame(project);
    if (frame != null) {
      VirtualFile file = getCurrentFile();

      File ioFile = file == null ? null : new File(file.getPresentableUrl());
      String fileTitle =
          file == null ? null : FrameTitleBuilder.getInstance().getFileTitle(project, file);

      frame.setFileTitle(fileTitle, ioFile);
    }
  }
 void closeFile(VirtualFile file, boolean moveFocus) {
   final List<EditorWindow> windows = findWindows(file);
   if (!windows.isEmpty()) {
     final VirtualFile nextFile = findNextFile(file);
     for (final EditorWindow window : windows) {
       LOG.assertTrue(window.getSelectedEditor() != null);
       window.closeFile(file, false, moveFocus);
       if (window.getTabCount() == 0 && nextFile != null && myManager.getProject().isOpen()) {
         EditorWithProviderComposite newComposite = myManager.newEditorComposite(nextFile);
         window.setEditor(newComposite, moveFocus); // newComposite can be null
       }
     }
     // cleanup windows with no tabs
     for (final EditorWindow window : windows) {
       if (window.isDisposed()) {
         // call to window.unsplit() which might make its sibling disposed
         continue;
       }
       if (window.getTabCount() == 0) {
         window.unsplit(false);
       }
     }
   }
 }
    @Override
    protected JPanel processFiles(@NotNull List<Element> fileElements, final JPanel context) {
      final Ref<EditorWindow> windowRef = new Ref<EditorWindow>();
      UIUtil.invokeAndWaitIfNeeded(
          new Runnable() {
            @Override
            public void run() {
              windowRef.set(context == null ? createEditorWindow() : findWindowWith(context));
            }
          });
      final EditorWindow window = windowRef.get();
      LOG.assertTrue(window != null);
      VirtualFile focusedFile = null;

      for (int i = 0; i < fileElements.size(); i++) {
        final Element file = fileElements.get(i);
        if (i == 0) {
          EditorTabbedContainer tabbedPane = window.getTabbedPane();
          if (tabbedPane != null) {
            try {
              int limit =
                  Integer.parseInt(
                      file.getParentElement()
                          .getAttributeValue(
                              JBTabsImpl.SIDE_TABS_SIZE_LIMIT_KEY.toString(),
                              String.valueOf(JBTabsImpl.DEFAULT_MAX_TAB_WIDTH)));
              UIUtil.putClientProperty(
                  tabbedPane.getComponent(), JBTabsImpl.SIDE_TABS_SIZE_LIMIT_KEY, limit);
            } catch (NumberFormatException e) {
              // ignore
            }
          }
        }
        try {
          final FileEditorManagerImpl fileEditorManager = getManager();
          Element historyElement = file.getChild(HistoryEntry.TAG);
          final HistoryEntry entry =
              HistoryEntry.createLight(fileEditorManager.getProject(), historyElement);
          final VirtualFile virtualFile = entry.getFile();
          if (virtualFile == null)
            throw new InvalidDataException("No file exists: " + entry.getFilePointer().getUrl());
          Document document =
              ApplicationManager.getApplication()
                  .runReadAction(
                      new Computable<Document>() {
                        @Override
                        public Document compute() {
                          return virtualFile.isValid()
                              ? FileDocumentManager.getInstance().getDocument(virtualFile)
                              : null;
                        }
                      });
          final boolean isCurrentInTab =
              Boolean.valueOf(file.getAttributeValue(CURRENT_IN_TAB)).booleanValue();
          Boolean pin = Boolean.valueOf(file.getAttributeValue(PINNED));
          fileEditorManager.openFileImpl4(
              window, virtualFile, entry, isCurrentInTab, isCurrentInTab, pin, i);
          if (isCurrentInTab) {
            focusedFile = virtualFile;
          }
          if (document != null) {
            // This is just to make sure document reference is kept on stack till this point
            // so that document is available for folding state deserialization in HistoryEntry
            // constructor
            // and that document will be created only once during file opening
            document.putUserData(DUMMY_KEY, null);
          }
          updateProgress();
        } catch (InvalidDataException e) {
          if (ApplicationManager.getApplication().isUnitTestMode()) {
            LOG.error(e);
          }
        }
      }
      if (focusedFile != null) {
        getManager().addSelectionRecord(focusedFile, window);
      }
      return window.myPanel;
    }
  @Nullable
  @SuppressWarnings({"HardCodedStringLiteral"})
  private JPanel readExternalPanel(
      final Element element, @Nullable JPanel panel, Ref<EditorWindow> currentWindow) {
    final Element splitterElement = element.getChild("splitter");
    if (splitterElement != null) {
      return readSplitter(panel, splitterElement, currentWindow);
    }

    final Element leaf = element.getChild("leaf");
    if (leaf == null) {
      return null;
    }

    final EditorWindow window = panel == null ? new EditorWindow(this) : findWindowWith(panel);
    LOG.assertTrue(window != null);

    @SuppressWarnings("unchecked")
    final List<Element> children = ContainerUtil.newArrayList(leaf.getChildren("file"));
    if (UISettings.getInstance().ACTIVATE_RIGHT_EDITOR_ON_CLOSE) {
      Collections.reverse(children);
    }

    // trim to EDITOR_TAB_LIMIT, ignoring CLOSE_NON_MODIFIED_FILES_FIRST policy
    for (Iterator<Element> iterator = children.iterator();
        iterator.hasNext() && UISettings.getInstance().EDITOR_TAB_LIMIT < children.size(); ) {
      Element child = iterator.next();
      if (!Boolean.valueOf(child.getAttributeValue(PINNED)).booleanValue()) {
        iterator.remove();
      }
    }

    VirtualFile currentFile = null;
    for (int i = 0; i < children.size(); i++) {
      final Element file = children.get(i);
      try {
        final FileEditorManagerImpl fileEditorManager = getManager();
        final HistoryEntry entry =
            new HistoryEntry(fileEditorManager.getProject(), file.getChild(HistoryEntry.TAG), true);
        final boolean isCurrent = Boolean.valueOf(file.getAttributeValue("current")).booleanValue();
        fileEditorManager.openFileImpl4(window, entry.myFile, false, entry, isCurrent, i);
        if (fileEditorManager.isFileOpen(entry.myFile)) {
          window.setFilePinned(
              entry.myFile, Boolean.valueOf(file.getAttributeValue(PINNED)).booleanValue());
          if (Boolean.valueOf(file.getAttributeValue("current-in-tab")).booleanValue()) {
            currentFile = entry.myFile;
          }
        }

      } catch (InvalidDataException e) {
        if (ApplicationManager.getApplication().isUnitTestMode()) {
          LOG.error(e);
        }
      }
    }
    if (currentFile != null) {
      final EditorComposite editor = window.findFileComposite(currentFile);
      if (editor != null) {
        window.setSelectedEditor(editor, true);
      }
    }
    return window.myPanel;
  }