Search in sources :

Example 26 with ProjectData

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

the class ExternalSystemResolveProjectTask method doExecute.

@SuppressWarnings("unchecked")
protected void doExecute() throws Exception {
    final ExternalSystemFacadeManager manager = ServiceManager.getService(ExternalSystemFacadeManager.class);
    Project ideProject = getIdeProject();
    RemoteExternalSystemProjectResolver resolver = manager.getFacade(ideProject, myProjectPath, getExternalSystemId()).getResolver();
    ExternalSystemExecutionSettings settings = ExternalSystemApiUtil.getExecutionSettings(ideProject, myProjectPath, getExternalSystemId());
    if (StringUtil.isNotEmpty(myVmOptions)) {
        settings.withVmOptions(ParametersListUtil.parse(myVmOptions));
    }
    if (StringUtil.isNotEmpty(myArguments)) {
        settings.withArguments(ParametersListUtil.parse(myArguments));
    }
    ExternalSystemProgressNotificationManagerImpl progressNotificationManager = (ExternalSystemProgressNotificationManagerImpl) ServiceManager.getService(ExternalSystemProgressNotificationManager.class);
    ExternalSystemTaskId id = getId();
    progressNotificationManager.onStart(id, myProjectPath);
    try {
        DataNode<ProjectData> project = resolver.resolveProjectInfo(id, myProjectPath, myIsPreviewMode, settings);
        if (project != null) {
            myExternalProject.set(project);
            ExternalSystemManager<?, ?, ?, ?, ?> systemManager = ExternalSystemApiUtil.getManager(getExternalSystemId());
            assert systemManager != null;
            Set<String> externalModulePaths = ContainerUtil.newHashSet();
            Collection<DataNode<ModuleData>> moduleNodes = ExternalSystemApiUtil.findAll(project, ProjectKeys.MODULE);
            for (DataNode<ModuleData> node : moduleNodes) {
                externalModulePaths.add(node.getData().getLinkedExternalProjectPath());
            }
            String projectPath = project.getData().getLinkedExternalProjectPath();
            ExternalProjectSettings linkedProjectSettings = systemManager.getSettingsProvider().fun(ideProject).getLinkedProjectSettings(projectPath);
            if (linkedProjectSettings != null) {
                linkedProjectSettings.setModules(externalModulePaths);
            }
        }
        progressNotificationManager.onSuccess(id);
    } finally {
        progressNotificationManager.onEnd(id);
    }
}
Also used : ExternalSystemTaskId(com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId) ExternalSystemProgressNotificationManagerImpl(com.intellij.openapi.externalSystem.service.remote.ExternalSystemProgressNotificationManagerImpl) ExternalSystemFacadeManager(com.intellij.openapi.externalSystem.service.ExternalSystemFacadeManager) ExternalSystemProgressNotificationManager(com.intellij.openapi.externalSystem.service.notification.ExternalSystemProgressNotificationManager) ExternalProjectSettings(com.intellij.openapi.externalSystem.settings.ExternalProjectSettings) Project(com.intellij.openapi.project.Project) RemoteExternalSystemProjectResolver(com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolver) DataNode(com.intellij.openapi.externalSystem.model.DataNode) ModuleData(com.intellij.openapi.externalSystem.model.project.ModuleData) ExternalSystemExecutionSettings(com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings) ProjectData(com.intellij.openapi.externalSystem.model.project.ProjectData)

Example 27 with ProjectData

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

the class ExternalSystemSelectProjectDataToImportAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final Project project = getProject(e);
    final ProjectSystemId projectSystemId = getSystemId(e);
    final List<ExternalSystemNode> selectedNodes = ExternalSystemDataKeys.SELECTED_NODES.getData(e.getDataContext());
    final ExternalProjectInfo projectInfo;
    final ExternalSystemNode<?> externalSystemNode = ContainerUtil.getFirstItem(selectedNodes);
    if (externalSystemNode == null) {
        projectInfo = ContainerUtil.getFirstItem(ProjectDataManager.getInstance().getExternalProjectsData(project, projectSystemId));
    } else {
        final ProjectNode projectNode = externalSystemNode instanceof ProjectNode ? (ProjectNode) externalSystemNode : externalSystemNode.findParent(ProjectNode.class);
        assert projectNode != null;
        final ProjectData projectData = projectNode.getData();
        assert projectData != null;
        projectInfo = ProjectDataManager.getInstance().getExternalProjectData(project, projectSystemId, projectData.getLinkedExternalProjectPath());
    }
    final ExternalProjectDataSelectorDialog dialog;
    if (projectInfo != null) {
        dialog = new ExternalProjectDataSelectorDialog(project, projectInfo, externalSystemNode != null ? externalSystemNode.getData() : null);
        dialog.showAndGet();
    }
}
Also used : ExternalProjectInfo(com.intellij.openapi.externalSystem.model.ExternalProjectInfo) Project(com.intellij.openapi.project.Project) ExternalProjectDataSelectorDialog(com.intellij.openapi.externalSystem.service.ui.ExternalProjectDataSelectorDialog) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) ProjectNode(com.intellij.openapi.externalSystem.view.ProjectNode) ExternalSystemNode(com.intellij.openapi.externalSystem.view.ExternalSystemNode) ProjectData(com.intellij.openapi.externalSystem.model.project.ProjectData)

Example 28 with ProjectData

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

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

the class AssignShortcutAction method perform.

@Override
protected void perform(@NotNull Project project, @NotNull ProjectSystemId projectSystemId, @NotNull TaskData taskData, @NotNull AnActionEvent e) {
    final ExternalSystemShortcutsManager shortcutsManager = ExternalProjectsManager.getInstance(project).getShortcutsManager();
    final String actionId = shortcutsManager.getActionId(taskData.getLinkedExternalProjectPath(), taskData.getName());
    if (actionId != null) {
        AnAction action = ActionManager.getInstance().getAction(actionId);
        if (action == null) {
            ExternalSystemNode<?> taskNode = ContainerUtil.getFirstItem(ExternalSystemDataKeys.SELECTED_NODES.getData(e.getDataContext()));
            assert taskNode != null;
            final String group;
            final ModuleNode moduleDataNode = taskNode.findParent(ModuleNode.class);
            if (moduleDataNode != null) {
                ModuleData moduleData = moduleDataNode.getData();
                group = moduleData != null ? moduleData.getInternalName() : null;
            } else {
                ProjectNode projectNode = taskNode.findParent(ProjectNode.class);
                ProjectData projectData = projectNode != null ? projectNode.getData() : null;
                group = projectData != null ? projectData.getInternalName() : null;
            }
            if (group != null) {
                ExternalSystemKeymapExtension.getOrRegisterAction(project, group, taskData);
            }
        }
        new EditKeymapsDialog(project, actionId).show();
    }
}
Also used : ExternalSystemShortcutsManager(com.intellij.openapi.externalSystem.service.project.manage.ExternalSystemShortcutsManager) EditKeymapsDialog(com.intellij.openapi.keymap.impl.ui.EditKeymapsDialog) ModuleData(com.intellij.openapi.externalSystem.model.project.ModuleData) ProjectNode(com.intellij.openapi.externalSystem.view.ProjectNode) AnAction(com.intellij.openapi.actionSystem.AnAction) ProjectData(com.intellij.openapi.externalSystem.model.project.ProjectData) ModuleNode(com.intellij.openapi.externalSystem.view.ModuleNode)

Example 30 with ProjectData

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

the class ImportSpecBuilder method build.

public ImportSpec build() {
    ImportSpecImpl mySpec = new ImportSpecImpl(myProject, myExternalSystemId);
    mySpec.setWhenAutoImportEnabled(myWhenAutoImportEnabled);
    mySpec.setProgressExecutionMode(myProgressExecutionMode);
    mySpec.setForceWhenUptodate(myForceWhenUptodate);
    mySpec.setCreateDirectoriesForEmptyContentRoots(myCreateDirectoriesForEmptyContentRoots);
    if (myUseDefaultCallback) {
        mySpec.setCallback(new ExternalProjectRefreshCallback() {

            @Override
            public void onSuccess(@Nullable final DataNode<ProjectData> externalProject) {
                if (externalProject == null) {
                    return;
                }
                final boolean synchronous = mySpec.getProgressExecutionMode() == ProgressExecutionMode.MODAL_SYNC;
                ServiceManager.getService(ProjectDataManager.class).importData(externalProject, mySpec.getProject(), synchronous);
            }

            @Override
            public void onFailure(@NotNull String errorMessage, @Nullable String errorDetails) {
            }
        });
    } else {
        mySpec.setCallback(myCallback);
    }
    mySpec.setPreviewMode(isPreviewMode);
    mySpec.setReportRefreshError(isReportRefreshError);
    mySpec.setArguments(myArguments);
    mySpec.setVmOptions(myVmOptions);
    return mySpec;
}
Also used : ExternalProjectRefreshCallback(com.intellij.openapi.externalSystem.service.project.ExternalProjectRefreshCallback) ProjectData(com.intellij.openapi.externalSystem.model.project.ProjectData)

Aggregations

ProjectData (com.intellij.openapi.externalSystem.model.project.ProjectData)40 ModuleData (com.intellij.openapi.externalSystem.model.project.ModuleData)13 DataNode (com.intellij.openapi.externalSystem.model.DataNode)12 Project (com.intellij.openapi.project.Project)8 ExternalProjectSettings (com.intellij.openapi.externalSystem.settings.ExternalProjectSettings)7 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)5 GradleModuleModel (com.android.tools.idea.gradle.project.model.GradleModuleModel)4 ExternalProjectInfo (com.intellij.openapi.externalSystem.model.ExternalProjectInfo)4 AbstractExternalSystemSettings (com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 MultiMap (com.intellij.util.containers.MultiMap)4 NotNull (org.jetbrains.annotations.NotNull)4 ProjectSystemId (com.intellij.openapi.externalSystem.model.ProjectSystemId)3 InternalExternalProjectInfo (com.intellij.openapi.externalSystem.model.internal.InternalExternalProjectInfo)3 ExternalProjectRefreshCallback (com.intellij.openapi.externalSystem.service.project.ExternalProjectRefreshCallback)3 Module (com.intellij.openapi.module.Module)3 Task (com.intellij.openapi.progress.Task)3 DataNodeCaches (com.android.tools.idea.gradle.project.sync.idea.data.DataNodeCaches)2 ImportSpecBuilder (com.intellij.openapi.externalSystem.importing.ImportSpecBuilder)2 ExternalProjectPojo (com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo)2