Search in sources :

Example 11 with ExternalSystemNode

use of com.intellij.openapi.externalSystem.view.ExternalSystemNode in project intellij-community by JetBrains.

the class AssignRunConfigurationShortcutAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    Project project = getProject(e);
    assert project != null;
    final List<ExternalSystemNode> selectedNodes = ExternalSystemDataKeys.SELECTED_NODES.getData(e.getDataContext());
    if (selectedNodes == null || selectedNodes.size() != 1 || !(selectedNodes.get(0) instanceof RunConfigurationNode))
        return;
    RunnerAndConfigurationSettings settings = ((RunConfigurationNode) selectedNodes.get(0)).getSettings();
    assert settings != null;
    ExternalSystemRunConfiguration runConfiguration = (ExternalSystemRunConfiguration) settings.getConfiguration();
    String actionIdPrefix = getActionPrefix(project, runConfiguration.getSettings().getExternalProjectPath());
    String actionId = actionIdPrefix + settings.getName();
    AnAction action = ActionManager.getInstance().getAction(actionId);
    if (action == null) {
        ExternalSystemKeymapExtension.getOrRegisterAction(project, settings);
    }
    new EditKeymapsDialog(project, actionId).show();
}
Also used : Project(com.intellij.openapi.project.Project) EditKeymapsDialog(com.intellij.openapi.keymap.impl.ui.EditKeymapsDialog) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) ExternalSystemRunConfiguration(com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration) ExternalSystemNode(com.intellij.openapi.externalSystem.view.ExternalSystemNode) RunConfigurationNode(com.intellij.openapi.externalSystem.view.RunConfigurationNode) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 12 with ExternalSystemNode

use of com.intellij.openapi.externalSystem.view.ExternalSystemNode in project intellij-community by JetBrains.

the class GradleExecuteTaskAction method obtainAppropriateWorkingDirectory.

private static String obtainAppropriateWorkingDirectory(AnActionEvent e) {
    final List<ExternalSystemNode> selectedNodes = ExternalSystemDataKeys.SELECTED_NODES.getData(e.getDataContext());
    if (selectedNodes == null || selectedNodes.size() != 1) {
        final Module module = ExternalSystemActionUtil.getModule(e.getDataContext());
        String projectPath = ExternalSystemApiUtil.getExternalProjectPath(module);
        return projectPath == null ? "" : projectPath;
    }
    final ExternalSystemNode<?> node = selectedNodes.get(0);
    final Object externalData = node.getData();
    if (externalData instanceof ExternalConfigPathAware) {
        return ((ExternalConfigPathAware) externalData).getLinkedExternalProjectPath();
    } else {
        final ExternalConfigPathAware parentExternalConfigPathAware = node.findParentData(ExternalConfigPathAware.class);
        return parentExternalConfigPathAware != null ? parentExternalConfigPathAware.getLinkedExternalProjectPath() : "";
    }
}
Also used : ExternalConfigPathAware(com.intellij.openapi.externalSystem.model.project.ExternalConfigPathAware) ExternalSystemNode(com.intellij.openapi.externalSystem.view.ExternalSystemNode) Module(com.intellij.openapi.module.Module)

Aggregations

ExternalSystemNode (com.intellij.openapi.externalSystem.view.ExternalSystemNode)12 ExternalConfigPathAware (com.intellij.openapi.externalSystem.model.project.ExternalConfigPathAware)5 RunConfigurationNode (com.intellij.openapi.externalSystem.view.RunConfigurationNode)5 Project (com.intellij.openapi.project.Project)5 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)4 AnAction (com.intellij.openapi.actionSystem.AnAction)2 ProjectSystemId (com.intellij.openapi.externalSystem.model.ProjectSystemId)2 ProjectData (com.intellij.openapi.externalSystem.model.project.ProjectData)2 ExternalSystemRunConfiguration (com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration)2 ExternalProjectSettings (com.intellij.openapi.externalSystem.settings.ExternalProjectSettings)2 RunManagerEx (com.intellij.execution.RunManagerEx)1 EditConfigurationsDialog (com.intellij.execution.impl.EditConfigurationsDialog)1 ProgramRunner (com.intellij.execution.runners.ProgramRunner)1 ImportSpecBuilder (com.intellij.openapi.externalSystem.importing.ImportSpecBuilder)1 DataNode (com.intellij.openapi.externalSystem.model.DataNode)1 ExternalProjectInfo (com.intellij.openapi.externalSystem.model.ExternalProjectInfo)1 ExternalSystemTaskExecutionSettings (com.intellij.openapi.externalSystem.model.execution.ExternalSystemTaskExecutionSettings)1 ModuleData (com.intellij.openapi.externalSystem.model.project.ModuleData)1 TaskData (com.intellij.openapi.externalSystem.model.task.TaskData)1 ConfigureTasksActivationDialog (com.intellij.openapi.externalSystem.service.task.ui.ConfigureTasksActivationDialog)1