/** * Finds the current file editor. */ @Nullable public static FileEditor getCurrentFileEditor(@NotNull Project project, @Nullable StatusBar statusBar) { if (statusBar == null) { return null; } DockContainer c = DockManager.getInstance(project).getContainerFor(statusBar.getComponent()); EditorsSplitters splitters = null; if (c instanceof DockableEditorTabbedContainer) { splitters = ((DockableEditorTabbedContainer)c).getSplitters(); } if (splitters != null && splitters.getCurrentWindow() != null) { EditorWithProviderComposite editor = splitters.getCurrentWindow().getSelectedEditor(); if (editor != null) { return editor.getSelectedEditorWithProvider().getFirst(); } } return null; }
@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; }
@Override public void clearContext() { if(myFileEditorManager != null) { myFileEditorManager.closeAllFiles(); myFileEditorManager.getMainSplitters().clear(); } for(DockContainer container : myDockManager.getContainers()) { if(container instanceof DockableEditorTabbedContainer) { container.closeAll(); } } }
/** * Finds the current file editor. */ @Nullable public static FileEditor getCurrentFileEditor(@Nonnull Project project, @Nullable StatusBar statusBar) { if (statusBar == null) { return null; } DockContainer c = DockManager.getInstance(project).getContainerFor(statusBar.getComponent()); DesktopEditorsSplitters splitters = null; if (c instanceof DockableEditorTabbedContainer) { splitters = ((DockableEditorTabbedContainer)c).getSplitters(); } if (splitters != null && splitters.getCurrentWindow() != null) { EditorWithProviderComposite editor = splitters.getCurrentWindow().getSelectedEditor(); if (editor != null) { return editor.getSelectedEditorWithProvider().getFirst(); } } return null; }
@Nonnull private AsyncResult<EditorSplitters> getActiveSplittersAsync() { final AsyncResult<EditorSplitters> result = new AsyncResult<>(); final IdeFocusManager fm = IdeFocusManager.getInstance(myProject); fm.doWhenFocusSettlesDown(() -> { if (myProject.isDisposed()) { result.setRejected(); return; } Component focusOwner = fm.getFocusOwner(); DockContainer container = myDockManager.getContainerFor(focusOwner); if (container instanceof DockableEditorTabbedContainer) { result.setDone(((DockableEditorTabbedContainer)container).getSplitters()); } else { result.setDone(getMainSplitters()); } }); return result; }
private EditorSplitters getActiveSplittersSync() { assertDispatchThread(); final IdeFocusManager fm = IdeFocusManager.getInstance(myProject); Component focusOwner = fm.getFocusOwner(); if (focusOwner == null) { focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); } if (focusOwner == null) { focusOwner = fm.getLastFocusedFor(fm.getLastFocusedFrame()); } DockContainer container = myDockManager.getContainerFor(focusOwner); if (container == null) { focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow(); container = myDockManager.getContainerFor(focusOwner); } if (container instanceof DockableEditorTabbedContainer) { return ((DockableEditorTabbedContainer)container).getSplitters(); } return getMainSplitters(); }
@Override protected void tearDown() throws Exception { for (DockContainer container : DockManager.getInstance(getProject()).getContainers()) { if (!myOldDockContainers.contains(container)) { Disposer.dispose(container); } } myOldDockContainers = null; ((ComponentManagerImpl)getProject()).registerComponentInstance(FileEditorManager.class, myOldManager); myManager.closeAllFiles(); ((FileEditorProviderManagerImpl)FileEditorProviderManager.getInstance()).clearSelectedProviders(); super.tearDown(); }
@NotNull public Set<EditorsSplitters> getAllSplitters() { Set<EditorsSplitters> all = new LinkedHashSet<EditorsSplitters>(); all.add(getMainSplitters()); Set<DockContainer> dockContainers = myDockManager.getContainers(); for (DockContainer each : dockContainers) { if (each instanceof DockableEditorTabbedContainer) { all.add(((DockableEditorTabbedContainer)each).getSplitters()); } } return Collections.unmodifiableSet(all); }
@Override public EditorsSplitters getSplittersFor(Component c) { EditorsSplitters splitters = null; DockContainer dockContainer = myDockManager.getContainerFor(c); if (dockContainer instanceof DockableEditorTabbedContainer) { splitters = ((DockableEditorTabbedContainer)dockContainer).getSplitters(); } if (splitters == null) { splitters = getMainSplitters(); } return splitters; }
public void clearContext() { if (myFileEditorManager != null) { myFileEditorManager.closeAllFiles(); myFileEditorManager.getMainSplitters().clear(); } for (DockContainer container : myDockManager.getContainers()) { if (container instanceof DockableEditorTabbedContainer) { container.closeAll(); } } }
public Set<EditorsSplitters> getAllSplitters() { HashSet<EditorsSplitters> all = new HashSet<EditorsSplitters>(); all.add(getMainSplitters()); Set<DockContainer> dockContainers = myDockManager.getContainers(); for (DockContainer each : dockContainers) { if (each instanceof DockableEditorTabbedContainer) { all.add(((DockableEditorTabbedContainer)each).getSplitters()); } } return Collections.unmodifiableSet(all); }
public EditorsSplitters getSplittersFor(Component c) { EditorsSplitters splitters = null; DockContainer dockContainer = myDockManager.getContainerFor(c); if (dockContainer instanceof DockableEditorTabbedContainer) { splitters = ((DockableEditorTabbedContainer)dockContainer).getSplitters(); } if (splitters == null) { splitters = getMainSplitters(); } return splitters; }
@Nonnull public Set<EditorSplitters> getAllSplitters() { Set<EditorSplitters> all = new LinkedHashSet<>(); all.add(getMainSplitters()); Set<DockContainer> dockContainers = myDockManager.getContainers(); for (DockContainer each : dockContainers) { if (each instanceof DockableEditorTabbedContainer) { all.add(((DockableEditorTabbedContainer)each).getSplitters()); } } return Collections.unmodifiableSet(all); }
@Override public EditorSplitters getSplittersFor(Component c) { EditorSplitters splitters = null; DockContainer dockContainer = myDockManager.getContainerFor(c); if (dockContainer instanceof DockableEditorTabbedContainer) { splitters = ((DockableEditorTabbedContainer)dockContainer).getSplitters(); } if (splitters == null) { splitters = getMainSplitters(); } return splitters; }
@Override public DockContainer createContainer(DockableContent content) { return createContainer(false); }
@Override public DockContainer loadContainerFrom(Element element) { DockableEditorTabbedContainer container = (DockableEditorTabbedContainer)createContainer(true); container.getSplitters().readExternal(element.getChild("state")); return container; }
@NotNull private AsyncResult<EditorsSplitters> getActiveSplitters(boolean syncUsage) { final boolean async = Registry.is("ide.windowSystem.asyncSplitters") && !syncUsage; final AsyncResult<EditorsSplitters> result = new AsyncResult<EditorsSplitters>(); final IdeFocusManager fm = IdeFocusManager.getInstance(myProject); Runnable run = new Runnable() { @Override public void run() { if (myProject.isDisposed()) { result.setRejected(); return; } Component focusOwner = fm.getFocusOwner(); if (focusOwner == null && !async) { focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); } if (focusOwner == null && !async) { focusOwner = fm.getLastFocusedFor(fm.getLastFocusedFrame()); } DockContainer container = myDockManager.getContainerFor(focusOwner); if (container == null && !async) { focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow(); container = myDockManager.getContainerFor(focusOwner); } if (container instanceof DockableEditorTabbedContainer) { result.setDone(((DockableEditorTabbedContainer)container).getSplitters()); } else { result.setDone(getMainSplitters()); } } }; if (async) { fm.doWhenFocusSettlesDown(run); } else { UIUtil.invokeLaterIfNeeded(run); } return result; }
@Override public DockContainer createContainer(DockableContent content) { final RunnerContentUi.DockableGrid dockableGrid = (RunnerContentUi.DockableGrid)content; return new RunnerContentUi(dockableGrid.getRunnerUi(), dockableGrid.getOriginalRunnerUi(), dockableGrid.getWindow()); }
private AsyncResult<EditorsSplitters> getActiveSplitters(boolean syncUsage) { final boolean async = Registry.is("ide.windowSystem.asyncSplitters") && !syncUsage; final AsyncResult<EditorsSplitters> result = new AsyncResult<EditorsSplitters>(); final IdeFocusManager fm = IdeFocusManager.getInstance(myProject); Runnable run = new Runnable() { @Override public void run() { if (myProject.isDisposed()) { result.setRejected(); return; } Component focusOwner = fm.getFocusOwner(); if (focusOwner == null && !async) { focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); } if (focusOwner == null && !async) { focusOwner = fm.getLastFocusedFor(fm.getLastFocusedFrame()); } DockContainer container = myDockManager.getContainerFor(focusOwner); if (container == null && !async) { focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow(); container = myDockManager.getContainerFor(focusOwner); } if (container instanceof DockableEditorTabbedContainer) { result.setDone(((DockableEditorTabbedContainer)container).getSplitters()); } else { result.setDone(getMainSplitters()); } } }; if (async) { fm.doWhenFocusSettlesDown(run); } else { run.run(); } return result; }