/*
 * Copyright 2000-2009 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.intellij.ide.actions;

import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ShadowAction;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowManager;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;

public class ShowContentAction extends AnAction {
  private ToolWindow myWindow;

  public ShowContentAction() {
  }

  public ShowContentAction(ToolWindow window, JComponent c) {
    myWindow = window;
    AnAction original = ActionManager.getInstance().getAction("ShowContent");
    new ShadowAction(this, original, c);
    copyFrom(original);
  }

  @Override
  public void update(AnActionEvent e) {
    e.getPresentation().setEnabled(getWindow(e) != null);
  }

  @Override
  public void actionPerformed(AnActionEvent e) {
    getWindow(e).showContentPopup(e.getInputEvent());
  }

  @Nullable
  private ToolWindow getWindow(AnActionEvent event) {
    if (myWindow != null) return myWindow;

    Project project = (Project)event.getDataContext().getData(DataConstants.PROJECT);
    if (project == null) return null;

    ToolWindowManager manager = ToolWindowManager.getInstance(project);

    return manager.getToolWindow(manager.getActiveToolWindowId());
  }
}

@@ -833,28 +833,31 @@
 nSystem.
-DataConstant
+PlatformDataKey
 s;%0Aimpor
@@ -1099,16 +1099,35 @@
 swing.*;
+%0Aimport java.awt.*;
 %0A%0Apublic
@@ -1842,69 +1842,63 @@
 t = 
-(Project)event.getDataContext().getData(DataConstants.PROJECT
+PlatformDataKeys.PROJECT.getData(event.getDataContext()
 );%0A 
@@ -2011,19 +2011,37 @@
 t);%0A
-%0A
     
-return
+final ToolWindow window =
  man
@@ -2088,19 +2088,230 @@
 WindowId());
+%0A%0A    final Component context = PlatformDataKeys.CONTEXT_COMPONENT.getData(event.getDataContext());%0A%0A    return context == null %7C%7C SwingUtilities.isDescendingFrom(window.getComponent(), context) ? window : null;
 %0A  %7D%0A%7D%0A

Fix conflict of ShowContentAction and TabSwitcher. Ctrl+Down with tabSwitcher shown must move selection to next line instead of showing content.