/** * 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; }
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); UISettings.getInstance().addUISettingsListener(this, this); }
public PsiAwareFileEditorManagerImpl(final Project project, final PsiManager psiManager, final WolfTheProblemSolver problemSolver, DockManager dockManager, MessageBus messageBus, EditorHistoryManager editorHistoryManager) { super(project, dockManager, editorHistoryManager); myPsiManager = psiManager; myProblemSolver = problemSolver; myPsiTreeChangeListener = new MyPsiTreeChangeListener(); myProblemListener = new MyProblemListener(); registerExtraEditorDataProvider(new TextEditorPsiDataProvider(), null); // reinit syntax highlighter for Groovy. In power save mode keywords are highlighted by GroovySyntaxHighlighter insteadof // GrKeywordAndDeclarationHighlighter. So we need to drop caches for token types attributes in LayeredLexerEditorHighlighter messageBus.connect().subscribe(PowerSaveMode.TOPIC, new PowerSaveMode.Listener() { @Override public void powerSaveStateChanged() { for (Editor editor : EditorFactory.getInstance().getAllEditors()) { ((EditorEx)editor).reinitSettings(); } } }); }
public FileEditorManagerImpl(final Project project, DockManager dockManager) { /* ApplicationManager.getApplication().assertIsDispatchThread(); */ myProject = project; myDockManager = dockManager; myListenerList = new MessageListenerList<FileEditorManagerListener>(myProject.getMessageBus(), FileEditorManagerListener.FILE_EDITOR_MANAGER); if (Extensions.getExtensions(FileEditorAssociateFinder.EP_NAME).length > 0) { myListenerList.add(new FileEditorManagerAdapter() { @Override public void selectionChanged(@NotNull FileEditorManagerEvent event) { EditorsSplitters splitters = getSplitters(); openAssociatedFile(event.getNewFile(), splitters.getCurrentWindow(), splitters); } }); } myQueue.setTrackUiActivity(true); }
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(); }
/** * 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; }
DesktopEditorsSplitters(final FileEditorManagerImpl manager, DockManager dockManager, boolean createOwnDockableContainer) { super(new BorderLayout()); 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); } KeymapManagerListener keymapListener = keymap -> { invalidate(); repaint(); }; KeymapManager.getInstance().addKeymapManagerListener(keymapListener, this); }
public PsiAwareFileEditorManagerImpl(final Project project, final PsiManager psiManager, final WolfTheProblemSolver problemSolver, DockManager dockManager) { super(project, dockManager); myPsiManager = psiManager; myProblemSolver = problemSolver; myPsiTreeChangeListener = new MyPsiTreeChangeListener(); myProblemListener = new MyProblemListener(); registerExtraEditorDataProvider(new TextEditorPsiDataProvider(), null); // reinit syntax highlighter for Groovy. In power save mode keywords are highlighted by GroovySyntaxHighlighter insteadof // GrKeywordAndDeclarationHighlighter. So we need to drop caches for token types attributes in LayeredLexerEditorHighlighter project.getMessageBus().connect().subscribe(PowerSaveMode.TOPIC, new PowerSaveMode.Listener() { @Override public void powerSaveStateChanged() { UIUtil.invokeLaterIfNeeded(() -> { for (Editor editor : EditorFactory.getInstance().getAllEditors()) { ((EditorEx)editor).reinitSettings(); } }); } }); }
@Override public void setUp() throws Exception { super.setUp(); DockManager dockManager = DockManager.getInstance(getProject()); myOldDockContainers = dockManager.getContainers(); myManager = new FileEditorManagerImpl(getProject(), dockManager, EditorHistoryManager.getInstance(getProject())); myOldManager = ((ComponentManagerImpl)getProject()).registerComponentInstance(FileEditorManager.class, myManager); ((FileEditorProviderManagerImpl)FileEditorProviderManager.getInstance()).clearSelectedProviders(); }
@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(); }
public FileEditorManagerImpl(final Project project, DockManager dockManager, EditorHistoryManager editorHistoryManager) { /* ApplicationManager.getApplication().assertIsDispatchThread(); */ myProject = project; myDockManager = dockManager; myEditorHistoryManager = editorHistoryManager; myListenerList = new MessageListenerList<FileEditorManagerListener>(myProject.getMessageBus(), FileEditorManagerListener.FILE_EDITOR_MANAGER); if (Extensions.getExtensions(FileEditorAssociateFinder.EP_NAME).length > 0) { myListenerList.add(new FileEditorManagerAdapter() { @Override public void selectionChanged(@NotNull FileEditorManagerEvent event) { EditorsSplitters splitters = getSplitters(); openAssociatedFile(event.getNewFile(), splitters.getCurrentWindow(), splitters); } }); } myQueue.setTrackUiActivity(true); project.getMessageBus().connect().subscribe(DumbService.DUMB_MODE, new DumbService.DumbModeListener() { public void enteredDumbMode() { } public void exitDumbMode() { // can happen under write action, so postpone to avoid deadlock on FileEditorProviderManager.getProviders() ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { if (!project.isDisposed()) dumbModeFinished(project); } }); } }); }
public FilePreviewPanelProvider(@NotNull Project project, @NotNull FileEditorManagerImpl manager, @NotNull DockManager dockManager) { super(ID); myProject = project; myManager = manager; myEditorsSplitters = new MyEditorsSplitters(manager, dockManager, false); Disposer.register(this, myEditorsSplitters); myEditorsSplitters.createCurrentWindow(); myWindow = myEditorsSplitters.getCurrentWindow(); myWindow.setTabsPlacement(UISettings.TABS_NONE); }
public RunContentManagerImpl(@NotNull Project project, @NotNull DockManager dockManager) { myProject = project; DockableGridContainerFactory containerFactory = new DockableGridContainerFactory(); dockManager.register(DockableGridContainerFactory.TYPE, containerFactory); Disposer.register(myProject, containerFactory); AppUIUtil.invokeOnEdt(new Runnable() { @Override public void run() { init(); } }, myProject.getDisposed()); }
public void testDockableContainer() throws Exception { VirtualFile file = getFile("/foo.txt"); myManager.openFile(file, false); DockManager dockManager = DockManager.getInstance(getProject()); assertEquals(1, dockManager.getContainers().size()); myManager.initDockableContentFactory(); myManager.openFileInNewWindow(file); assertEquals(2, dockManager.getContainers().size()); Element context = new Element("context"); WorkingContextManager contextManager = WorkingContextManager.getInstance(getProject()); contextManager.saveContext(context); assertEquals(2, context.getChild("editors").getChildren().size()); assertEquals(2, EditorFactory.getInstance().getAllEditors().length); contextManager.clearContext(); assertEquals(1, dockManager.getContainers().size()); assertEquals(0, EditorFactory.getInstance().getAllEditors().length); //contextManager.loadContext(context); //assertEquals(2, dockManager.getContainers().size()); //Editor[] editors = EditorFactory.getInstance().getAllEditors(); //assertEquals(2, editors.length); // //contextManager.clearContext(); }
public void setUp() throws Exception { super.setUp(); myManager = new FileEditorManagerImpl(getProject(), DockManager.getInstance(getProject())); ((ComponentManagerImpl)getProject()).registerComponentInstance(FileEditorManager.class, myManager); ((IdeDocumentHistoryImpl)IdeDocumentHistory.getInstance(getProject())).projectOpened(); EditorHistoryManager.getInstance(getProject()).projectOpened(); }
public PsiAwareFileEditorManagerImpl(final Project project, final PsiManager psiManager, final WolfTheProblemSolver problemSolver, DockManager dockManager) { super(project, dockManager); myPsiManager = psiManager; myProblemSolver = problemSolver; myPsiTreeChangeListener = new MyPsiTreeChangeListener(); myProblemListener = new MyProblemListener(); registerExtraEditorDataProvider(new TextEditorPsiDataProvider(), null); }
public RunContentManagerImpl(@Nonnull Project project, @Nonnull DockManager dockManager) { myProject = project; DockableGridContainerFactory containerFactory = new DockableGridContainerFactory(); dockManager.register(DockableGridContainerFactory.TYPE, containerFactory); Disposer.register(myProject, containerFactory); AppUIUtil.invokeOnEdt(() -> init(), myProject.getDisposed()); }
public DockableEditorContainerFactory(Project project, FileEditorManagerImpl fileEditorManager, DockManager dockManager) { this.myProject = project; myFileEditorManager = fileEditorManager; myDockManager = dockManager; }
private DockManager getDockManager() { return DockManager.getInstance(myProject); }
public Pair<FileEditor[], FileEditorProvider[]> openFileInNewWindow(@NotNull VirtualFile file) { return ((DockManagerImpl)DockManager.getInstance(getProject())).createNewDockContainerFor(file, this); }
private MyEditorsSplitters(final FileEditorManagerImpl manager, DockManager dockManager, boolean createOwnDockableContainer) { super(manager, dockManager, createOwnDockableContainer); }
public void setUp() throws Exception { super.setUp(); myManager = new FileEditorManagerImpl(getProject(), DockManager.getInstance(getProject()), EditorHistoryManager.getInstance(getProject())); ((ComponentManagerImpl)getProject()).registerComponentInstance(FileEditorManager.class, myManager); }
private DockManagerImpl getDockManager() { return (DockManagerImpl)DockManager.getInstance(myProject); }
@Override protected String getDimensionServiceKey() { return DockManager.getInstance(myProject).getDimensionKeyForFocus("#com.intellij.ide.util.FileStructureDialog"); }
public OpenEditorsContextProvider(FileEditorManager fileEditorManager, DockManager dockManager) { myDockManager = (DockManagerImpl)dockManager; myFileEditorManager = fileEditorManager instanceof FileEditorManagerImpl ? (FileEditorManagerImpl)fileEditorManager : null; }
public void initTerminal(final ToolWindow toolWindow) { LocalTerminalDirectRunner terminalRunner = LocalTerminalDirectRunner.createTerminalRunner(myProject); toolWindow.setToHideOnEmptyContent(true); if (terminalRunner != null) { Content content = createTerminalInContentPanel(terminalRunner, toolWindow); toolWindow.getContentManager().addContent(content); ((ToolWindowManagerEx)ToolWindowManager.getInstance(myProject)).addToolWindowManagerListener(new ToolWindowManagerListener() { @Override public void toolWindowRegistered(@NotNull String id) { } @Override public void stateChanged() { ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(TerminalToolWindowFactory.TOOL_WINDOW_ID); if (window != null) { boolean visible = window.isVisible(); if (visible && toolWindow.getContentManager().getContentCount() == 0) { initTerminal(window); } } } }); Disposer.register(myProject, new Disposable() { @Override public void dispose() { if (myTerminalWidget != null) { myTerminalWidget.dispose(); myTerminalWidget = null; } } }); } if (myDockContainer == null) { myDockContainer = new TerminalDockContainer(toolWindow); Disposer.register(myProject, myDockContainer); DockManager.getInstance(myProject).register(myDockContainer); } }
public Pair<FileEditor[], FileEditorProvider[]> openFileInNewWindow(VirtualFile file) { return ((DockManagerImpl)DockManager.getInstance(getProject())).createNewDockContainerFor(file, this); }
public void setUp() throws Exception { super.setUp(); myManager = new FileEditorManagerImpl(getProject(), DockManager.getInstance(getProject())); myOldManager = ((ComponentManagerImpl)getProject()).registerComponentInstance(FileEditorManager.class, myManager); }
public RunContentManagerImpl(Project project, DockManager dockManager) { myProject = project; myContentFactory = new DockableGridContainerFactory(); dockManager.register(DockableGridContainerFactory.TYPE, myContentFactory); Disposer.register(myProject, myContentFactory); }
public void initTerminal(final ToolWindow toolWindow) { LocalTerminalDirectRunner terminalRunner = OpenLocalTerminalAction.createTerminalRunner(myProject); toolWindow.setToHideOnEmptyContent(true); if(terminalRunner != null) { Content content = createTerminalInContentPanel(terminalRunner, toolWindow); toolWindow.getContentManager().addContent(content); ((ToolWindowManagerEx) ToolWindowManager.getInstance(myProject)).addToolWindowManagerListener(new ToolWindowManagerListener() { @Override public void toolWindowRegistered(@NotNull String id) { } @Override public void stateChanged() { ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow (TerminalToolWindowFactory.TOOL_WINDOW_ID); if(window != null) { boolean visible = window.isVisible(); if(visible && toolWindow.getContentManager().getContentCount() == 0) { initTerminal(window); } } } }); Disposer.register(myProject, new Disposable() { @Override public void dispose() { if(myTerminalWidget != null) { myTerminalWidget.dispose(); myTerminalWidget = null; } } }); } if(myDockContainer == null) { myDockContainer = new TerminalDockContainer(toolWindow); Disposer.register(myProject, myDockContainer); DockManager.getInstance(myProject).register(myDockContainer); } }
public OpenEditorsContextProvider(FileEditorManager fileEditorManager, DockManager dockManager) { myDockManager = (DockManagerImpl) dockManager; myFileEditorManager = fileEditorManager instanceof FileEditorManagerImpl ? (FileEditorManagerImpl) fileEditorManager : null; }