use of com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager in project intellij-community by JetBrains.
the class ExternalSystemUtil method refreshProjects.
/**
* Asks to refresh all external projects of the target external system linked to the given ide project based on provided spec
*
* @param spec import specification
*/
public static void refreshProjects(@NotNull final ImportSpec spec) {
ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(spec.getExternalSystemId());
if (manager == null) {
return;
}
AbstractExternalSystemSettings<?, ?, ?> settings = manager.getSettingsProvider().fun(spec.getProject());
final Collection<? extends ExternalProjectSettings> projectsSettings = settings.getLinkedProjectsSettings();
if (projectsSettings.isEmpty()) {
return;
}
final ProjectDataManager projectDataManager = ServiceManager.getService(ProjectDataManager.class);
final ExternalProjectRefreshCallback callback;
if (spec.getCallback() == null) {
callback = new MyMultiExternalProjectRefreshCallback(spec.getProject(), projectDataManager, spec.getExternalSystemId());
} else {
callback = spec.getCallback();
}
Set<String> toRefresh = ContainerUtilRt.newHashSet();
for (ExternalProjectSettings setting : projectsSettings) {
// don't refresh project when auto-import is disabled if such behavior needed (e.g. on project opening when auto-import is disabled)
if (!setting.isUseAutoImport() && spec.whenAutoImportEnabled())
continue;
toRefresh.add(setting.getExternalProjectPath());
}
if (!toRefresh.isEmpty()) {
ExternalSystemNotificationManager.getInstance(spec.getProject()).clearNotifications(null, NotificationSource.PROJECT_SYNC, spec.getExternalSystemId());
for (String path : toRefresh) {
refreshProject(path, new ImportSpecBuilder(spec).callback(callback).build());
}
}
}
use of com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager in project intellij-community by JetBrains.
the class GradleStartupActivity method showNotificationForUnlinkedGradleProject.
private static void showNotificationForUnlinkedGradleProject(@NotNull final Project project) {
if (!PropertiesComponent.getInstance(project).getBoolean(SHOW_UNLINKED_GRADLE_POPUP, true) || !GradleSettings.getInstance(project).getLinkedProjectsSettings().isEmpty() || project.getUserData(ExternalSystemDataKeys.NEWLY_IMPORTED_PROJECT) == Boolean.TRUE || project.getBaseDir() == null) {
return;
}
File baseDir = VfsUtilCore.virtualToIoFile(project.getBaseDir());
final File gradleFile = new File(baseDir, GradleConstants.DEFAULT_SCRIPT_NAME);
if (gradleFile.exists()) {
String message = String.format("%s<br>\n%s", GradleBundle.message("gradle.notifications.unlinked.project.found.msg", IMPORT_EVENT_DESCRIPTION), GradleBundle.message("gradle.notifications.do.not.show"));
GradleNotification.getInstance(project).showBalloon(GradleBundle.message("gradle.notifications.unlinked.project.found.title"), message, NotificationType.INFORMATION, new NotificationListener.Adapter() {
@Override
protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) {
notification.expire();
if (IMPORT_EVENT_DESCRIPTION.equals(e.getDescription())) {
final ProjectDataManager projectDataManager = ServiceManager.getService(ProjectDataManager.class);
GradleProjectImportBuilder gradleProjectImportBuilder = new GradleProjectImportBuilder(projectDataManager);
final GradleProjectImportProvider gradleProjectImportProvider = new GradleProjectImportProvider(gradleProjectImportBuilder);
AddModuleWizard wizard = new AddModuleWizard(project, gradleFile.getPath(), gradleProjectImportProvider);
if ((wizard.getStepCount() <= 0 || wizard.showAndGet())) {
ImportModuleAction.createFromWizard(project, wizard);
}
} else if (DO_NOT_SHOW_EVENT_DESCRIPTION.equals(e.getDescription())) {
PropertiesComponent.getInstance(project).setValue(SHOW_UNLINKED_GRADLE_POPUP, false, true);
}
}
});
}
}
Aggregations