Java 类com.intellij.ui.docking.DockManager 实例源码

项目:intellij-ce-playground    文件:StatusBarUtil.java   
/**
 * 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;
}
项目:intellij-ce-playground    文件:EditorsSplitters.java   
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);
}
项目:intellij-ce-playground    文件:PsiAwareFileEditorManagerImpl.java   
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();
      }
    }
  });
}
项目:tools-idea    文件:StatusBarUtil.java   
/**
 * 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;
}
项目:tools-idea    文件:FileEditorManagerImpl.java   
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);
  }
项目:tools-idea    文件:EditorsSplitters.java   
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();
}
项目:consulo    文件:StatusBarUtil.java   
/**
 * 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;
}
项目:consulo    文件:DesktopEditorsSplitters.java   
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);
}
项目:consulo    文件:PsiAwareFileEditorManagerImpl.java   
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();
        }
      });
    }
  });
}
项目:intellij-ce-playground    文件:FileEditorManagerTestCase.java   
@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();
}
项目:intellij-ce-playground    文件:FileEditorManagerTestCase.java   
@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();
}
项目:intellij-ce-playground    文件:FileEditorManagerImpl.java   
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);
          }
        });
      }
    });
  }
项目:intellij-ce-playground    文件:FilePreviewPanelProvider.java   
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);
}
项目:intellij-ce-playground    文件:RunContentManagerImpl.java   
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());
}
项目:intellij-ce-playground    文件:EditorsContextTest.java   
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();
  }
项目:tools-idea    文件:HeavyFileEditorManagerTestCase.java   
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();
}
项目:tools-idea    文件:PsiAwareFileEditorManagerImpl.java   
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);
}
项目:consulo    文件:HeavyFileEditorManagerTestCase.java   
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();
}
项目:consulo    文件:RunContentManagerImpl.java   
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());
}
项目:intellij-ce-playground    文件:DockableEditorContainerFactory.java   
public DockableEditorContainerFactory(Project project, FileEditorManagerImpl fileEditorManager, DockManager dockManager) {
  this.myProject = project;
  myFileEditorManager = fileEditorManager;
  myDockManager = dockManager;
}
项目:intellij-ce-playground    文件:EditorTabbedContainer.java   
private DockManager getDockManager() {
  return DockManager.getInstance(myProject);
}
项目:intellij-ce-playground    文件:FileEditorManagerImpl.java   
public Pair<FileEditor[], FileEditorProvider[]> openFileInNewWindow(@NotNull VirtualFile file) {
  return ((DockManagerImpl)DockManager.getInstance(getProject())).createNewDockContainerFor(file, this);
}
项目:intellij-ce-playground    文件:FilePreviewPanelProvider.java   
private MyEditorsSplitters(final FileEditorManagerImpl manager, DockManager dockManager, boolean createOwnDockableContainer) {
  super(manager, dockManager, createOwnDockableContainer);
}
项目:intellij-ce-playground    文件:HeavyFileEditorManagerTestCase.java   
public void setUp() throws Exception {
  super.setUp();
  myManager = new FileEditorManagerImpl(getProject(), DockManager.getInstance(getProject()), EditorHistoryManager.getInstance(getProject()));
  ((ComponentManagerImpl)getProject()).registerComponentInstance(FileEditorManager.class, myManager);
}
项目:intellij-ce-playground    文件:RunnerContentUi.java   
private DockManagerImpl getDockManager() {
  return (DockManagerImpl)DockManager.getInstance(myProject);
}
项目:intellij-ce-playground    文件:FileStructureDialog.java   
@Override
protected String getDimensionServiceKey() {
  return DockManager.getInstance(myProject).getDimensionKeyForFocus("#com.intellij.ide.util.FileStructureDialog");
}
项目:intellij-ce-playground    文件:OpenEditorsContextProvider.java   
public OpenEditorsContextProvider(FileEditorManager fileEditorManager, DockManager dockManager) {
  myDockManager = (DockManagerImpl)dockManager;
  myFileEditorManager = fileEditorManager instanceof FileEditorManagerImpl ? (FileEditorManagerImpl)fileEditorManager : null;
}
项目:intellij-ce-playground    文件:TerminalView.java   
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);
  }
}
项目:intellij-ce-playground    文件:JBTabbedTerminalWidget.java   
private DockManager getDockManager() {
  return DockManager.getInstance(myProject);
}
项目:tools-idea    文件:DockableEditorContainerFactory.java   
public DockableEditorContainerFactory(Project project, FileEditorManagerImpl fileEditorManager, DockManager dockManager) {
  this.myProject = project;
  myFileEditorManager = fileEditorManager;
  myDockManager = dockManager;
}
项目:tools-idea    文件:EditorTabbedContainer.java   
private DockManager getDockManager() {
  return DockManager.getInstance(myProject);
}
项目:tools-idea    文件:FileEditorManagerImpl.java   
public Pair<FileEditor[], FileEditorProvider[]> openFileInNewWindow(VirtualFile file) {
  return ((DockManagerImpl)DockManager.getInstance(getProject())).createNewDockContainerFor(file, this);
}
项目:tools-idea    文件:FileEditorManagerTestCase.java   
public void setUp() throws Exception {
  super.setUp();
  myManager = new FileEditorManagerImpl(getProject(), DockManager.getInstance(getProject()));
  myOldManager = ((ComponentManagerImpl)getProject()).registerComponentInstance(FileEditorManager.class, myManager);
}
项目:tools-idea    文件:RunContentManagerImpl.java   
public RunContentManagerImpl(Project project, DockManager dockManager) {
  myProject = project;
  myContentFactory = new DockableGridContainerFactory();
  dockManager.register(DockableGridContainerFactory.TYPE, myContentFactory);
  Disposer.register(myProject, myContentFactory);
}
项目:tools-idea    文件:RunnerContentUi.java   
private DockManagerImpl getDockManager() {
  return (DockManagerImpl)DockManager.getInstance(myProject);
}
项目:tools-idea    文件:FileStructureDialog.java   
@Override
protected String getDimensionServiceKey() {
  return DockManager.getInstance(myProject).getDimensionKeyForFocus("#com.intellij.ide.util.FileStructureDialog");
}
项目:consulo-terminal    文件:TerminalView.java   
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);
    }
}
项目:consulo-terminal    文件:JBTabbedTerminalWidget.java   
private DockManager getDockManager()
{
    return DockManager.getInstance(myProject);
}
项目:consulo-tasks    文件:OpenEditorsContextProvider.java   
public OpenEditorsContextProvider(FileEditorManager fileEditorManager, DockManager dockManager)
{
    myDockManager = (DockManagerImpl) dockManager;
    myFileEditorManager = fileEditorManager instanceof FileEditorManagerImpl ? (FileEditorManagerImpl) fileEditorManager : null;
}
项目:consulo    文件:FileEditorManagerTestCase.java   
public void setUp() throws Exception {
  super.setUp();
  myManager = new FileEditorManagerImpl(getProject(), DockManager.getInstance(getProject()));
  myOldManager = ((ComponentManagerImpl)getProject()).registerComponentInstance(FileEditorManager.class, myManager);
}