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);
}
}
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();
}
}
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);
}
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();
}
}
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;
}
Aggregations