Search in sources :

Example 1 with TargetActionStub

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

the class AntToolwindowRegistrar method projectOpened.

@Override
public void projectOpened() {
    final KeymapManagerEx keymapManager = KeymapManagerEx.getInstanceEx();
    final String prefix = AntConfiguration.getActionIdPrefix(myProject);
    final ActionManager actionManager = ActionManager.getInstance();
    for (Keymap keymap : keymapManager.getAllKeymaps()) {
        for (String id : keymap.getActionIdList()) {
            if (id.startsWith(prefix) && actionManager.getAction(id) == null) {
                actionManager.registerAction(id, new TargetActionStub(id, myProject));
            }
        }
    }
    final CompilerManager compilerManager = CompilerManager.getInstance(myProject);
    compilerManager.addBeforeTask(new CompileTask() {

        @Override
        public boolean execute(CompileContext context) {
            final AntConfiguration config = AntConfiguration.getInstance(myProject);
            ((AntConfigurationBase) config).ensureInitialized();
            return config.executeTargetBeforeCompile(createDataContext(context));
        }
    });
    compilerManager.addAfterTask(new CompileTask() {

        @Override
        public boolean execute(CompileContext context) {
            final AntConfigurationBase config = (AntConfigurationBase) AntConfiguration.getInstance(myProject);
            config.ensureInitialized();
            if (context.getMessageCount(CompilerMessageCategory.ERROR) > 0) {
                final AntBuildTarget target = config.getTargetForEvent(ExecuteAfterCompilationEvent.getInstance());
                if (target != null) {
                    context.addMessage(CompilerMessageCategory.INFORMATION, "Skipping ant target \"" + target.getDisplayName() + "\" because of compilation errors", null, -1, -1);
                }
                return true;
            }
            return config.executeTargetAfterCompile(createDataContext(context));
        }
    });
}
Also used : ActionManager(com.intellij.openapi.actionSystem.ActionManager) TargetActionStub(com.intellij.lang.ant.config.actions.TargetActionStub) KeymapManagerEx(com.intellij.openapi.keymap.ex.KeymapManagerEx) AntConfiguration(com.intellij.lang.ant.config.AntConfiguration) AntBuildTarget(com.intellij.lang.ant.config.AntBuildTarget) Keymap(com.intellij.openapi.keymap.Keymap) AntConfigurationBase(com.intellij.lang.ant.config.AntConfigurationBase)

Aggregations

AntBuildTarget (com.intellij.lang.ant.config.AntBuildTarget)1 AntConfiguration (com.intellij.lang.ant.config.AntConfiguration)1 AntConfigurationBase (com.intellij.lang.ant.config.AntConfigurationBase)1 TargetActionStub (com.intellij.lang.ant.config.actions.TargetActionStub)1 ActionManager (com.intellij.openapi.actionSystem.ActionManager)1 Keymap (com.intellij.openapi.keymap.Keymap)1 KeymapManagerEx (com.intellij.openapi.keymap.ex.KeymapManagerEx)1