Search in sources :

Example 1 with BuckModule

use of com.facebook.buck.intellij.ideabuck.config.BuckModule in project buck by facebook.

the class BuckBuildManager method showNoTargetMessage.

/**
   * Print "no selected target" error message to console window.
   * Also provide a hyperlink which can directly jump to "Choose Target" GUI window.
   */
public void showNoTargetMessage(Project project) {
    BuckModule buckModule = project.getComponent(BuckModule.class);
    buckModule.getBuckEventsConsumer().consumeConsoleEvent("Please choose a build target!");
    BuckToolWindowFactory.outputConsoleMessage(project, "Please ", ConsoleViewContentType.ERROR_OUTPUT);
    BuckToolWindowFactory.outputConsoleHyperlink(project, "choose a build target!\n", new HyperlinkInfo() {

        @Override
        public void navigate(Project project) {
            JComponent frame = WindowManager.getInstance().getIdeFrame(project).getComponent();
            AnAction action = ActionManager.getInstance().getAction("buck.ChooseTarget");
            action.actionPerformed(new AnActionEvent(null, DataManager.getInstance().getDataContext(frame), ActionPlaces.UNKNOWN, action.getTemplatePresentation(), ActionManager.getInstance(), 0));
        }
    });
}
Also used : Project(com.intellij.openapi.project.Project) BuckModule(com.facebook.buck.intellij.ideabuck.config.BuckModule) JComponent(javax.swing.JComponent) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnAction(com.intellij.openapi.actionSystem.AnAction) HyperlinkInfo(com.intellij.execution.filters.HyperlinkInfo)

Example 2 with BuckModule

use of com.facebook.buck.intellij.ideabuck.config.BuckModule 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 3 with BuckModule

use of com.facebook.buck.intellij.ideabuck.config.BuckModule 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 BuckModule

use of com.facebook.buck.intellij.ideabuck.config.BuckModule in project buck by facebook.

the class BuckKillAction method executeOnPooledThread.

@Override
public void executeOnPooledThread(final AnActionEvent e) {
    Project project = e.getProject();
    // stop the current running process
    BuckBuildManager.getInstance(project).getCurrentRunningBuckCommandHandler().stop();
    BuckModule buckModule = project.getComponent(BuckModule.class);
    // run the buck kill command
    BuckKillCommandHandler handler = new BuckKillCommandHandler(project, project.getBaseDir(), BuckCommand.KILL);
    BuckBuildManager.getInstance(project).runBuckCommandWhileConnectedToBuck(handler, ACTION_TITLE, buckModule);
}
Also used : Project(com.intellij.openapi.project.Project) BuckModule(com.facebook.buck.intellij.ideabuck.config.BuckModule) BuckKillCommandHandler(com.facebook.buck.intellij.ideabuck.build.BuckKillCommandHandler)

Example 5 with BuckModule

use of com.facebook.buck.intellij.ideabuck.config.BuckModule 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

BuckModule (com.facebook.buck.intellij.ideabuck.config.BuckModule)9 Project (com.intellij.openapi.project.Project)7 BuckBuildCommandHandler (com.facebook.buck.intellij.ideabuck.build.BuckBuildCommandHandler)6 BuckBuildManager (com.facebook.buck.intellij.ideabuck.build.BuckBuildManager)5 Matcher (java.util.regex.Matcher)2 BuckKillCommandHandler (com.facebook.buck.intellij.ideabuck.build.BuckKillCommandHandler)1 BuckSettingsProvider (com.facebook.buck.intellij.ideabuck.config.BuckSettingsProvider)1 ExecutionException (com.intellij.execution.ExecutionException)1 HyperlinkInfo (com.intellij.execution.filters.HyperlinkInfo)1 OSProcessHandler (com.intellij.execution.process.OSProcessHandler)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 Key (com.intellij.openapi.util.Key)1 IOException (java.io.IOException)1 JComponent (javax.swing.JComponent)1