use of com.intellij.openapi.actionSystem.AnAction in project intellij-community by JetBrains.
the class ChameleonAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
AnAction action = getAction(e);
assert action != null;
action.actionPerformed(e);
}
use of com.intellij.openapi.actionSystem.AnAction in project intellij-community by JetBrains.
the class MacGestureAdapter method swipedRight.
@Override
public void swipedRight(SwipeEvent event) {
ActionManager actionManager = ActionManager.getInstance();
AnAction back = actionManager.getAction("Back");
if (back == null)
return;
actionManager.tryToExecute(back, createMouseEventWrapper(myFrame), null, null, false);
}
use of com.intellij.openapi.actionSystem.AnAction in project intellij-community by JetBrains.
the class KeymapsTestCase method testValidActionIds.
public void testValidActionIds() {
THashSet<String> unknownActions = new THashSet<>();
collectUnknownActions(unknownActions);
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection") Map<String, List<String>> missingActions = new FactoryMap<String, List<String>>() {
@Override
protected Map<String, List<String>> createMap() {
return new LinkedHashMap<>();
}
@Nullable
@Override
protected List<String> create(String key) {
return new ArrayList<>();
}
};
for (Keymap keymap : KeymapManagerEx.getInstanceEx().getAllKeymaps()) {
List<String> ids = new ArrayList<>(keymap.getActionIdList());
ids.sort(null);
assertThat(ids).isEqualTo(new ArrayList<>(new LinkedHashSet<>(ids)));
for (String cid : ids) {
if (unknownActions.contains(cid))
continue;
AnAction action = ActionManager.getInstance().getAction(cid);
if (action == null) {
if (OUTPUT_TEST_DATA) {
System.out.print("\"" + cid + "\", ");
} else {
missingActions.get(keymap.getName()).add(cid);
}
}
}
}
List<String> reappearedAction = new ArrayList<>();
for (String id : unknownActions) {
AnAction action = ActionManager.getInstance().getAction(id);
if (action != null) {
reappearedAction.add(id);
}
}
if (!missingActions.isEmpty() || !reappearedAction.isEmpty()) {
StringBuilder message = new StringBuilder();
if (!missingActions.isEmpty()) {
for (Map.Entry<String, List<String>> keymapAndActions : missingActions.entrySet()) {
message.append("Unknown actions in keymap ").append(keymapAndActions.getKey()).append(", add them to unknown actions list:\n");
for (String action : keymapAndActions.getValue()) {
message.append("\"").append(action).append("\",").append("\n");
}
}
}
if (!reappearedAction.isEmpty()) {
message.append("The following actions have reappeared, remove them from unknown action list:\n");
for (String action : reappearedAction) {
message.append(action).append("\n");
}
}
fail("\n" + message);
}
}
use of com.intellij.openapi.actionSystem.AnAction in project intellij-community by JetBrains.
the class UnwrapTestCase method assertOptions.
protected void assertOptions(String code, String... expectedOptions) throws IOException {
configureCode(code);
final List<String> actualOptions = new ArrayList<>();
UnwrapHandler h = new UnwrapHandler() {
@Override
protected void selectOption(List<AnAction> options, Editor editor, PsiFile file) {
for (AnAction each : options) {
actualOptions.add(each.getTemplatePresentation().getText());
}
}
};
h.invoke(getProject(), getEditor(), getFile());
//noinspection MisorderedAssertEqualsArguments
assertEquals(Arrays.asList(expectedOptions), actualOptions);
}
use of com.intellij.openapi.actionSystem.AnAction in project intellij-community by JetBrains.
the class ShowQuickActionPopupAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
QuickActionProvider provider = e.getRequiredData(QuickActionProvider.KEY);
List<AnAction> actions = provider.getActions(true);
DefaultActionGroup group = new DefaultActionGroup(actions);
group.addSeparator();
JComponent component = provider.getComponent();
if (component != null && !provider.isCycleRoot()) {
Component eachParent = component.getParent();
while (eachParent != null) {
QuickActionProvider parentProvider = ObjectUtils.tryCast(eachParent, QuickActionProvider.class);
if (parentProvider != null) {
List<AnAction> parentActions = parentProvider.getActions(false);
if (!parentActions.isEmpty()) {
String name = StringUtil.notNullize(parentProvider.getName(), "");
DefaultActionGroup parentGroup = new DefaultActionGroup(name, parentActions);
if (!StringUtil.isEmpty(name)) {
parentGroup.setPopup(true);
} else {
group.add(Separator.getInstance());
}
group.add(parentGroup);
}
if (parentProvider.isCycleRoot())
break;
}
eachParent = eachParent.getParent();
}
}
JBPopupFactory.getInstance().createActionGroupPopup(null, group, e.getDataContext(), ALPHA_NUMBERING, true).showInBestPositionFor(e.getDataContext());
}
Aggregations