mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-120224 Add possibility to customize ConsoleView popup actions
This commit is contained in:
+10
-3
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user