"expand all" action in hierarchy toolbar (IDEA-79848)

This commit is contained in:
Dmitry Jemerov
2012-02-02 19:58:26 +01:00
parent 6d89720ea0
commit a386146bb0
3 changed files with 15 additions and 4 deletions
@@ -16,6 +16,7 @@
package com.intellij.ide.hierarchy;
import com.intellij.ide.DefaultTreeExpander;
import com.intellij.ide.actions.CloseTabToolbarAction;
import com.intellij.ide.actions.ContextHelpAction;
import com.intellij.ide.util.treeView.AbstractTreeUi;
@@ -27,7 +28,7 @@ import com.intellij.openapi.ui.SimpleToolWindowPanel;
import com.intellij.pom.Navigatable;
import com.intellij.psi.NavigatablePsiElement;
import com.intellij.psi.PsiElement;
import com.intellij.psi.util.PsiUtilBase;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.ui.AutoScrollToSourceHandler;
import com.intellij.ui.TreeSpeedSearch;
import com.intellij.ui.content.Content;
@@ -92,6 +93,7 @@ public abstract class HierarchyBrowserBase extends SimpleToolWindowPanel impleme
protected void appendActions(@NotNull DefaultActionGroup actionGroup, @Nullable String helpID) {
actionGroup.add(myAutoScrollToSourceHandler.createToggleAction());
actionGroup.add(ActionManager.getInstance().getAction(IdeActions.ACTION_EXPAND_ALL));
actionGroup.add(PinToolwindowTabAction.getPinAction());
actionGroup.add(new CloseAction());
if (helpID != null) {
@@ -162,7 +164,7 @@ public abstract class HierarchyBrowserBase extends SimpleToolWindowPanel impleme
PsiElement element = getElementFromDescriptor(descriptor);
if (element != null) elements.add(element);
}
return PsiUtilBase.toPsiElementArray(elements);
return PsiUtilCore.toPsiElementArray(elements);
}
@@ -193,7 +195,7 @@ public abstract class HierarchyBrowserBase extends SimpleToolWindowPanel impleme
@Nullable
public Object getData(@NonNls final String dataId) {
if (LangDataKeys.PSI_ELEMENT.is(dataId)) {
if (LangDataKeys.PSI_ELEMENT.is(dataId)) {
final PsiElement anElement = getSelectedElement();
return anElement != null && anElement.isValid() ? anElement : super.getData(dataId);
}
@@ -213,6 +215,12 @@ public abstract class HierarchyBrowserBase extends SimpleToolWindowPanel impleme
if (PlatformDataKeys.NAVIGATABLE_ARRAY.is(dataId)) {
return getNavigatables();
}
if (PlatformDataKeys.TREE_EXPANDER.is(dataId)) {
final JTree tree = getCurrentTree();
if (tree != null) {
return new DefaultTreeExpander(tree);
}
}
return super.getData(dataId);
}
@@ -17,6 +17,7 @@
package com.intellij.ide;
import com.intellij.util.ui.tree.TreeUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -26,7 +27,7 @@ import javax.swing.*;
public class DefaultTreeExpander implements TreeExpander {
private final JTree myTree;
public DefaultTreeExpander(final JTree tree) {
public DefaultTreeExpander(@NotNull final JTree tree) {
myTree = tree;
}
@@ -21,11 +21,13 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.project.DumbAware;
import org.jetbrains.annotations.Nullable;
/**
* @author max
*/
public abstract class TreeExpandAllActionBase extends AnAction implements DumbAware {
@Nullable
protected abstract TreeExpander getExpander(DataContext dataContext);
public final void actionPerformed(AnActionEvent e) {