mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-123918: add ability to disable processing via our action subsystem
This commit is contained in:
@@ -3,6 +3,7 @@ package com.intellij.ui;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.Action;
|
||||
@@ -17,6 +18,7 @@ import static com.intellij.util.ui.UIUtil.getParentOfType;
|
||||
* @author Sergey.Malenkov
|
||||
*/
|
||||
public class SwingActionDelegate extends AnAction implements DumbAware {
|
||||
private static final Object DISABLED = new Object();
|
||||
private final String mySwingActionId;
|
||||
|
||||
protected SwingActionDelegate(String actionId) {
|
||||
@@ -42,7 +44,13 @@ public class SwingActionDelegate extends AnAction implements DumbAware {
|
||||
|
||||
private Action getSwingAction(JComponent component) {
|
||||
if (component == null) return null;
|
||||
if (Boolean.TRUE.equals(component.getClientProperty(DISABLED))) return null;
|
||||
ActionMap map = component.getActionMap();
|
||||
return map == null ? null : map.get(mySwingActionId);
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public static void disableFor(@NotNull JComponent component) {
|
||||
component.putClientProperty(DISABLED, true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user