/** * sets the window passed as a current ('focused') window among all splitters. All file openings * will be done inside this current window * * @param window a window to be set as current * @param requestFocus whether to request focus to the editor currently selected in this window */ public void setCurrentWindow(@Nullable final EditorWindow window, final boolean requestFocus) { final EditorWithProviderComposite newEditor = window != null ? window.getSelectedEditor() : null; Runnable fireRunnable = new Runnable() { public void run() { getManager().fireSelectionChanged(newEditor); } }; setCurrentWindow(window); getManager().updateFileName(window == null ? null : window.getSelectedFile()); if (window != null) { final EditorWithProviderComposite selectedEditor = window.getSelectedEditor(); if (selectedEditor != null) { fireRunnable.run(); } if (requestFocus) { window.requestFocus(true); } } else { fireRunnable.run(); } }
private void writeWindow(@NotNull Element res, @Nullable EditorWindow window) { if (window != null) { EditorWithProviderComposite[] composites = window.getEditors(); for (int i = 0; i < composites.length; i++) { VirtualFile file = window.getFileAt(i); res.addContent( writeComposite( file, composites[i], window.isFilePinned(file), window.getSelectedEditor())); } } }
@NotNull public FileEditor[] getSelectedEditors() { final List<FileEditor> editors = new ArrayList<FileEditor>(); final EditorWindow currentWindow = getCurrentWindow(); if (currentWindow != null) { final EditorWithProviderComposite composite = currentWindow.getSelectedEditor(); if (composite != null) { editors.add(composite.getSelectedEditor()); } } for (final EditorWindow window : myWindows) { if (!window.equals(currentWindow)) { final EditorWithProviderComposite composite = window.getSelectedEditor(); if (composite != null) { editors.add(composite.getSelectedEditor()); } } } return editors.toArray(new FileEditor[editors.size()]); }
private void writeWindow(final Element res, final EditorWindow window) { if (window != null) { final EditorWithProviderComposite[] composites = window.getEditors(); for (int i = 0; i < composites.length; i++) { final VirtualFile file = window.getFileAt(i); final boolean isPinned = window.isFilePinned(file); final EditorWithProviderComposite composite = composites[i]; final EditorWithProviderComposite selectedEditor = window.getSelectedEditor(); writeComposite(res, file, composite, isPinned, selectedEditor); } } }
@NotNull public FileEditor[] getSelectedEditors() { List<FileEditor> editors = new ArrayList<FileEditor>(); Set<EditorWindow> windows = new THashSet<EditorWindow>(myWindows); final EditorWindow currentWindow = getCurrentWindow(); if (currentWindow != null) { windows.add(currentWindow); } for (final EditorWindow window : windows) { final EditorWithProviderComposite composite = window.getSelectedEditor(); if (composite != null) { editors.add(composite.getSelectedEditor()); } } return editors.toArray(new FileEditor[editors.size()]); }
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); } } } }