Search in sources :

Example 6 with ExternalConfigPathAware

use of com.intellij.openapi.externalSystem.model.project.ExternalConfigPathAware in project intellij-community by JetBrains.

the class IgnoreExternalProjectAction method setSelected.

@Override
public void setSelected(AnActionEvent e, boolean state) {
    final ProjectSystemId projectSystemId = getSystemId(e);
    final ExternalSystemNode<ExternalConfigPathAware> projectNode = getProjectNode(e);
    if (projectSystemId == null || projectNode == null || projectNode.getData() == null)
        return;
    projectNode.setIgnored(state);
    final Project project = getProject(e);
    final String externalProjectPath = projectNode.getData().getLinkedExternalProjectPath();
    final ExternalProjectInfo externalProjectInfo = ExternalSystemUtil.getExternalProjectInfo(project, projectSystemId, externalProjectPath);
    if (externalProjectInfo == null || externalProjectInfo.getExternalProjectStructure() == null) {
        if (LOG.isDebugEnabled()) {
            LOG.debug(String.format("external project data not found, path: %s, data: %s", externalProjectPath, externalProjectInfo));
        }
        return;
    }
    final DataNode<ProjectData> projectDataNode = externalProjectInfo.getExternalProjectStructure();
    ServiceManager.getService(ProjectDataManager.class).importData(projectDataNode, project, true);
}
Also used : ExternalConfigPathAware(com.intellij.openapi.externalSystem.model.project.ExternalConfigPathAware) ExternalProjectInfo(com.intellij.openapi.externalSystem.model.ExternalProjectInfo) Project(com.intellij.openapi.project.Project) ProjectDataManager(com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) ProjectData(com.intellij.openapi.externalSystem.model.project.ProjectData)

Example 7 with ExternalConfigPathAware

use of com.intellij.openapi.externalSystem.model.project.ExternalConfigPathAware in project intellij-community by JetBrains.

the class OpenTasksActivationManagerAction 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;
    new ConfigureTasksActivationDialog(project, projectSystemId, externalConfigPathAware.getLinkedExternalProjectPath()).showAndGet();
}
Also used : ExternalConfigPathAware(com.intellij.openapi.externalSystem.model.project.ExternalConfigPathAware) ExternalSystemNode(com.intellij.openapi.externalSystem.view.ExternalSystemNode) ConfigureTasksActivationDialog(com.intellij.openapi.externalSystem.service.task.ui.ConfigureTasksActivationDialog)

Example 8 with ExternalConfigPathAware

use of com.intellij.openapi.externalSystem.model.project.ExternalConfigPathAware 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

ExternalConfigPathAware (com.intellij.openapi.externalSystem.model.project.ExternalConfigPathAware)8 ExternalSystemNode (com.intellij.openapi.externalSystem.view.ExternalSystemNode)5 ProjectSystemId (com.intellij.openapi.externalSystem.model.ProjectSystemId)4 ProjectData (com.intellij.openapi.externalSystem.model.project.ProjectData)2 ExternalProjectSettings (com.intellij.openapi.externalSystem.settings.ExternalProjectSettings)2 ExternalSystemUiAware (com.intellij.openapi.externalSystem.ExternalSystemUiAware)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 ExternalEntityData (com.intellij.openapi.externalSystem.model.project.ExternalEntityData)1 ModuleData (com.intellij.openapi.externalSystem.model.project.ModuleData)1 TaskData (com.intellij.openapi.externalSystem.model.task.TaskData)1 ProjectDataManager (com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager)1 ConfigureTasksActivationDialog (com.intellij.openapi.externalSystem.service.task.ui.ConfigureTasksActivationDialog)1 AbstractExternalSystemLocalSettings (com.intellij.openapi.externalSystem.settings.AbstractExternalSystemLocalSettings)1 Module (com.intellij.openapi.module.Module)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 MultiMap (com.intellij.util.containers.MultiMap)1 Collection (java.util.Collection)1