use of com.intellij.openapi.actionSystem.ex.ActionManagerEx in project intellij-community by JetBrains.
the class ActionMacroManager method checkCanCreateMacro.
public boolean checkCanCreateMacro(String name) {
final ActionManagerEx actionManager = (ActionManagerEx) ActionManager.getInstance();
final String actionId = ActionMacro.MACRO_ACTION_PREFIX + name;
if (actionManager.getAction(actionId) != null) {
if (Messages.showYesNoDialog(IdeBundle.message("message.macro.exists", name), IdeBundle.message("title.macro.name.already.used"), Messages.getWarningIcon()) != Messages.YES) {
return false;
}
actionManager.unregisterAction(actionId);
removeMacro(name);
}
return true;
}
use of com.intellij.openapi.actionSystem.ex.ActionManagerEx in project intellij-community by JetBrains.
the class EditorTestUtil method executeAction.
public static void executeAction(@NotNull Editor editor, @NotNull String actionId, boolean assertActionIsEnabled) {
ActionManagerEx actionManager = ActionManagerEx.getInstanceEx();
AnAction action = actionManager.getAction(actionId);
assertNotNull(action);
executeAction(editor, assertActionIsEnabled, action);
}
use of com.intellij.openapi.actionSystem.ex.ActionManagerEx in project intellij-community by JetBrains.
the class AntConfigurationImpl method updateRegisteredActions.
private void updateRegisteredActions() {
final Project project = getProject();
if (project.isDisposed()) {
return;
}
final List<Pair<String, AnAction>> actionList = new ArrayList<>();
for (final AntBuildFile buildFile : myBuildFiles) {
final AntBuildModelBase model = (AntBuildModelBase) buildFile.getModel();
String defaultTargetActionId = model.getDefaultTargetActionId();
if (defaultTargetActionId != null) {
final TargetAction action = new TargetAction(buildFile, TargetAction.DEFAULT_TARGET_NAME, new String[] { TargetAction.DEFAULT_TARGET_NAME }, null);
actionList.add(new Pair<>(defaultTargetActionId, action));
}
collectTargetActions(model.getFilteredTargets(), actionList, buildFile);
collectTargetActions(getMetaTargets(buildFile), actionList, buildFile);
}
//noinspection SynchronizeOnThis
synchronized (this) {
// unregister Ant actions
ActionManagerEx actionManager = ActionManagerEx.getInstanceEx();
final String[] oldIds = actionManager.getActionIds(AntConfiguration.getActionIdPrefix(project));
for (String oldId : oldIds) {
actionManager.unregisterAction(oldId);
}
final Set<String> registeredIds = StringSetSpinAllocator.alloc();
try {
for (Pair<String, AnAction> pair : actionList) {
if (!registeredIds.contains(pair.first)) {
registeredIds.add(pair.first);
actionManager.registerAction(pair.first, pair.second);
}
}
} finally {
StringSetSpinAllocator.dispose(registeredIds);
}
}
}
use of com.intellij.openapi.actionSystem.ex.ActionManagerEx in project intellij-community by JetBrains.
the class AntKeymapExtension method createGroup.
public KeymapGroup createGroup(final Condition<AnAction> filtered, Project project) {
final Map<AntBuildFile, KeymapGroup> buildFileToGroup = new HashMap<>();
final KeymapGroup result = KeymapGroupFactory.getInstance().createGroup(KeyMapBundle.message("ant.targets.group.title"), AllIcons.Nodes.KeymapAnt);
final ActionManagerEx actionManager = ActionManagerEx.getInstanceEx();
final String[] ids = actionManager.getActionIds(project != null ? AntConfiguration.getActionIdPrefix(project) : AntConfiguration.ACTION_ID_PREFIX);
Arrays.sort(ids);
if (project != null) {
final AntConfiguration antConfiguration = AntConfiguration.getInstance(project);
ApplicationManager.getApplication().runReadAction(() -> {
for (final String id : ids) {
if (filtered != null && !filtered.value(actionManager.getActionOrStub(id))) {
continue;
}
final AntBuildFile buildFile = antConfiguration.findBuildFileByActionId(id);
if (buildFile != null) {
KeymapGroup subGroup = buildFileToGroup.get(buildFile);
if (subGroup == null) {
subGroup = KeymapGroupFactory.getInstance().createGroup(buildFile.getPresentableName());
buildFileToGroup.put(buildFile, subGroup);
result.addGroup(subGroup);
}
subGroup.addActionId(id);
} else {
LOG.info("no buildfile found for actionId=" + id);
}
}
});
}
return result;
}
use of com.intellij.openapi.actionSystem.ex.ActionManagerEx in project intellij-community by JetBrains.
the class AntToolwindowRegistrar method projectClosed.
@Override
public void projectClosed() {
final ActionManagerEx actionManager = ActionManagerEx.getInstanceEx();
final String[] oldIds = actionManager.getActionIds(AntConfiguration.getActionIdPrefix(myProject));
for (String oldId : oldIds) {
actionManager.unregisterAction(oldId);
}
}
Aggregations