IDEA-120224 Add possibility to customize ConsoleView popup actions

This commit is contained in:
Eugene Kudelevsky
2014-02-03 15:14:25 +04:00
parent 9eae97504c
commit c103300759
2 changed files with 25 additions and 4 deletions
@@ -26,9 +26,9 @@ import org.jetbrains.annotations.NotNull;
* @author Denis Zhdanov
* @since 4/25/11 1:16 PM
*/
public interface ConsoleActionsPostProcessor {
public abstract class ConsoleActionsPostProcessor {
ExtensionPointName<ConsoleActionsPostProcessor> EP_NAME = ExtensionPointName.create("com.intellij.consoleActionsPostProcessor");
public static final ExtensionPointName<ConsoleActionsPostProcessor> EP_NAME = ExtensionPointName.create("com.intellij.consoleActionsPostProcessor");
/**
* Allows to adjust actions to use within the given console instance.
@@ -40,5 +40,12 @@ public interface ConsoleActionsPostProcessor {
* @return actions to use within the given console instance (given actions may be returned by default)
*/
@NotNull
AnAction[] postProcess(@NotNull ConsoleView console, @NotNull AnAction[] actions);
public AnAction[] postProcess(@NotNull ConsoleView console, @NotNull AnAction[] actions) {
return actions;
}
@NotNull
public AnAction[] postProcessPopupActions(@NotNull ConsoleView console, @NotNull AnAction[] actions) {
return actions;
}
}
@@ -922,7 +922,21 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
if (group == null) {
group = (ActionGroup)actionManager.getAction(CONSOLE_VIEW_POPUP_MENU);
}
final ActionPopupMenu menu = actionManager.createActionPopupMenu(ActionPlaces.EDITOR_POPUP, group);
final ConsoleActionsPostProcessor[] postProcessors = Extensions.getExtensions(ConsoleActionsPostProcessor.EP_NAME);
AnAction[] result = group.getChildren(null);
for (ConsoleActionsPostProcessor postProcessor : postProcessors) {
result = postProcessor.postProcessPopupActions(this, result);
}
final AnAction[] processedActions = result;
final ActionGroup processedGroup = new ActionGroup() {
@NotNull
@Override
public AnAction[] getChildren(@Nullable AnActionEvent e) {
return processedActions;
}
};
final ActionPopupMenu menu = actionManager.createActionPopupMenu(ActionPlaces.EDITOR_POPUP, processedGroup);
menu.getComponent().show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
}