Example usage for com.intellij.openapi.actionSystem PlatformDataKeys NONEMPTY_CONTENT_MANAGER

List of usage examples for com.intellij.openapi.actionSystem PlatformDataKeys NONEMPTY_CONTENT_MANAGER

Introduction

In this page you can find the example usage for com.intellij.openapi.actionSystem PlatformDataKeys NONEMPTY_CONTENT_MANAGER.

Prototype

DataKey NONEMPTY_CONTENT_MANAGER

To view the source code for com.intellij.openapi.actionSystem PlatformDataKeys NONEMPTY_CONTENT_MANAGER.

Click Source Link

Usage

From source file:com.intellij.ide.actions.TabNavigationActionBase.java

License:Apache License

public void actionPerformed(AnActionEvent e) {
    DataContext dataContext = e.getDataContext();
    Project project = CommonDataKeys.PROJECT.getData(dataContext);
    if (project == null) {
        return;/*from   w  ww  .ja  v a 2  s.co m*/
    }

    ToolWindowManager windowManager = ToolWindowManager.getInstance(project);

    if (windowManager.isEditorComponentActive()) {
        doNavigate(dataContext, project);
        return;
    }

    ContentManager contentManager = PlatformDataKeys.NONEMPTY_CONTENT_MANAGER.getData(dataContext);
    if (contentManager == null)
        return;
    doNavigate(contentManager);
}

From source file:com.intellij.ide.actions.TabNavigationActionBase.java

License:Apache License

public void update(AnActionEvent event) {
    Presentation presentation = event.getPresentation();
    DataContext dataContext = event.getDataContext();
    Project project = CommonDataKeys.PROJECT.getData(dataContext);
    presentation.setEnabled(false);//from   ww  w . jav a2 s  .  c  om
    if (project == null) {
        return;
    }
    final ToolWindowManager windowManager = ToolWindowManager.getInstance(project);
    if (windowManager.isEditorComponentActive()) {
        final FileEditorManagerEx editorManager = FileEditorManagerEx.getInstanceEx(project);
        EditorWindow currentWindow = EditorWindow.DATA_KEY.getData(dataContext);
        if (currentWindow == null) {
            editorManager.getCurrentWindow();
        }
        if (currentWindow != null) {
            final VirtualFile[] files = currentWindow.getFiles();
            presentation.setEnabled(files.length > 1);
        }
        return;
    }

    ContentManager contentManager = PlatformDataKeys.NONEMPTY_CONTENT_MANAGER.getData(dataContext);
    presentation.setEnabled(contentManager != null && contentManager.getContentCount() > 1
            && contentManager.isSingleSelection());
}