Search in sources :

Example 1 with BuckBuildManager

use of com.facebook.buck.intellij.ideabuck.build.BuckBuildManager in project buck by facebook.

the class BuckBuildAction method executeOnPooledThread.

@Override
public void executeOnPooledThread(final AnActionEvent e) {
    Project project = e.getProject();
    if (project == null) {
        return;
    }
    BuckBuildManager buildManager = BuckBuildManager.getInstance(project);
    String target = buildManager.getCurrentSavedTarget(project);
    // Initiate a buck build
    BuckModule buckModule = project.getComponent(BuckModule.class);
    buckModule.attach(target);
    if (target == null) {
        buildManager.showNoTargetMessage(project);
        return;
    }
    BuckBuildCommandHandler handler = new BuckBuildCommandHandler(project, project.getBaseDir(), BuckCommand.BUILD);
    handler.command().addParameter(target);
    buildManager.runBuckCommandWhileConnectedToBuck(handler, ACTION_TITLE, buckModule);
}
Also used : Project(com.intellij.openapi.project.Project) BuckModule(com.facebook.buck.intellij.ideabuck.config.BuckModule) BuckBuildManager(com.facebook.buck.intellij.ideabuck.build.BuckBuildManager) BuckBuildCommandHandler(com.facebook.buck.intellij.ideabuck.build.BuckBuildCommandHandler)

Example 2 with BuckBuildManager

use of com.facebook.buck.intellij.ideabuck.build.BuckBuildManager in project buck by facebook.

the class BuckQueryAction method execute.

public static synchronized List<String> execute(final Project project, final String target, final Function<List<String>, Void> fillTextResults) {
    if (ongoingQuery.contains(target)) {
        return Collections.emptyList();
    }
    List<String> targetsInBuckFile = buckTargetCache.getIfPresent(target);
    if (targetsInBuckFile != null) {
        return targetsInBuckFile;
    }
    ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {

        public void run() {
            ongoingQuery.add(target);
            BuckBuildManager buildManager = BuckBuildManager.getInstance(project);
            BuckCommandHandler handler = new BuckQueryCommandHandler(project, project.getBaseDir(), BuckCommand.QUERY, new Function<List<String>, Void>() {

                @Nullable
                @Override
                public Void apply(@Nullable List<String> strings) {
                    ongoingQuery.remove(target);
                    buckTargetCache.put(target, strings);
                    fillTextResults.apply(strings);
                    return null;
                }
            });
            handler.command().addParameter(target);
            buildManager.runBuckCommand(handler, ACTION_TITLE);
        }
    });
    return Collections.emptyList();
}
Also used : Function(com.google.common.base.Function) BuckQueryCommandHandler(com.facebook.buck.intellij.ideabuck.build.BuckQueryCommandHandler) BuckBuildManager(com.facebook.buck.intellij.ideabuck.build.BuckBuildManager) List(java.util.List) BuckCommandHandler(com.facebook.buck.intellij.ideabuck.build.BuckCommandHandler) Nullable(javax.annotation.Nullable)

Example 3 with BuckBuildManager

use of com.facebook.buck.intellij.ideabuck.build.BuckBuildManager in project buck by facebook.

the class BuckInstallAction method executeOnPooledThread.

@Override
public void executeOnPooledThread(final AnActionEvent e) {
    Project project = e.getProject();
    BuckBuildManager buildManager = BuckBuildManager.getInstance(project);
    String target = buildManager.getCurrentSavedTarget(project);
    BuckModule buckModule = project.getComponent(BuckModule.class);
    buckModule.attach(target);
    if (target == null) {
        buildManager.showNoTargetMessage(project);
        return;
    }
    BuckSettingsProvider.State state = BuckSettingsProvider.getInstance().getState();
    if (state == null) {
        return;
    }
    BuckBuildCommandHandler handler = new BuckBuildCommandHandler(project, project.getBaseDir(), BuckCommand.INSTALL);
    if (state.customizedInstallSetting) {
        // Split the whole command line into different parameters.
        String commands = state.customizedInstallSettingCommand;
        Matcher matcher = Pattern.compile("([^\"]\\S*|\".+?\")\\s*").matcher(commands);
        while (matcher.find()) {
            handler.command().addParameter(matcher.group(1));
        }
    } else {
        if (state.runAfterInstall) {
            handler.command().addParameter("-r");
        }
        if (state.multiInstallMode) {
            handler.command().addParameter("-x");
        }
        if (state.uninstallBeforeInstalling) {
            handler.command().addParameter("-u");
        }
    }
    handler.command().addParameter(target);
    buildManager.runBuckCommandWhileConnectedToBuck(handler, ACTION_TITLE, buckModule);
}
Also used : Project(com.intellij.openapi.project.Project) BuckModule(com.facebook.buck.intellij.ideabuck.config.BuckModule) Matcher(java.util.regex.Matcher) BuckBuildManager(com.facebook.buck.intellij.ideabuck.build.BuckBuildManager) BuckSettingsProvider(com.facebook.buck.intellij.ideabuck.config.BuckSettingsProvider) BuckBuildCommandHandler(com.facebook.buck.intellij.ideabuck.build.BuckBuildCommandHandler)

Example 4 with BuckBuildManager

use of com.facebook.buck.intellij.ideabuck.build.BuckBuildManager in project buck by facebook.

the class BuckKillAction method update.

@Override
public void update(AnActionEvent e) {
    Project project = e.getProject();
    if (project != null) {
        BuckBuildManager buildManager = BuckBuildManager.getInstance(project);
        e.getPresentation().setEnabled(!buildManager.isKilling() && buildManager.isBuilding());
    }
}
Also used : Project(com.intellij.openapi.project.Project) BuckBuildManager(com.facebook.buck.intellij.ideabuck.build.BuckBuildManager)

Example 5 with BuckBuildManager

use of com.facebook.buck.intellij.ideabuck.build.BuckBuildManager in project buck by facebook.

the class BuckProjectGenerationAction method executeOnPooledThread.

@Override
public void executeOnPooledThread(final AnActionEvent e) {
    Project project = e.getProject();
    BuckBuildManager buildManager = BuckBuildManager.getInstance(project);
    String target = buildManager.getCurrentSavedTarget(project);
    BuckModule buckModule = project.getComponent(BuckModule.class);
    buckModule.attach(target);
    if (target == null) {
        buildManager.showNoTargetMessage(project);
        return;
    }
    BuckBuildCommandHandler handler = new BuckBuildCommandHandler(project, project.getBaseDir(), BuckCommand.PROJECT);
    handler.command().addParameter(target);
    buildManager.runBuckCommandWhileConnectedToBuck(handler, ACTION_TITLE, buckModule);
}
Also used : Project(com.intellij.openapi.project.Project) BuckModule(com.facebook.buck.intellij.ideabuck.config.BuckModule) BuckBuildManager(com.facebook.buck.intellij.ideabuck.build.BuckBuildManager) BuckBuildCommandHandler(com.facebook.buck.intellij.ideabuck.build.BuckBuildCommandHandler)

Aggregations

BuckBuildManager (com.facebook.buck.intellij.ideabuck.build.BuckBuildManager)8 Project (com.intellij.openapi.project.Project)6 BuckBuildCommandHandler (com.facebook.buck.intellij.ideabuck.build.BuckBuildCommandHandler)5 BuckModule (com.facebook.buck.intellij.ideabuck.config.BuckModule)5 BuckCommandHandler (com.facebook.buck.intellij.ideabuck.build.BuckCommandHandler)1 BuckQueryCommandHandler (com.facebook.buck.intellij.ideabuck.build.BuckQueryCommandHandler)1 BuckSettingsProvider (com.facebook.buck.intellij.ideabuck.config.BuckSettingsProvider)1 Function (com.google.common.base.Function)1 Notification (com.intellij.notification.Notification)1 List (java.util.List)1 Matcher (java.util.regex.Matcher)1 Nullable (javax.annotation.Nullable)1 Nullable (org.jetbrains.annotations.Nullable)1