Search in sources :

Example 1 with TargetAction

use of com.intellij.lang.ant.config.actions.TargetAction 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);
        }
    }
}
Also used : CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) TargetAction(com.intellij.lang.ant.config.actions.TargetAction) AnAction(com.intellij.openapi.actionSystem.AnAction) ActionManagerEx(com.intellij.openapi.actionSystem.ex.ActionManagerEx) Project(com.intellij.openapi.project.Project)

Example 2 with TargetAction

use of com.intellij.lang.ant.config.actions.TargetAction in project intellij-community by JetBrains.

the class AntConfigurationImpl method collectTargetActions.

private static void collectTargetActions(final AntBuildTarget[] targets, final List<Pair<String, AnAction>> actionList, final AntBuildFile buildFile) {
    for (final AntBuildTarget target : targets) {
        final String actionId = ((AntBuildTargetBase) target).getActionId();
        if (actionId != null) {
            final TargetAction action = new TargetAction(buildFile, target.getName(), new String[] { target.getName() }, target.getNotEmptyDescription());
            actionList.add(new Pair<>(actionId, action));
        }
    }
}
Also used : TargetAction(com.intellij.lang.ant.config.actions.TargetAction)

Aggregations

TargetAction (com.intellij.lang.ant.config.actions.TargetAction)2 AnAction (com.intellij.openapi.actionSystem.AnAction)1 ActionManagerEx (com.intellij.openapi.actionSystem.ex.ActionManagerEx)1 Project (com.intellij.openapi.project.Project)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1