Search in sources :

Example 1 with ExternalSystemNode

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

the class OpenTasksActivationManagerAction method isEnabled.

@Override
protected boolean isEnabled(AnActionEvent e) {
    if (!super.isEnabled(e))
        return false;
    final List<ExternalSystemNode> selectedNodes = ExternalSystemDataKeys.SELECTED_NODES.getData(e.getDataContext());
    if (selectedNodes == null || selectedNodes.size() != 1)
        return false;
    final Object externalData = selectedNodes.get(0).getData();
    ProjectSystemId projectSystemId = getSystemId(e);
    e.getPresentation().setText(ExternalSystemBundle.message("external.system.task.activation.title"));
    e.getPresentation().setDescription(ExternalSystemBundle.message("external.system.task.activation.description", projectSystemId.getReadableName()));
    final boolean isProjectNode = externalData instanceof ProjectData || externalData instanceof ModuleData;
    return isProjectNode && StringUtil.isNotEmpty(((ExternalConfigPathAware) externalData).getLinkedExternalProjectPath());
}
Also used : ExternalConfigPathAware(com.intellij.openapi.externalSystem.model.project.ExternalConfigPathAware) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) ModuleData(com.intellij.openapi.externalSystem.model.project.ModuleData) ExternalSystemNode(com.intellij.openapi.externalSystem.view.ExternalSystemNode) ProjectData(com.intellij.openapi.externalSystem.model.project.ProjectData)

Example 2 with ExternalSystemNode

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

the class RefreshExternalProjectAction method perform.

@Override
public void perform(@NotNull final Project project, @NotNull ProjectSystemId projectSystemId, @NotNull AbstractExternalEntityData externalEntityData, @NotNull AnActionEvent e) {
    final List<ExternalSystemNode> selectedNodes = ExternalSystemDataKeys.SELECTED_NODES.getData(e.getDataContext());
    final ExternalSystemNode<?> externalSystemNode = ContainerUtil.getFirstItem(selectedNodes);
    assert externalSystemNode != null;
    final ExternalConfigPathAware externalConfigPathAware = externalSystemNode.getData() instanceof ExternalConfigPathAware ? (ExternalConfigPathAware) externalSystemNode.getData() : null;
    assert externalConfigPathAware != null;
    // We save all documents because there is a possible case that there is an external system config file changed inside the ide.
    FileDocumentManager.getInstance().saveAllDocuments();
    final ExternalProjectSettings linkedProjectSettings = ExternalSystemApiUtil.getSettings(project, projectSystemId).getLinkedProjectSettings(externalConfigPathAware.getLinkedExternalProjectPath());
    final String externalProjectPath = linkedProjectSettings == null ? externalConfigPathAware.getLinkedExternalProjectPath() : linkedProjectSettings.getExternalProjectPath();
    ExternalSystemUtil.refreshProject(project, projectSystemId, externalProjectPath, false, ProgressExecutionMode.IN_BACKGROUND_ASYNC);
}
Also used : ExternalConfigPathAware(com.intellij.openapi.externalSystem.model.project.ExternalConfigPathAware) ExternalSystemNode(com.intellij.openapi.externalSystem.view.ExternalSystemNode) ExternalProjectSettings(com.intellij.openapi.externalSystem.settings.ExternalProjectSettings)

Example 3 with ExternalSystemNode

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

the class RemoveExternalSystemRunConfigurationAction 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;
    int res = Messages.showYesNoDialog(project, "Delete \"" + settings.getName() + "\"?", "Confirmation", Messages.getQuestionIcon());
    if (res == Messages.YES) {
        ((RunManagerEx) RunManager.getInstance(project)).removeConfiguration(settings);
    }
}
Also used : Project(com.intellij.openapi.project.Project) RunManagerEx(com.intellij.execution.RunManagerEx) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) ExternalSystemNode(com.intellij.openapi.externalSystem.view.ExternalSystemNode) RunConfigurationNode(com.intellij.openapi.externalSystem.view.RunConfigurationNode)

Example 4 with ExternalSystemNode

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

the class ToggleTaskActivationAction method getTasks.

@NotNull
private static List<TaskData> getTasks(AnActionEvent e) {
    final List<ExternalSystemNode> selectedNodes = ExternalSystemDataKeys.SELECTED_NODES.getData(e.getDataContext());
    if (selectedNodes == null)
        return Collections.emptyList();
    List<TaskData> tasks = new SmartList<>();
    for (ExternalSystemNode node : selectedNodes) {
        if (node instanceof TaskNode && !node.isIgnored()) {
            tasks.add((TaskData) node.getData());
        } else if (node instanceof RunConfigurationNode) {
            final RunnerAndConfigurationSettings configurationSettings = ((RunConfigurationNode) node).getSettings();
            final ExternalSystemRunConfiguration runConfiguration = (ExternalSystemRunConfiguration) configurationSettings.getConfiguration();
            final ExternalSystemTaskExecutionSettings taskExecutionSettings = runConfiguration.getSettings();
            tasks.add(new TaskData(taskExecutionSettings.getExternalSystemId(), RUN_CONFIGURATION_TASK_PREFIX + configurationSettings.getName(), taskExecutionSettings.getExternalProjectPath(), null));
        } else {
            return Collections.emptyList();
        }
    }
    return tasks;
}
Also used : TaskNode(com.intellij.openapi.externalSystem.view.TaskNode) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) ExternalSystemRunConfiguration(com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration) ExternalSystemNode(com.intellij.openapi.externalSystem.view.ExternalSystemNode) SmartList(com.intellij.util.SmartList) RunConfigurationNode(com.intellij.openapi.externalSystem.view.RunConfigurationNode) TaskData(com.intellij.openapi.externalSystem.model.task.TaskData) ExternalSystemTaskExecutionSettings(com.intellij.openapi.externalSystem.model.execution.ExternalSystemTaskExecutionSettings) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with ExternalSystemNode

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

the class GradleRefreshProjectDependenciesAction method perform.

@Override
public void perform(@NotNull final Project project, @NotNull ProjectSystemId projectSystemId, @NotNull AbstractExternalEntityData externalEntityData, @NotNull AnActionEvent e) {
    final List<ExternalSystemNode> selectedNodes = ExternalSystemDataKeys.SELECTED_NODES.getData(e.getDataContext());
    final ExternalSystemNode<?> externalSystemNode = ContainerUtil.getFirstItem(selectedNodes);
    assert externalSystemNode != null;
    final ExternalConfigPathAware externalConfigPathAware = externalSystemNode.getData() instanceof ExternalConfigPathAware ? (ExternalConfigPathAware) externalSystemNode.getData() : null;
    assert externalConfigPathAware != null;
    // We save all documents because there is a possible case that there is an external system config file changed inside the ide.
    FileDocumentManager.getInstance().saveAllDocuments();
    final ExternalProjectSettings linkedProjectSettings = ExternalSystemApiUtil.getSettings(project, projectSystemId).getLinkedProjectSettings(externalConfigPathAware.getLinkedExternalProjectPath());
    final String externalProjectPath = linkedProjectSettings == null ? externalConfigPathAware.getLinkedExternalProjectPath() : linkedProjectSettings.getExternalProjectPath();
    ExternalSystemUtil.refreshProject(externalProjectPath, new ImportSpecBuilder(project, projectSystemId).useDefaultCallback().use(ProgressExecutionMode.IN_BACKGROUND_ASYNC).withArguments("--refresh-dependencies").build());
}
Also used : ExternalConfigPathAware(com.intellij.openapi.externalSystem.model.project.ExternalConfigPathAware) ExternalSystemNode(com.intellij.openapi.externalSystem.view.ExternalSystemNode) ExternalProjectSettings(com.intellij.openapi.externalSystem.settings.ExternalProjectSettings) ImportSpecBuilder(com.intellij.openapi.externalSystem.importing.ImportSpecBuilder)

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