Java Code Examples for com.intellij.openapi.fileEditor.ex.FileEditorManagerEx

The following examples show how to use com.intellij.openapi.fileEditor.ex.FileEditorManagerEx. These examples are extracted from open source projects. 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 Project: lsp4intellij   Source File: FileUtilsTest.java    License: Apache License 2.0 6 votes vote down vote up
@PrepareForTest(FileEditorManager.class)
@Test
public void testEditorFromVirtualFile() {
  VirtualFile file = PowerMockito.mock(VirtualFile.class);
  Project project = PowerMockito.mock(Project.class);

  Editor editor = PowerMockito.mock(Editor.class);
  TextEditor textEditor = PowerMockito.mock(TextEditor.class);
  PowerMockito.when(textEditor.getEditor()).thenReturn(editor);

  FileEditorManagerEx fileEditorManagerEx = PowerMockito.mock(FileEditorManagerEx.class);
  PowerMockito.mockStatic(FileEditorManager.class);
  PowerMockito.when(fileEditorManagerEx.getAllEditors(file))
      .thenReturn(new FileEditor[]{textEditor})
      .thenReturn(new FileEditor[0]);
  PowerMockito.when(FileEditorManager.getInstance(project)).thenReturn(fileEditorManagerEx);

  Assert.assertEquals(editor, FileUtils.editorFromVirtualFile(file, project));

  Assert.assertNull(FileUtils.editorFromVirtualFile(file, project));
}
 
Example 2
Source Project: emacsIDEAs   Source File: EmacsIdeasAction.java    License: Apache License 2.0 6 votes vote down vote up
private ArrayList<Editor> collect_active_editors(AnActionEvent e) {
    ArrayList<Editor> editors = new ArrayList<Editor>();

    final Project project = e.getData(CommonDataKeys.PROJECT);
    final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
    FileEditor[] selectedEditors = fileEditorManager.getSelectedEditors();

    for (FileEditor selectedEditor : selectedEditors) {
        if (selectedEditor instanceof TextEditor) {
            Editor editor = ((TextEditor) selectedEditor).getEditor();
            editors.add(editor);
        }
    }

    return editors;
}
 
Example 3
Source Project: consulo   Source File: CoverageView.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void selectElementFromEditor(@Nonnull FileEditor editor) {
  if (myProject.isDisposed() || !CoverageView.this.isShowing()) return;
  if (myStateBean.myAutoScrollFromSource) {
    final VirtualFile file = FileEditorManagerEx.getInstanceEx(myProject).getFile(editor);
    if (file != null) {
      if (canSelect(file)) {
        PsiElement e = null;
        if (editor instanceof TextEditor) {
          final int offset = ((TextEditor)editor).getEditor().getCaretModel().getOffset();
          PsiDocumentManager.getInstance(myProject).commitAllDocuments();
          final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file);
          if (psiFile != null) {
            e = psiFile.findElementAt(offset);
          }
        }
        myBuilder.select(e != null ? e : file);
      }
    }
  }
}
 
Example 4
Source Project: consulo   Source File: DumbServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
private void updateFinished() {
  if (!WriteAction.compute(this::switchToSmartMode)) return;

  if (ApplicationManager.getApplication().isInternal()) LOG.info("updateFinished");

  try {
    myPublisher.exitDumbMode();
    FileEditorManagerEx.getInstanceEx(myProject).refreshIcons();
  }
  finally {
    // It may happen that one of the pending runWhenSmart actions triggers new dumb mode;
    // in this case we should quit processing pending actions and postpone them until the newly started dumb mode finishes.
    while (!isDumb()) {
      final Runnable runnable;
      synchronized (myRunWhenSmartQueue) {
        if (myRunWhenSmartQueue.isEmpty()) {
          break;
        }
        runnable = myRunWhenSmartQueue.pullFirst();
      }
      doRun(runnable);
    }
  }
}
 
Example 5
Source Project: consulo   Source File: EditorTabbedContainer.java    License: Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
@Override
public void actionPerformed(final AnActionEvent e) {
  final FileEditorManagerEx mgr = FileEditorManagerEx.getInstanceEx(myProject);
  consulo.fileEditor.impl.EditorWindow window;
  final VirtualFile file = (VirtualFile)myTabInfo.getObject();
  if (ActionPlaces.EDITOR_TAB.equals(e.getPlace())) {
    window = myWindow;
  }
  else {
    window = mgr.getCurrentWindow();
  }

  if (window != null) {
    if (BitUtil.isSet(e.getModifiers(), InputEvent.ALT_MASK)) {
      window.closeAllExcept(file);
    }
    else {
      if (window.findFileComposite(file) != null) {
        mgr.closeFile(file, window);
      }
    }
  }
}
 
Example 6
Source Project: consulo   Source File: EditorTabbedContainer.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void close() {
  TabInfo selected = myTabs.getTargetInfo();
  if (selected == null) return;

  final VirtualFile file = (VirtualFile)selected.getObject();
  final FileEditorManagerEx mgr = FileEditorManagerEx.getInstanceEx(myProject);

  AsyncResult<EditorWindow> window = mgr.getActiveWindow();
  window.doWhenDone(wnd -> {
    if (wnd != null) {
      if (wnd.findFileComposite(file) != null) {
        mgr.closeFile(file, wnd);
      }
    }
  });
}
 
Example 7
Source Project: consulo   Source File: EditorTabbedContainer.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void mouseReleased(MouseEvent e) {
  if (UIUtil.isCloseClick(e, MouseEvent.MOUSE_RELEASED)) {
    final TabInfo info = myTabs.findInfo(e);
    if (info != null) {
      IdeEventQueue.getInstance().blockNextEvents(e);
      if (e.isAltDown() && e.getButton() == MouseEvent.BUTTON1) {//close others
        List<TabInfo> allTabInfos = myTabs.getTabs();
        for (TabInfo tabInfo : allTabInfos) {
          if (tabInfo == info) continue;
          FileEditorManagerEx.getInstanceEx(myProject).closeFile((VirtualFile)tabInfo.getObject(), myWindow);
        }
      }
      else {
        FileEditorManagerEx.getInstanceEx(myProject).closeFile((VirtualFile)info.getObject(), myWindow);
      }
    }
  }
}
 
Example 8
Source Project: consulo   Source File: EditorTabbedContainer.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void dragOutFinished(MouseEvent event, TabInfo source) {
  boolean copy = UIUtil.isControlKeyDown(event) || mySession.getResponse(event) == DockContainer.ContentResponse.ACCEPT_COPY;
  if (!copy) {
    myFile.putUserData(FileEditorManagerImpl.CLOSING_TO_REOPEN, Boolean.TRUE);
    FileEditorManagerEx.getInstanceEx(myProject).closeFile(myFile, myWindow);
  }
  else {
    source.setHidden(false);
  }

  mySession.process(event);
  if (!copy) {
    myFile.putUserData(FileEditorManagerImpl.CLOSING_TO_REOPEN, null);
  }

  myFile = null;
  mySession = null;
}
 
Example 9
public void actionPerformed(final AnActionEvent event) {
  final VirtualFile vFile = event.getData(PlatformDataKeys.VIRTUAL_FILE);
  final Project project = event.getData(CommonDataKeys.PROJECT);
  if (vFile == null || project == null) {
    return;
  }
  final EditorWindow window = event.getData(EditorWindow.DATA_KEY);
  if (window != null) {
    final EditorWindow[] siblings = window.findSiblings();
    if (siblings.length == 1) {
      final EditorWithProviderComposite editorComposite = window.getSelectedEditor();
      final HistoryEntry entry = editorComposite.currentStateAsHistoryEntry();
      ((FileEditorManagerImpl)FileEditorManagerEx.getInstanceEx(project)).openFileImpl3(UIAccess.get(), siblings[0], vFile, true, entry, true);
      window.closeFile(vFile);
    }
  }
}
 
Example 10
Source Project: consulo   Source File: FileDropHandler.java    License: Apache License 2.0 6 votes vote down vote up
private void openFiles(final Project project, final List<File> fileList, EditorWindow editorWindow) {
  if (editorWindow == null && myEditor != null) {
    editorWindow = findEditorWindow(project);
  }
  final LocalFileSystem fileSystem = LocalFileSystem.getInstance();
  for (File file : fileList) {
    final VirtualFile vFile = fileSystem.refreshAndFindFileByIoFile(file);
    final FileEditorManagerEx fileEditorManager = (FileEditorManagerEx) FileEditorManager.getInstance(project);
    if (vFile != null) {
      NonProjectFileWritingAccessProvider.allowWriting(vFile);

      if (editorWindow != null) {
        fileEditorManager.openFileWithProviders(vFile, true, editorWindow);
      }
      else {
        new OpenFileDescriptor(project, vFile).navigate(true);
      }
    }
  }
}
 
Example 11
Source Project: consulo   Source File: FileDropHandler.java    License: Apache License 2.0 6 votes vote down vote up
@Nullable
private EditorWindow findEditorWindow(Project project) {
  final Document document = myEditor.getDocument();
  final VirtualFile file = FileDocumentManager.getInstance().getFile(document);
  if (file != null) {
    final FileEditorManagerEx fileEditorManager = (FileEditorManagerEx) FileEditorManager.getInstance(project);
    final EditorWindow[] windows = fileEditorManager.getWindows();
    for (EditorWindow window : windows) {
      final EditorWithProviderComposite composite = window.findFileComposite(file);
      if (composite == null) {
        continue;
      }
      for (FileEditor editor : composite.getEditors()) {
        if (editor instanceof TextEditor && ((TextEditor)editor).getEditor() == myEditor) {
          return window;
        }
      }
    }
  }
  return null;
}
 
Example 12
Source Project: consulo   Source File: IdeDocumentHistoryImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void gotoPlaceInfo(@Nonnull PlaceInfo info) {
  final boolean wasActive = ToolWindowManager.getInstance(myProject).isEditorComponentActive();
  EditorWindow wnd = info.getWindow();
  FileEditorManagerEx editorManager = getFileEditorManager();
  final Pair<FileEditor[], FileEditorProvider[]> editorsWithProviders =
          wnd != null && wnd.isValid() ? editorManager.openFileWithProviders(info.getFile(), wasActive, wnd) : editorManager.openFileWithProviders(info.getFile(), wasActive, false);

  editorManager.setSelectedEditor(info.getFile(), info.getEditorTypeId());

  final FileEditor[] editors = editorsWithProviders.getFirst();
  final FileEditorProvider[] providers = editorsWithProviders.getSecond();
  for (int i = 0; i < editors.length; i++) {
    String typeId = providers[i].getEditorTypeId();
    if (typeId.equals(info.getEditorTypeId())) {
      editors[i].setState(info.getNavigationState());
    }
  }
}
 
Example 13
Source Project: consulo   Source File: TabNavigationActionBase.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void update(@Nonnull AnActionEvent event) {
  Presentation presentation = event.getPresentation();
  Project project = event.getData(CommonDataKeys.PROJECT);
  presentation.setEnabled(false);
  if (project == null) {
    return;
  }
  final ToolWindowManager windowManager = ToolWindowManager.getInstance(project);
  if (windowManager.isEditorComponentActive()) {
    final FileEditorManagerEx editorManager = FileEditorManagerEx.getInstanceEx(project);
    EditorWindow currentWindow = event.getData(EditorWindow.DATA_KEY);
    if (currentWindow == null) {
      editorManager.getCurrentWindow();
    }
    if (currentWindow != null) {
      final VirtualFile[] files = currentWindow.getFiles();
      presentation.setEnabled(files.length > 1);
    }
    return;
  }

  ContentManager contentManager = event.getData(PlatformDataKeys.NONEMPTY_CONTENT_MANAGER);
  presentation.setEnabled(contentManager != null && contentManager.getContentCount() > 1 && contentManager.isSingleSelection());
}
 
Example 14
Source Project: consulo   Source File: CloseAllEditorsButActiveAction.java    License: Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  Project project = e.getData(CommonDataKeys.PROJECT);
  FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
  VirtualFile selectedFile;
  final EditorWindow window = e.getData(EditorWindow.DATA_KEY);
  if (window != null) {
    window.closeAllExcept(e.getData(PlatformDataKeys.VIRTUAL_FILE));
    return;
  }
  selectedFile = fileEditorManager.getSelectedFiles()[0];
  final VirtualFile[] siblings = fileEditorManager.getSiblings(selectedFile);
  for (final VirtualFile sibling : siblings) {
    if (!Comparing.equal(selectedFile, sibling)) {
      fileEditorManager.closeFile(sibling);
    }
  }
}
 
Example 15
Source Project: consulo   Source File: CloseAllEditorsButActiveAction.java    License: Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
@Override
public void update(@Nonnull AnActionEvent event) {
  Presentation presentation = event.getPresentation();
  Project project = event.getData(CommonDataKeys.PROJECT);
  if (project == null) {
    presentation.setEnabled(false);
    return;
  }
  FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
  VirtualFile selectedFile;
  final EditorWindow window = event.getData(EditorWindow.DATA_KEY);
  if (window != null) {
    presentation.setEnabled(window.getFiles().length > 1);
    return;
  }
  else {
    if (fileEditorManager.getSelectedFiles().length == 0) {
      presentation.setEnabled(false);
      return;
    }
    selectedFile = fileEditorManager.getSelectedFiles()[0];
  }
  VirtualFile[] siblings = fileEditorManager.getSiblings(selectedFile);
  presentation.setEnabled(siblings.length > 1);
}
 
Example 16
Source Project: consulo   Source File: CloseEditorAction.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
  final Project project = e.getData(CommonDataKeys.PROJECT);

  FileEditorManagerEx editorManager = getEditorManager(project);
  EditorWindow window = e.getData(EditorWindow.DATA_KEY);
  VirtualFile file = null;
  if (window == null) {
    window = editorManager.getActiveWindow().getResult();
    if (window != null) {
      file = window.getSelectedFile();
    }
  }
  else {
    file = e.getData(PlatformDataKeys.VIRTUAL_FILE);
  }
  if (file != null) {
    editorManager.closeFile(file, window);
  }
}
 
Example 17
Source Project: consulo   Source File: CloseAllEditorsAction.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(final AnActionEvent e) {
  final Project project = e.getData(CommonDataKeys.PROJECT);
  CommandProcessor commandProcessor = CommandProcessor.getInstance();
  commandProcessor.executeCommand(project, () -> {
    final EditorWindow window = e.getData(EditorWindow.DATA_KEY);
    if (window != null) {
      final VirtualFile[] files = window.getFiles();
      for (final VirtualFile file : files) {
        window.closeFile(file);
      }
      return;
    }
    FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
    VirtualFile selectedFile = fileEditorManager.getSelectedFiles()[0];
    VirtualFile[] openFiles = fileEditorManager.getSiblings(selectedFile);
    for (final VirtualFile openFile : openFiles) {
      fileEditorManager.closeFile(openFile);
    }
  }, IdeBundle.message("command.close.all.editors"), null);
}
 
Example 18
Source Project: consulo   Source File: PinActiveTabAction.java    License: Apache License 2.0 6 votes vote down vote up
protected Handler getHandler(@Nonnull AnActionEvent e) {
  Project project = e.getProject();
  EditorWindow currentWindow = e.getData(EditorWindow.DATA_KEY);

  Content content = currentWindow != null ? null : getContentFromEvent(e);
  if (content != null && content.isPinnable()) {
    return createHandler(content);
  }

  final EditorWindow window = currentWindow != null ? currentWindow :
                              project != null ? FileEditorManagerEx.getInstanceEx(project).getCurrentWindow() : null;
  VirtualFile selectedFile = window == null ? null : getFileFromEvent(e, window);
  if (selectedFile != null) {
    return createHandler(window, selectedFile);
  }
  return null;
}
 
Example 19
@Override
protected void selectElementFromEditor(@Nonnull FileEditor editor) {
  final VirtualFile file = FileEditorManagerEx.getInstanceEx(myProject).getFile(editor);
  if (file != null) {
    final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file);
    if (psiFile != null) {
      final SelectInTarget target = mySelectInTarget;
      if (target != null) {
        final SelectInContext selectInContext = SelectInContextImpl.createEditorContext(myProject, editor);

        if (target.canSelect(selectInContext)) {
          target.selectIn(selectInContext, false);
        }
      }
    }
  }
}
 
Example 20
Source Project: consulo   Source File: SelectInContextImpl.java    License: Apache License 2.0 6 votes vote down vote up
public static SelectInContext createEditorContext(Project project, FileEditor editor) {
  if (project == null || editor == null) {
    return null;
  }
  VirtualFile file = FileEditorManagerEx.getInstanceEx(project).getFile(editor);
  if (file == null) {
    return null;
  }
  final PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
  if (psiFile == null) {
    return null;
  }
  if (editor instanceof TextEditor) {
    return new TextEditorContext((TextEditor)editor, psiFile);
  }
  else {
    return new SimpleSelectInContext(psiFile);
  }
}
 
Example 21
Source Project: consulo   Source File: DesktopToolWindowManagerImpl.java    License: Apache License 2.0 6 votes vote down vote up
private EditorsSplitters getSplittersToFocus() {
  WindowManagerEx windowManager = (WindowManagerEx)myWindowManager.get();

  Window activeWindow = TargetAWT.to(windowManager.getMostRecentFocusedWindow());

  if (activeWindow instanceof DesktopFloatingDecorator) {
    IdeFocusManager ideFocusManager = IdeFocusManager.findInstanceByComponent(activeWindow);
    IdeFrame lastFocusedFrame = ideFocusManager.getLastFocusedFrame();
    JComponent frameComponent = lastFocusedFrame != null ? lastFocusedFrame.getComponent() : null;
    Window lastFocusedWindow = frameComponent != null ? SwingUtilities.getWindowAncestor(frameComponent) : null;
    activeWindow = ObjectUtil.notNull(lastFocusedWindow, activeWindow);
  }

  FileEditorManagerEx fem = FileEditorManagerEx.getInstanceEx(myProject);
  EditorsSplitters splitters = activeWindow != null ? fem.getSplittersFor(activeWindow) : null;
  return splitters != null ? splitters : fem.getSplitters();
}
 
Example 22
private boolean representsCurrentFile() {
    final Ref<Boolean> represents = Ref.create(false);
    final FileEditorManagerEx fileEditorManagerEx = FileEditorManagerEx.getInstanceEx(myProject);
    UIUtil.invokeLaterIfNeeded(() -> {
        represents.set(representsFile(fileEditorManagerEx.getCurrentFile()));
    });
    return represents.get();
}
 
Example 23
Source Project: consulo   Source File: CompareFileWithEditorAction.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable
private static VirtualFile getEditingFile(@Nonnull AnActionEvent e) {
  Project project = e.getProject();
  if (project == null) return null;

  return FileEditorManagerEx.getInstanceEx(project).getCurrentFile();
}
 
Example 24
Source Project: consulo   Source File: TestDataProvider.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Object getData(@Nonnull Key<?> dataId) {
  if (myProject.isDisposed()) {
    throw new RuntimeException("TestDataProvider is already disposed for " + myProject + "\n" +
                               "If you closed a project in test, please reset IdeaTestApplication.setDataProvider.");
  }

  if (CommonDataKeys.PROJECT == dataId) {
    return myProject;
  }
  else if (PlatformDataKeys.EDITOR == dataId || OpenFileDescriptor.NAVIGATE_IN_EDITOR == dataId) {
    return FileEditorManager.getInstance(myProject).getSelectedTextEditor();
  }
  else {
    Editor editor = (Editor)getData(PlatformDataKeys.EDITOR);
    if (editor != null) {
      FileEditorManagerEx manager = FileEditorManagerEx.getInstanceEx(myProject);
      Object managerData = manager.getData(dataId, editor, editor.getCaretModel().getCurrentCaret());
      if (managerData != null) {
        return managerData;
      }
      JComponent component = editor.getContentComponent();
      if (component instanceof EditorComponentImpl) {
        return ((EditorComponentImpl)component).getData(dataId);
      }
    }
    return null;
  }
}
 
Example 25
Source Project: consulo   Source File: InfoAndProgressPanel.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
private static Component getAnchor(@Nonnull JRootPane pane) {
  Component tabWrapper = UIUtil.findComponentOfType(pane, TabbedPaneWrapper.TabWrapper.class);
  if (tabWrapper != null) {
    return tabWrapper;
  }
  EditorsSplitters splitters = AWTComponentProviderUtil.findChild(pane, EditorsSplitters.class);
  if (splitters != null) {
    return splitters.isShowing() ? splitters.getComponent() : pane;
  }
  FileEditorManagerEx ex = FileEditorManagerEx.getInstanceEx(ProjectUtil.guessCurrentProject(pane));
  if (ex == null) return pane;
  splitters = ex.getSplitters();
  return splitters.isShowing() ? splitters.getComponent() : pane;
}
 
Example 26
Source Project: consulo   Source File: ToggleReadOnlyAttributePanel.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable
private VirtualFile getCurrentFile() {
  final Project project = getProject();
  if (project == null) return null;
  EditorsSplitters splitters = FileEditorManagerEx.getInstanceEx(project).getSplittersFor(myStatusBar.getComponent());
  return splitters.getCurrentFile();
}
 
Example 27
Source Project: consulo   Source File: DesktopEditorWindow.java    License: Apache License 2.0 5 votes vote down vote up
void trimToSize(final int limit, @Nullable final VirtualFile fileToIgnore, final boolean transferFocus) {
  if (myTabbedPane == null) return;

  FileEditorManagerEx.getInstanceEx(getManager().getProject()).getReady(this).doWhenDone(() -> {
    if (myTabbedPane == null) return;
    final boolean closeNonModifiedFilesFirst = UISettings.getInstance().getCloseNonModifiedFilesFirst();
    final DesktopEditorComposite selectedComposite = getSelectedEditor();
    try {
      doTrimSize(limit, fileToIgnore, closeNonModifiedFilesFirst, transferFocus);
    }
    finally {
      setSelectedEditor(selectedComposite, false);
    }
  });
}
 
Example 28
Source Project: consulo   Source File: FileEditorManagerImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
protected EditorWithProviderComposite createEditorWithProviderComposite(@Nonnull VirtualFile file,
                                                                        @Nonnull FileEditor[] editors,
                                                                        @Nonnull FileEditorProvider[] providers,
                                                                        @Nonnull FileEditorManagerEx fileEditorManager) {
  throw new UnsupportedOperationException();
}
 
Example 29
Source Project: consulo   Source File: IdeDocumentHistoryImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @return currently selected FileEditor or null.
 */
@Nullable
protected FileEditorWithProvider getSelectedEditor() {
  FileEditorManagerEx editorManager = getFileEditorManager();
  VirtualFile file = editorManager.getCurrentFile();
  return file == null ? null : editorManager.getSelectedEditorWithProvider(file);
}
 
Example 30
Source Project: consulo   Source File: IdeDocumentHistoryImpl.java    License: Apache License 2.0 5 votes vote down vote up
protected PlaceInfo createPlaceInfo(@Nonnull final FileEditor fileEditor, final FileEditorProvider fileProvider) {
  if (!fileEditor.isValid()) {
    return null;
  }

  FileEditorManagerEx editorManager = getFileEditorManager();
  final VirtualFile file = editorManager.getFile(fileEditor);
  LOG.assertTrue(file != null);
  FileEditorState state = fileEditor.getState(FileEditorStateLevel.NAVIGATION);

  return new PlaceInfo(file, state, fileProvider.getEditorTypeId(), editorManager.getCurrentWindow(), getCaretPosition(fileEditor), System.currentTimeMillis());
}