From 25b64aa9aeb577888a5c1a52d0df5b279449c3fe Mon Sep 17 00:00:00 2001 From: "Denis.Zhdanov" Date: Mon, 22 Apr 2013 10:47:07 +0400 Subject: [PATCH] IDEA-104500 Gradle: Allow to reuse common logic for other external systems 1. 'external-system' is split into 'external-system-api' and 'external-system-impl'; 2. Legacy code is removed; --- build/scripts/utils.gant | 3 +- java/java-psi-impl/java-psi-impl.iml | 2 + .../externalSystem}/JavaProjectData.java | 21 +- .../JavaProjectDataService.java | 48 +- .../external-system-api.iml | 18 + .../i18n/ExternalSystemBundle.properties | 0 .../externalSystem/ExternalSystemManager.java | 2 +- .../build/ExternalSystemBuildManager.java | 2 +- .../externalSystem/model/DataNode.java | 0 .../model/ExternalSystemDataKeys.java | 17 + .../model/ExternalSystemException.java | 0 .../openapi/externalSystem/model/Key.java | 0 .../externalSystem/model/ProjectKeys.java | 2 - .../externalSystem/model/ProjectSystemId.java | 0 .../model/project/AbstractDependencyData.java | 0 .../model/project/AbstractNamedData.java | 0 .../project/AbstractProjectEntityData.java | 1 - .../model/project/ContentRootData.java | 25 +- .../model/project/DependencyData.java | 0 .../project/ExternalSystemSourceType.java | 0 .../model/project/LibraryData.java | 14 +- .../model/project/LibraryDependencyData.java | 16 + .../model/project/LibraryPathType.java | 0 .../model/project/ModuleData.java | 15 +- .../model/project/ModuleDependencyData.java | 10 - .../externalSystem/model/project/Named.java | 0 .../model/project/ProjectData.java | 16 +- .../model/project/ProjectEntityData.java | 12 - .../ExternalSystemExecutionSettings.java | 2 +- .../model/task/ExternalSystemTask.java | 0 .../task/ExternalSystemTaskDescriptor.java | 0 .../model/task/ExternalSystemTaskId.java | 0 .../ExternalSystemTaskNotificationEvent.java | 0 ...xternalSystemTaskNotificationListener.java | 0 ...SystemTaskNotificationListenerAdapter.java | 0 .../model/task/ExternalSystemTaskState.java | 0 .../model/task/ExternalSystemTaskType.java | 0 .../service/ParametersEnhancer.java | 0 .../ExternalLibraryPathTypeMapper.java | 5 +- .../ExternalSystemProjectResolver.java | 2 +- .../project/ModuleAwareContentRoot.java | 0 .../service/project/PlatformFacade.java | 4 - .../project/manage/ProjectDataService.java | 0 .../AbstractExternalSystemLocalSettings.java | 0 .../AbstractExternalSystemSettings.java | 0 .../ExternalSystemSettingsListener.java | 0 .../externalSystem/util/ArtifactInfo.java | 0 .../util/ExternalSystemApiUtil.java | 333 ++++++ .../util/ExternalSystemBundle.java | 0 .../util/ExternalSystemConstants.java | 0 .../externalSystem/util/IdeEntityVisitor.java | 0 .../externalSystem/util/IntegrationKey.java | 0 .../openapi/externalSystem/util/Order.java | 0 .../external-system-impl.iml} | 14 +- .../model/settings/LocationSettingType.java | 4 +- .../task/AbstractExternalSystemTask.java | 4 +- .../ExternalSystemResolveProjectTask.java | 18 +- .../model/task/ExternalSystemTaskAware.java | 0 .../DisposableExternalSystemService.java | 0 .../service/ExternalSystemFacadeImpl.java | 1 + .../service/ExternalSystemFacadeManager.java | 9 +- .../service/RemoteExternalSystemFacade.java | 2 +- .../service/RemoteExternalSystemService.java | 2 +- ...rnalSystemProgressNotificationManager.java | 0 .../ExternalLibraryPathTypeMapperImpl.java | 0 .../service/project/PlatformFacadeImpl.java | 10 +- .../project/ProjectStructureHelper.java | 252 ++++ .../project/ProjectStructureServices.java | 9 - .../manage/AbstractDependencyDataService.java | 8 +- .../manage/ContentRootDataService.java | 14 +- .../project/manage/LibraryDataService.java | 42 +- .../manage/LibraryDependencyDataService.java | 22 +- .../project/manage/ModuleDataService.java | 6 +- .../manage/ModuleDependencyDataService.java | 11 +- .../project/manage/ProjectDataManager.java | 6 +- .../manage/ProjectDataServiceImpl.java | 4 +- .../manage/ProjectEntityChangeListener.java | 0 .../AbstractExternalProjectImportBuilder.java | 19 +- ...AbstractExternalProjectImportProvider.java | 0 ...actImportFromExternalSystemWizardStep.java | 0 .../wizard/ExternalProjectOpenProcessor.java | 0 .../wizard/SelectExternalProjectStepBase.java | 0 .../AbstractRemoteExternalSystemService.java | 1 + ...SystemProgressNotificationManagerImpl.java | 0 .../RemoteExternalSystemBuildManager.java | 1 + .../RemoteExternalSystemBuildManagerImpl.java | 1 + ...rnalSystemProgressNotificationManager.java | 0 .../RemoteExternalSystemProjectResolver.java | 1 + ...moteExternalSystemProjectResolverImpl.java | 1 + ...actRemoteExternalSystemServiceWrapper.java | 2 +- .../ExternalSystemBuildManagerWrapper.java | 2 +- .../wrapper/ExternalSystemFacadeWrapper.java | 2 +- .../ExternalSystemProjectResolverWrapper.java | 2 +- .../AbstractExternalProjectConfigurable.java | 0 .../task/ExternalSystemTaskManager.java | 0 .../ExternalSystemSettingsManager.java | 2 +- .../util/ExternalSystemUiUtil.java | 30 - .../util/ExternalSystemUtil.java | 332 +----- .../model/ExternalSystemDataKeys.java | 38 - .../model/project/AbstractCompositeData.java | 71 -- .../CompositeLibraryDependencyData.java | 58 - .../project/ExternalEntityCloneContext.java | 44 - .../externalSystem/model/project/JarData.java | 114 -- .../model/project/LibraryDependencyData.java | 26 - .../model/project/ProjectEntityType.java | 80 -- .../AbstractConflictingPropertyChange.java | 94 -- ...bstractExternalProjectStructureChange.java | 36 - .../AbstractProjectEntityPresenceChange.java | 96 -- .../change/ContentRootPresenceChange.java | 35 - .../change/DependencyExportedChange.java | 27 - .../project/change/DependencyScopeChange.java | 31 - .../ExternalProjectStructureChange.java | 23 - ...ExternalProjectStructureChangeVisitor.java | 37 - ...lProjectStructureChangeVisitorAdapter.java | 49 - ...rnalProjectStructureChangesCalculator.java | 28 - .../change/GradleProjectRenameChange.java | 24 - .../project/change/JarPresenceChange.java | 22 - .../project/change/LanguageLevelChange.java | 38 - .../LibraryDependencyPresenceChange.java | 37 - .../ModuleDependencyPresenceChange.java | 33 - .../project/change/ModulePresenceChange.java | 50 - .../change/OutdatedLibraryVersionChange.java | 109 -- .../AbstractDependencyAwareUserChange.java | 88 -- .../AbstractDependencyExportedUserChange.java | 78 -- .../AbstractDependencyScopeUserChange.java | 92 -- .../user/AbstractModuleAwareUserChange.java | 84 -- .../user/AbstractUserProjectChange.java | 44 - .../user/AddLibraryDependencyUserChange.java | 44 - .../user/AddModuleDependencyUserChange.java | 44 - .../change/user/AddModuleUserChange.java | 45 - .../user/LibraryDependencyExportedChange.java | 47 - .../LibraryDependencyScopeUserChange.java | 48 - .../user/ModuleDependencyExportedChange.java | 47 - .../user/ModuleDependencyScopeUserChange.java | 48 - .../RemoveLibraryDependencyUserChange.java | 44 - .../RemoveModuleDependencyUserChange.java | 44 - .../change/user/RemoveModuleUserChange.java | 45 - .../change/user/UserProjectChange.java | 34 - .../change/user/UserProjectChangeVisitor.java | 36 - .../id/AbstractCompositeExternalEntityId.java | 76 -- .../id/AbstractExternalDependencyId.java | 55 - .../project/id/AbstractExternalEntityId.java | 55 - .../id/CompositeLibraryDependencyId.java | 59 - .../model/project/id/ContentRootId.java | 70 -- .../model/project/id/EntityIdMapper.java | 121 -- .../model/project/id/GradleSyntheticId.java | 40 - .../model/project/id/JarId.java | 86 -- .../model/project/id/LibraryDependencyId.java | 35 - .../model/project/id/LibraryId.java | 52 - .../model/project/id/ModuleDependencyId.java | 30 - .../model/project/id/ModuleId.java | 52 - .../model/project/id/ProjectEntityId.java | 34 - .../model/project/id/ProjectId.java | 30 - .../ProjectStructureChangesDetector.java | 214 ---- .../project/ProjectStructureHelper.java | 498 -------- .../service/project/change/AutoImporter.java | 100 -- ...ernalProjectChangesCalculationContext.java | 65 -- ...xternalProjectStructureChangeListener.java | 32 - ...lProjectStructureChangesPostProcessor.java | 53 - ...alProjectStructureChangesPreProcessor.java | 34 - .../change/MovedJarsPostProcessor.java | 226 ---- .../OutdatedLibraryVersionPostProcessor.java | 174 --- .../change/ProjectStructureChangesModel.java | 221 ---- .../user/UserProjectChangesCalculator.java | 500 -------- .../project/manage/EntityManageHelper.java | 479 -------- .../manage/GradleLocalNodeManageHelper.java | 242 ---- .../project/manage/JarDataService.java | 245 ---- .../manage/OutdatedLibraryService.java | 144 --- ...justExternalProjectImportSettingsStep.java | 346 ------ .../ExternalSystemTextAttributes.java | 64 -- .../settings/UserProjectChanges.java | 78 -- ...xternalProjectStructureNodeComparator.java | 188 --- .../ExternalProjectStructureNodeFilter.java | 12 - .../ui/ExternalProjectStructureTreeModel.java | 1013 ----------------- .../ui/ProjectStructureNode.java | 349 ------ .../ui/ProjectStructureNodeDescriptor.java | 71 -- .../src/META-INF/ExternalSystemExtensions.xml | 2 - plugins/gradle/gradle.iml | 3 +- .../plugins/gradle/GradleManager.java | 10 +- .../AbstractGradleSyncTreeFilterAction.java | 122 -- .../AbstractGradleSyncTreeNodeAction.java | 119 -- .../GradleConflictSyncTreeFilterAction.java | 14 - .../action/GradleImportEntityAction.java | 41 - .../action/GradleLinkToProjectAction.java | 44 - .../GradleLocalSyncTreeFilterAction.java | 14 - .../GradleOutdatedSyncTreeFilterAction.java | 29 - ...adleRebuildStructureChangesTreeAction.java | 27 - .../action/GradleRefreshProjectAction.java | 10 +- .../action/GradleRemoveIdeEntityAction.java | 40 - .../action/GradleResetTreeFiltersAction.java | 35 - .../GradleShowConflictDetailsAction.java | 93 -- .../gradle/action/GradleSyncAction.java | 77 -- .../IntellijLocalSyncTreeFilterAction.java | 14 - ...GradleColorAndFontDescriptorsProvider.java | 68 -- .../GradleColorAndFontPanelFactory.java | 35 - .../GradleColorAndFontPreviewPanel.java | 329 ------ .../gradle/config/GradleToolWindowPanel.java | 8 - .../plugins/gradle/diff/GradleDiffUtil.java | 207 ---- ...ContentRootStructureChangesCalculator.java | 37 - ...eDependencyStructureChangesCalculator.java | 38 - ...yDependencyStructureChangesCalculator.java | 52 - ...eDependencyStructureChangesCalculator.java | 37 - ...adleLibraryStructureChangesCalculator.java | 87 -- ...radleModuleStructureChangesCalculator.java | 132 --- ...adleProjectStructureChangesCalculator.java | 103 -- .../GradleAdjustImportSettingsUtil.java | 80 -- .../adjust/GradleContentRootSettings.java | 69 -- .../wizard/adjust/GradleJarSettings.java | 59 - .../GradleLibraryDependencySettings.java | 52 - .../wizard/adjust/GradleLibrarySettings.java | 33 - .../GradleModuleDependencySettings.java | 52 - .../wizard/adjust/GradleModuleSettings.java | 134 --- .../wizard/adjust/GradleProjectSettings.java | 271 ----- .../adjust/GradleProjectSettingsBuilder.java | 130 --- .../adjust/GradleProjectStructureFactory.java | 163 --- .../GradleProjectStructureNodeSettings.java | 39 - .../project/GradleProjectResolver.java | 13 +- .../settings/GradleProjectImportBuilder.java | 35 +- .../settings/GradleExecutionSettings.java | 2 +- .../GradleDuplicateLibrariesPreProcessor.java | 87 -- .../GradleProjectStructureChangesPanel.java | 319 ------ .../GradleProjectStructureFiltersPanel.java | 27 - ...ommonDependencyConflictControlFactory.java | 80 -- .../GradleConflictControlFactory.java | 85 -- .../GradleProjectConflictControlFactory.java | 74 -- .../gradle/ui/GradleToolWindowFactory.java | 25 +- .../plugins/gradle/util/GradleConstants.java | 3 - .../plugins/gradle/util/GradleUtil.java | 59 - .../util/TestMovedJarsPostProcessor.java | 37 - resources/src/META-INF/IdeaPlugin.xml | 2 + 230 files changed, 858 insertions(+), 12558 deletions(-) rename {platform/external-system/src/com/intellij/openapi/externalSystem/model/project => java/java-psi-impl/src/com/intellij/externalSystem}/JavaProjectData.java (89%) rename {platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage => java/java-psi-impl/src/com/intellij/externalSystem}/JavaProjectDataService.java (65%) create mode 100644 platform/external-system-api/external-system-api.iml rename platform/{external-system => external-system-api}/resources/i18n/ExternalSystemBundle.properties (100%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/ExternalSystemManager.java (98%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/build/ExternalSystemBuildManager.java (96%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/model/DataNode.java (100%) create mode 100644 platform/external-system-api/src/com/intellij/openapi/externalSystem/model/ExternalSystemDataKeys.java rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/model/ExternalSystemException.java (100%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/model/Key.java (100%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/model/ProjectKeys.java (87%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/model/ProjectSystemId.java (100%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/model/project/AbstractDependencyData.java (100%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/model/project/AbstractNamedData.java (100%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/model/project/AbstractProjectEntityData.java (98%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/model/project/ContentRootData.java (74%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/model/project/DependencyData.java (100%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/model/project/ExternalSystemSourceType.java (100%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/model/project/LibraryData.java (75%) create mode 100644 platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/LibraryDependencyData.java rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/model/project/LibraryPathType.java (100%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/model/project/ModuleData.java (78%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/model/project/ModuleDependencyData.java (62%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/model/project/Named.java (100%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/model/project/ProjectData.java (68%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/model/project/ProjectEntityData.java (73%) rename platform/{external-system/src/com/intellij/openapi/externalSystem/service/remote => external-system-api/src/com/intellij/openapi/externalSystem/model/settings}/ExternalSystemExecutionSettings.java (98%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTask.java (100%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskDescriptor.java (100%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskId.java (100%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskNotificationEvent.java (100%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskNotificationListener.java (100%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskNotificationListenerAdapter.java (100%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskState.java (100%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskType.java (100%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/service/ParametersEnhancer.java (100%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/service/project/ExternalLibraryPathTypeMapper.java (87%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/service/project/ExternalSystemProjectResolver.java (97%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/service/project/ModuleAwareContentRoot.java (100%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/service/project/PlatformFacade.java (94%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataService.java (100%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/settings/AbstractExternalSystemLocalSettings.java (100%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/settings/AbstractExternalSystemSettings.java (100%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/settings/ExternalSystemSettingsListener.java (100%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/util/ArtifactInfo.java (100%) create mode 100644 platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemApiUtil.java rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/util/ExternalSystemBundle.java (100%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/util/ExternalSystemConstants.java (100%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/util/IdeEntityVisitor.java (100%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/util/IntegrationKey.java (100%) rename platform/{external-system => external-system-api}/src/com/intellij/openapi/externalSystem/util/Order.java (100%) rename platform/{external-system/external-system.iml => external-system-impl/external-system-impl.iml} (73%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/model/settings/LocationSettingType.java (87%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/model/task/AbstractExternalSystemTask.java (96%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemResolveProjectTask.java (77%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskAware.java (100%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/DisposableExternalSystemService.java (100%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/ExternalSystemFacadeImpl.java (99%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/ExternalSystemFacadeManager.java (97%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/RemoteExternalSystemFacade.java (98%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/RemoteExternalSystemService.java (95%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/notification/ExternalSystemProgressNotificationManager.java (100%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/project/ExternalLibraryPathTypeMapperImpl.java (100%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/project/PlatformFacadeImpl.java (86%) create mode 100644 platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/ProjectStructureHelper.java rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/project/ProjectStructureServices.java (76%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/project/manage/AbstractDependencyDataService.java (90%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/project/manage/ContentRootDataService.java (93%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDataService.java (84%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDependencyDataService.java (91%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDataService.java (96%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDependencyDataService.java (93%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataManager.java (96%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataServiceImpl.java (92%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectEntityChangeListener.java (100%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalProjectImportBuilder.java (94%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalProjectImportProvider.java (100%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractImportFromExternalSystemWizardStep.java (100%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/project/wizard/ExternalProjectOpenProcessor.java (100%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/project/wizard/SelectExternalProjectStepBase.java (100%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/remote/AbstractRemoteExternalSystemService.java (97%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/remote/ExternalSystemProgressNotificationManagerImpl.java (100%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemBuildManager.java (97%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemBuildManagerImpl.java (96%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemProgressNotificationManager.java (100%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemProjectResolver.java (97%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemProjectResolverImpl.java (95%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/remote/wrapper/AbstractRemoteExternalSystemServiceWrapper.java (97%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/remote/wrapper/ExternalSystemBuildManagerWrapper.java (97%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/remote/wrapper/ExternalSystemFacadeWrapper.java (97%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/remote/wrapper/ExternalSystemProjectResolverWrapper.java (97%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalProjectConfigurable.java (100%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/service/task/ExternalSystemTaskManager.java (100%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/settings/ExternalSystemSettingsManager.java (98%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/util/ExternalSystemUiUtil.java (59%) rename platform/{external-system => external-system-impl}/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java (55%) delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/ExternalSystemDataKeys.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/AbstractCompositeData.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/CompositeLibraryDependencyData.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/ExternalEntityCloneContext.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/JarData.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/LibraryDependencyData.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/ProjectEntityType.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/AbstractConflictingPropertyChange.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/AbstractExternalProjectStructureChange.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/AbstractProjectEntityPresenceChange.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/ContentRootPresenceChange.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/DependencyExportedChange.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/DependencyScopeChange.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/ExternalProjectStructureChange.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/ExternalProjectStructureChangeVisitor.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/ExternalProjectStructureChangeVisitorAdapter.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/ExternalProjectStructureChangesCalculator.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/GradleProjectRenameChange.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/JarPresenceChange.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/LanguageLevelChange.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/LibraryDependencyPresenceChange.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/ModuleDependencyPresenceChange.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/ModulePresenceChange.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/OutdatedLibraryVersionChange.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/AbstractDependencyAwareUserChange.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/AbstractDependencyExportedUserChange.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/AbstractDependencyScopeUserChange.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/AbstractModuleAwareUserChange.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/AbstractUserProjectChange.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/AddLibraryDependencyUserChange.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/AddModuleDependencyUserChange.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/AddModuleUserChange.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/LibraryDependencyExportedChange.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/LibraryDependencyScopeUserChange.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/ModuleDependencyExportedChange.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/ModuleDependencyScopeUserChange.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/RemoveLibraryDependencyUserChange.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/RemoveModuleDependencyUserChange.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/RemoveModuleUserChange.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/UserProjectChange.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/UserProjectChangeVisitor.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/AbstractCompositeExternalEntityId.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/AbstractExternalDependencyId.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/AbstractExternalEntityId.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/CompositeLibraryDependencyId.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/ContentRootId.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/EntityIdMapper.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/GradleSyntheticId.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/JarId.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/LibraryDependencyId.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/LibraryId.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/ModuleDependencyId.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/ModuleId.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/ProjectEntityId.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/ProjectId.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/service/project/ProjectStructureChangesDetector.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/service/project/ProjectStructureHelper.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/AutoImporter.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/ExternalProjectChangesCalculationContext.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/ExternalProjectStructureChangeListener.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/ExternalProjectStructureChangesPostProcessor.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/ExternalProjectStructureChangesPreProcessor.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/MovedJarsPostProcessor.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/OutdatedLibraryVersionPostProcessor.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/ProjectStructureChangesModel.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/user/UserProjectChangesCalculator.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/EntityManageHelper.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/GradleLocalNodeManageHelper.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/JarDataService.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/OutdatedLibraryService.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/service/project/wizard/AdjustExternalProjectImportSettingsStep.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/settings/ExternalSystemTextAttributes.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/settings/UserProjectChanges.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/ui/ExternalProjectStructureNodeComparator.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/ui/ExternalProjectStructureNodeFilter.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/ui/ExternalProjectStructureTreeModel.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/ui/ProjectStructureNode.java delete mode 100644 platform/external-system/src/com/intellij/openapi/externalSystem/ui/ProjectStructureNodeDescriptor.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/action/AbstractGradleSyncTreeFilterAction.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/action/AbstractGradleSyncTreeNodeAction.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleConflictSyncTreeFilterAction.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleImportEntityAction.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleLinkToProjectAction.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleLocalSyncTreeFilterAction.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleOutdatedSyncTreeFilterAction.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleRebuildStructureChangesTreeAction.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleRemoveIdeEntityAction.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleResetTreeFiltersAction.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleShowConflictDetailsAction.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleSyncAction.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/action/IntellijLocalSyncTreeFilterAction.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorAndFontDescriptorsProvider.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorAndFontPanelFactory.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorAndFontPreviewPanel.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/diff/GradleDiffUtil.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/diff/contentroot/GradleContentRootStructureChangesCalculator.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/diff/dependency/AbstractGradleDependencyStructureChangesCalculator.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/diff/dependency/GradleLibraryDependencyStructureChangesCalculator.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/diff/dependency/GradleModuleDependencyStructureChangesCalculator.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/diff/library/GradleLibraryStructureChangesCalculator.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/diff/module/GradleModuleStructureChangesCalculator.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/diff/project/GradleProjectStructureChangesCalculator.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleAdjustImportSettingsUtil.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleContentRootSettings.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleJarSettings.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleLibraryDependencySettings.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleLibrarySettings.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleModuleDependencySettings.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleModuleSettings.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleProjectSettings.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleProjectSettingsBuilder.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleProjectStructureFactory.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleProjectStructureNodeSettings.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/sync/GradleDuplicateLibrariesPreProcessor.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/sync/GradleProjectStructureChangesPanel.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/sync/GradleProjectStructureFiltersPanel.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/sync/conflict/GradleCommonDependencyConflictControlFactory.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/sync/conflict/GradleConflictControlFactory.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/sync/conflict/GradleProjectConflictControlFactory.java delete mode 100644 plugins/gradle/testSources/org/jetbrains/plugins/gradle/util/TestMovedJarsPostProcessor.java diff --git a/build/scripts/utils.gant b/build/scripts/utils.gant index 0befbcc14ef4..9200ecdc4b0b 100644 --- a/build/scripts/utils.gant +++ b/build/scripts/utils.gant @@ -254,6 +254,7 @@ binding.setVariable("platformApiModules", [ "usageView", "xdebugger-api", "xml-openapi", + "external-system-api", ]) @@ -276,7 +277,7 @@ binding.setVariable("platformImplementationModules", [ "images", "RegExpSupport", "dvcs", - "external-system" + "external-system-impl" ]) binding.setVariable("layoutMacApp", { String path, String ch, Map args -> diff --git a/java/java-psi-impl/java-psi-impl.iml b/java/java-psi-impl/java-psi-impl.iml index 89e9dba328f0..8fa9e62eb8d9 100644 --- a/java/java-psi-impl/java-psi-impl.iml +++ b/java/java-psi-impl/java-psi-impl.iml @@ -11,6 +11,8 @@ + + diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/JavaProjectData.java b/java/java-psi-impl/src/com/intellij/externalSystem/JavaProjectData.java similarity index 89% rename from platform/external-system/src/com/intellij/openapi/externalSystem/model/project/JavaProjectData.java rename to java/java-psi-impl/src/com/intellij/externalSystem/JavaProjectData.java index fc0cae1d2e13..d1f5bfa9503a 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/JavaProjectData.java +++ b/java/java-psi-impl/src/com/intellij/externalSystem/JavaProjectData.java @@ -13,14 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.intellij.openapi.externalSystem.model.project; +package com.intellij.externalSystem; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.externalSystem.model.DataNode; +import com.intellij.openapi.externalSystem.model.Key; import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.id.ProjectEntityId; -import com.intellij.openapi.externalSystem.model.project.id.ProjectId; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; +import com.intellij.openapi.externalSystem.model.project.AbstractProjectEntityData; +import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil; import com.intellij.openapi.projectRoots.JavaSdkVersion; import com.intellij.pom.java.LanguageLevel; import org.jetbrains.annotations.NotNull; @@ -34,7 +33,9 @@ import java.util.regex.Pattern; * @since 4/12/13 12:27 PM */ public class JavaProjectData extends AbstractProjectEntityData { - + + @NotNull public static final Key KEY = Key.create(JavaProjectData.class); + private static final Logger LOG = Logger.getInstance("#" + JavaProjectData.class.getName()); private static final long serialVersionUID = 1L; @@ -53,19 +54,13 @@ public class JavaProjectData extends AbstractProjectEntityData { myCompileOutputPath = compileOutputPath; } - @NotNull - @Override - public ProjectEntityId getId(@Nullable DataNode dataNode) { - return new ProjectId(getOwner()); - } - @NotNull public String getCompileOutputPath() { return myCompileOutputPath; } public void setCompileOutputPath(@NotNull String compileOutputPath) { - myCompileOutputPath = ExternalSystemUtil.toCanonicalPath(compileOutputPath); + myCompileOutputPath = ExternalSystemApiUtil.toCanonicalPath(compileOutputPath); } @NotNull diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/JavaProjectDataService.java b/java/java-psi-impl/src/com/intellij/externalSystem/JavaProjectDataService.java similarity index 65% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/JavaProjectDataService.java rename to java/java-psi-impl/src/com/intellij/externalSystem/JavaProjectDataService.java index d8d2c44cce28..05132a8b7734 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/JavaProjectDataService.java +++ b/java/java-psi-impl/src/com/intellij/externalSystem/JavaProjectDataService.java @@ -13,25 +13,26 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.intellij.openapi.externalSystem.service.project.manage; +package com.intellij.externalSystem; -import com.intellij.ide.impl.NewProjectUtil; import com.intellij.openapi.externalSystem.model.DataNode; import com.intellij.openapi.externalSystem.model.Key; -import com.intellij.openapi.externalSystem.model.ProjectKeys; import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.JavaProjectData; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; +import com.intellij.openapi.externalSystem.service.project.manage.ProjectDataService; +import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil; import com.intellij.openapi.project.Project; import com.intellij.openapi.projectRoots.JavaSdk; import com.intellij.openapi.projectRoots.JavaSdkVersion; +import com.intellij.openapi.projectRoots.ProjectJdkTable; import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.roots.LanguageLevelProjectExtension; -import com.intellij.openapi.roots.ex.ProjectRootManagerEx; +import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.pom.java.LanguageLevel; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.Collection; +import java.util.List; /** * @author Denis Zhdanov @@ -42,7 +43,7 @@ public class JavaProjectDataService implements ProjectDataService getTargetDataKey() { - return ProjectKeys.JAVA_PROJECT; + return JavaProjectData.KEY; } @Override @@ -55,13 +56,19 @@ public class JavaProjectDataService implements ProjectDataService javaSdks = ProjectJdkTable.getInstance().getSdksOfType(javaSdk); + Sdk candidate = null; + for (Sdk sdk : javaSdks) { + JavaSdkVersion v = javaSdk.getVersion(sdk); + if (v == version) { + return sdk; + } + else if (candidate == null && v != null && version.getMaxLanguageLevel().isAtLeast(version.getMaxLanguageLevel())) { + candidate = sdk; + } + } + return candidate; + } + @Override public void removeData(@NotNull Collection> toRemove, @NotNull Project project, boolean synchronous) { } @@ -79,12 +103,12 @@ public class JavaProjectDataService implements ProjectDataService + + + + + + + + + + + + + + + + + diff --git a/platform/external-system/resources/i18n/ExternalSystemBundle.properties b/platform/external-system-api/resources/i18n/ExternalSystemBundle.properties similarity index 100% rename from platform/external-system/resources/i18n/ExternalSystemBundle.properties rename to platform/external-system-api/resources/i18n/ExternalSystemBundle.properties diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/ExternalSystemManager.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/ExternalSystemManager.java similarity index 98% rename from platform/external-system/src/com/intellij/openapi/externalSystem/ExternalSystemManager.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/ExternalSystemManager.java index 86cec31f9af5..84eb746a7783 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/ExternalSystemManager.java +++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/ExternalSystemManager.java @@ -3,9 +3,9 @@ package com.intellij.openapi.externalSystem; import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.openapi.externalSystem.build.ExternalSystemBuildManager; import com.intellij.openapi.externalSystem.model.ProjectSystemId; +import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings; import com.intellij.openapi.externalSystem.service.ParametersEnhancer; import com.intellij.openapi.externalSystem.service.project.ExternalSystemProjectResolver; -import com.intellij.openapi.externalSystem.service.remote.ExternalSystemExecutionSettings; import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemLocalSettings; import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings; import com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsListener; diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/build/ExternalSystemBuildManager.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/build/ExternalSystemBuildManager.java similarity index 96% rename from platform/external-system/src/com/intellij/openapi/externalSystem/build/ExternalSystemBuildManager.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/build/ExternalSystemBuildManager.java index e53b2c062fea..8b7b5a1775f5 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/build/ExternalSystemBuildManager.java +++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/build/ExternalSystemBuildManager.java @@ -18,7 +18,7 @@ package com.intellij.openapi.externalSystem.build; import com.intellij.openapi.externalSystem.model.ExternalSystemException; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskDescriptor; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId; -import com.intellij.openapi.externalSystem.service.remote.ExternalSystemExecutionSettings; +import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/DataNode.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/DataNode.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/model/DataNode.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/model/DataNode.java diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/ExternalSystemDataKeys.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/ExternalSystemDataKeys.java new file mode 100644 index 000000000000..a8c4742c3b32 --- /dev/null +++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/ExternalSystemDataKeys.java @@ -0,0 +1,17 @@ +package com.intellij.openapi.externalSystem.model; + +/** + * @author Denis Zhdanov + * @since 2/7/12 11:19 AM + */ +public class ExternalSystemDataKeys { + + // TODO den uncomment + +// public static final DataKey RECENT_TASKS_LIST = DataKey.create("gradle.recent.tasks.list"); + +// public static final DataKey ALL_TASKS_MODEL = DataKey.create("gradle.all.tasks.model"); + + private ExternalSystemDataKeys() { + } +} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/ExternalSystemException.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/ExternalSystemException.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/model/ExternalSystemException.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/model/ExternalSystemException.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/Key.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/Key.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/model/Key.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/model/Key.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/ProjectKeys.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/ProjectKeys.java similarity index 87% rename from platform/external-system/src/com/intellij/openapi/externalSystem/model/ProjectKeys.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/model/ProjectKeys.java index 7d8a9b1280a8..f18da33ffbce 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/ProjectKeys.java +++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/ProjectKeys.java @@ -27,13 +27,11 @@ import org.jetbrains.annotations.NotNull; public class ProjectKeys { @NotNull public static final Key PROJECT = Key.create(ProjectData.class); - @NotNull public static final Key JAVA_PROJECT = Key.create(JavaProjectData.class); @NotNull public static final Key MODULE = Key.create(ModuleData.class); @NotNull public static final Key LIBRARY = Key.create(LibraryData.class); @NotNull public static final Key CONTENT_ROOT = Key.create(ContentRootData.class); @NotNull public static final Key MODULE_DEPENDENCY = Key.create(ModuleDependencyData.class); @NotNull public static final Key LIBRARY_DEPENDENCY = Key.create(LibraryDependencyData.class); - @NotNull public static final Key JAR = Key.create(JarData.class); private ProjectKeys() { } diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/ProjectSystemId.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/ProjectSystemId.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/model/ProjectSystemId.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/model/ProjectSystemId.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/AbstractDependencyData.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/AbstractDependencyData.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/model/project/AbstractDependencyData.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/AbstractDependencyData.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/AbstractNamedData.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/AbstractNamedData.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/model/project/AbstractNamedData.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/AbstractNamedData.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/AbstractProjectEntityData.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/AbstractProjectEntityData.java similarity index 98% rename from platform/external-system/src/com/intellij/openapi/externalSystem/model/project/AbstractProjectEntityData.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/AbstractProjectEntityData.java index 2c1f980e20ba..c3b15813abb3 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/AbstractProjectEntityData.java +++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/AbstractProjectEntityData.java @@ -7,7 +7,6 @@ import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.io.IOException; import java.io.ObjectInputStream; -import java.io.Serializable; /** * @author Denis Zhdanov diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/ContentRootData.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ContentRootData.java similarity index 74% rename from platform/external-system/src/com/intellij/openapi/externalSystem/model/project/ContentRootData.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ContentRootData.java index 6bfbe45e545f..391f12316610 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/ContentRootData.java +++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ContentRootData.java @@ -1,14 +1,10 @@ package com.intellij.openapi.externalSystem.model.project; -import com.intellij.openapi.externalSystem.model.DataNode; -import com.intellij.openapi.externalSystem.model.ProjectKeys; import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.id.ContentRootId; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; +import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil; import com.intellij.openapi.util.io.FileUtil; import com.intellij.util.containers.ContainerUtilRt; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import java.io.File; import java.util.Collection; @@ -34,22 +30,7 @@ public class ContentRootData extends AbstractProjectEntityData { */ public ContentRootData(@NotNull ProjectSystemId owner, @NotNull String rootPath) { super(owner); - myRootPath = ExternalSystemUtil.toCanonicalPath(rootPath); - } - - @NotNull - @Override - public ContentRootId getId(@Nullable DataNode dataNode) { - if (dataNode == null) { - throw new IllegalArgumentException(String.format("Can't build id for %s. Reason: given data holder is undefined", this)); - } - ModuleData moduleData = dataNode.getData(ProjectKeys.MODULE); - if (moduleData == null) { - throw new IllegalArgumentException(String.format( - "Can't build id for %s. Reason: given data holder doesn't contain information about owner module", this - )); - } - return new ContentRootId(getOwner(), moduleData.getName(), getRootPath()); + myRootPath = ExternalSystemApiUtil.toCanonicalPath(rootPath); } /** @@ -76,7 +57,7 @@ public class ContentRootData extends AbstractProjectEntityData { if (paths == null) { myData.put(type, paths = ContainerUtilRt.newHashSet()); } - paths.add(ExternalSystemUtil.toCanonicalPath(path)); + paths.add(ExternalSystemApiUtil.toCanonicalPath(path)); return; } if (!ExternalSystemSourceType.EXCLUDED.equals(type)) { // There are external systems which mark output directory as 'excluded' path. diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/DependencyData.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/DependencyData.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/model/project/DependencyData.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/DependencyData.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/ExternalSystemSourceType.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ExternalSystemSourceType.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/model/project/ExternalSystemSourceType.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ExternalSystemSourceType.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/LibraryData.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/LibraryData.java similarity index 75% rename from platform/external-system/src/com/intellij/openapi/externalSystem/model/project/LibraryData.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/LibraryData.java index 81bd417c8c24..c2975e8ed605 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/LibraryData.java +++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/LibraryData.java @@ -1,13 +1,9 @@ package com.intellij.openapi.externalSystem.model.project; -import com.intellij.openapi.externalSystem.model.DataNode; import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.id.LibraryId; -import com.intellij.openapi.externalSystem.model.project.id.ProjectEntityId; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; +import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil; import com.intellij.util.containers.HashMap; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import java.util.Collections; import java.util.HashSet; @@ -30,12 +26,6 @@ public class LibraryData extends AbstractNamedData implements Named { super(owner, name); } - @NotNull - @Override - public ProjectEntityId getId(@Nullable DataNode dataNode) { - return new LibraryId(getOwner(), getName()); - } - @NotNull public Set getPaths(@NotNull LibraryPathType type) { Set result = myPaths.get(type); @@ -47,7 +37,7 @@ public class LibraryData extends AbstractNamedData implements Named { if (paths == null) { myPaths.put(type, paths = new HashSet()); } - paths.add(ExternalSystemUtil.toCanonicalPath(path)); + paths.add(ExternalSystemApiUtil.toCanonicalPath(path)); } public void forgetAllPaths() { diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/LibraryDependencyData.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/LibraryDependencyData.java new file mode 100644 index 000000000000..6a22185337cb --- /dev/null +++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/LibraryDependencyData.java @@ -0,0 +1,16 @@ +package com.intellij.openapi.externalSystem.model.project; + +import org.jetbrains.annotations.NotNull; + +/** + * Not thread-safe. + * + * @author Denis Zhdanov + * @since 8/10/11 6:46 PM + */ +public class LibraryDependencyData extends AbstractDependencyData implements Named { + + public LibraryDependencyData(@NotNull ModuleData ownerModule, @NotNull LibraryData library) { + super(ownerModule, library); + } +} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/LibraryPathType.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/LibraryPathType.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/model/project/LibraryPathType.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/LibraryPathType.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/ModuleData.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ModuleData.java similarity index 78% rename from platform/external-system/src/com/intellij/openapi/externalSystem/model/project/ModuleData.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ModuleData.java index b460cc5743fb..d1467cab1d59 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/ModuleData.java +++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ModuleData.java @@ -1,11 +1,8 @@ package com.intellij.openapi.externalSystem.model.project; import com.intellij.ide.highlighter.ModuleFileType; -import com.intellij.openapi.externalSystem.model.DataNode; import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.id.ModuleId; -import com.intellij.openapi.externalSystem.model.project.id.ProjectEntityId; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; +import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil; import com.intellij.util.containers.ContainerUtilRt; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -30,19 +27,13 @@ public class ModuleData extends AbstractNamedData implements Named { setModuleFileDirectoryPath(moduleFileDirectoryPath); } - @NotNull - @Override - public ProjectEntityId getId(@Nullable DataNode dataNode) { - return new ModuleId(getOwner(), getName()); - } - @NotNull public String getModuleFilePath() { return myModuleFilePath; } public void setModuleFileDirectoryPath(@NotNull String path) { - myModuleFilePath = ExternalSystemUtil.toCanonicalPath(path + "/" + getName() + ModuleFileType.DOT_DEFAULT_EXTENSION); + myModuleFilePath = ExternalSystemApiUtil.toCanonicalPath(path + "/" + getName() + ModuleFileType.DOT_DEFAULT_EXTENSION); } public boolean isInheritProjectCompileOutputPath() { @@ -71,7 +62,7 @@ public class ModuleData extends AbstractNamedData implements Named { myCompileOutputPaths.remove(type); return; } - myCompileOutputPaths.put(type, ExternalSystemUtil.toCanonicalPath(path)); + myCompileOutputPaths.put(type, ExternalSystemApiUtil.toCanonicalPath(path)); } diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/ModuleDependencyData.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ModuleDependencyData.java similarity index 62% rename from platform/external-system/src/com/intellij/openapi/externalSystem/model/project/ModuleDependencyData.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ModuleDependencyData.java index 305438802600..3da5e8ddfc4c 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/ModuleDependencyData.java +++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ModuleDependencyData.java @@ -1,10 +1,6 @@ package com.intellij.openapi.externalSystem.model.project; -import com.intellij.openapi.externalSystem.model.DataNode; -import com.intellij.openapi.externalSystem.model.project.id.ModuleDependencyId; -import com.intellij.openapi.externalSystem.model.project.id.ProjectEntityId; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import java.util.Comparator; @@ -26,10 +22,4 @@ public class ModuleDependencyData extends AbstractDependencyData { public ModuleDependencyData(@NotNull ModuleData ownerModule, @NotNull ModuleData module) { super(ownerModule, module); } - - @NotNull - @Override - public ProjectEntityId getId(@Nullable DataNode dataNode) { - return new ModuleDependencyId(getOwner(), getOwnerModule().getName(), getName()); - } } diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/Named.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/Named.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/model/project/Named.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/Named.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/ProjectData.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ProjectData.java similarity index 68% rename from platform/external-system/src/com/intellij/openapi/externalSystem/model/project/ProjectData.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ProjectData.java index 2e88624b0abf..bd10e169a481 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/ProjectData.java +++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ProjectData.java @@ -1,12 +1,8 @@ package com.intellij.openapi.externalSystem.model.project; -import com.intellij.openapi.externalSystem.model.DataNode; import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.id.ProjectEntityId; -import com.intellij.openapi.externalSystem.model.project.id.ProjectId; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; +import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; /** * Not thread-safe. @@ -24,13 +20,7 @@ public class ProjectData extends AbstractNamedData { @NotNull String projectFileDirectoryPath) { super(owner, "unnamed"); - myProjectFileDirectoryPath = ExternalSystemUtil.toCanonicalPath(projectFileDirectoryPath); - } - - @NotNull - @Override - public ProjectEntityId getId(@Nullable DataNode dataNode) { - return new ProjectId(getOwner()); + myProjectFileDirectoryPath = ExternalSystemApiUtil.toCanonicalPath(projectFileDirectoryPath); } @NotNull @@ -39,7 +29,7 @@ public class ProjectData extends AbstractNamedData { } public void setProjectFileDirectoryPath(@NotNull String projectFileDirectoryPath) { - myProjectFileDirectoryPath = ExternalSystemUtil.toCanonicalPath(projectFileDirectoryPath); + myProjectFileDirectoryPath = ExternalSystemApiUtil.toCanonicalPath(projectFileDirectoryPath); } @Override diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/ProjectEntityData.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ProjectEntityData.java similarity index 73% rename from platform/external-system/src/com/intellij/openapi/externalSystem/model/project/ProjectEntityData.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ProjectEntityData.java index 65cd93af1f54..bd42a60ac872 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/ProjectEntityData.java +++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ProjectEntityData.java @@ -1,10 +1,7 @@ package com.intellij.openapi.externalSystem.model.project; -import com.intellij.openapi.externalSystem.model.DataNode; import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.id.ProjectEntityId; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; @@ -26,15 +23,6 @@ public interface ProjectEntityData extends Serializable { @NotNull ProjectSystemId getOwner(); - /** - * Allows to map current data to its id. - * - * @param dataNode data holder which holds current data (if any) - * @return current data id - */ - @NotNull - ProjectEntityId getId(@Nullable DataNode dataNode); - /** * Follows contract of {@link PropertyChangeSupport#addPropertyChangeListener(PropertyChangeListener)} * diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/ExternalSystemExecutionSettings.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/settings/ExternalSystemExecutionSettings.java similarity index 98% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/ExternalSystemExecutionSettings.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/model/settings/ExternalSystemExecutionSettings.java index 6eaef4555a65..d8376e508be5 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/ExternalSystemExecutionSettings.java +++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/settings/ExternalSystemExecutionSettings.java @@ -1,4 +1,4 @@ -package com.intellij.openapi.externalSystem.service.remote; +package com.intellij.openapi.externalSystem.model.settings; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListener; import com.intellij.util.SystemProperties; diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTask.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTask.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTask.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTask.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskDescriptor.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskDescriptor.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskDescriptor.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskDescriptor.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskId.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskId.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskId.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskId.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskNotificationEvent.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskNotificationEvent.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskNotificationEvent.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskNotificationEvent.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskNotificationListener.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskNotificationListener.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskNotificationListener.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskNotificationListener.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskNotificationListenerAdapter.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskNotificationListenerAdapter.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskNotificationListenerAdapter.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskNotificationListenerAdapter.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskState.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskState.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskState.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskState.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskType.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskType.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskType.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskType.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/ParametersEnhancer.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/service/ParametersEnhancer.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/ParametersEnhancer.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/service/ParametersEnhancer.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/ExternalLibraryPathTypeMapper.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/service/project/ExternalLibraryPathTypeMapper.java similarity index 87% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/project/ExternalLibraryPathTypeMapper.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/service/project/ExternalLibraryPathTypeMapper.java index 844e33dad1d1..ee24b47dd434 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/ExternalLibraryPathTypeMapper.java +++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/service/project/ExternalLibraryPathTypeMapper.java @@ -15,15 +15,14 @@ */ package com.intellij.openapi.externalSystem.service.project; -import com.intellij.openapi.roots.JavadocOrderRootType; +import com.intellij.openapi.externalSystem.model.project.LibraryPathType; import com.intellij.openapi.roots.OrderRootType; import org.jetbrains.annotations.NotNull; -import com.intellij.openapi.externalSystem.model.project.LibraryPathType; /** * Strategy for mapping {@link LibraryPathType external library path types} to {@link OrderRootType ide library path types}. *

- * Is introduced because {@link JavadocOrderRootType#getInstance() 'real ide doc type'} assumes that project IoC is setup thus + * Is introduced because 'JavadocOrderRootType.getInstance()' assumes that project IoC is setup thus * make it ineligible for unit testing. *

* Implementations of this interface are expected to be thread-safe. diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/ExternalSystemProjectResolver.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/service/project/ExternalSystemProjectResolver.java similarity index 97% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/project/ExternalSystemProjectResolver.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/service/project/ExternalSystemProjectResolver.java index aeeb05652e3a..18753d475801 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/ExternalSystemProjectResolver.java +++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/service/project/ExternalSystemProjectResolver.java @@ -18,8 +18,8 @@ package com.intellij.openapi.externalSystem.service.project; import com.intellij.openapi.externalSystem.model.DataNode; import com.intellij.openapi.externalSystem.model.ExternalSystemException; import com.intellij.openapi.externalSystem.model.project.ProjectData; +import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId; -import com.intellij.openapi.externalSystem.service.remote.ExternalSystemExecutionSettings; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/ModuleAwareContentRoot.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/service/project/ModuleAwareContentRoot.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/project/ModuleAwareContentRoot.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/service/project/ModuleAwareContentRoot.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/PlatformFacade.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/service/project/PlatformFacade.java similarity index 94% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/project/PlatformFacade.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/service/project/PlatformFacade.java index 37b1016f706f..404c2091b8a4 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/PlatformFacade.java +++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/service/project/PlatformFacade.java @@ -5,7 +5,6 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.OrderEntry; import com.intellij.openapi.roots.libraries.LibraryTable; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.pom.java.LanguageLevel; import org.jetbrains.annotations.NotNull; import java.util.Collection; @@ -31,9 +30,6 @@ public interface PlatformFacade { @NotNull LibraryTable getProjectLibraryTable(@NotNull Project project); - @NotNull - LanguageLevel getLanguageLevel(@NotNull Project project); - @NotNull Collection getModules(@NotNull Project project); diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataService.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataService.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataService.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataService.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/settings/AbstractExternalSystemLocalSettings.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/settings/AbstractExternalSystemLocalSettings.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/settings/AbstractExternalSystemLocalSettings.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/settings/AbstractExternalSystemLocalSettings.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/settings/AbstractExternalSystemSettings.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/settings/AbstractExternalSystemSettings.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/settings/AbstractExternalSystemSettings.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/settings/AbstractExternalSystemSettings.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/settings/ExternalSystemSettingsListener.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/settings/ExternalSystemSettingsListener.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/settings/ExternalSystemSettingsListener.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/settings/ExternalSystemSettingsListener.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/util/ArtifactInfo.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ArtifactInfo.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/util/ArtifactInfo.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ArtifactInfo.java diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemApiUtil.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemApiUtil.java new file mode 100644 index 000000000000..b7f3161c80d8 --- /dev/null +++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemApiUtil.java @@ -0,0 +1,333 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.externalSystem.util; + +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.externalSystem.ExternalSystemManager; +import com.intellij.openapi.externalSystem.model.DataNode; +import com.intellij.openapi.externalSystem.model.Key; +import com.intellij.openapi.externalSystem.model.ProjectSystemId; +import com.intellij.openapi.fileTypes.FileTypes; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.roots.OrderRootType; +import com.intellij.openapi.roots.libraries.Library; +import com.intellij.openapi.util.AtomicNotNullLazyValue; +import com.intellij.openapi.util.NotNullLazyValue; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.vfs.JarFileSystem; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.util.BooleanFunction; +import com.intellij.util.PathUtil; +import com.intellij.util.containers.ContainerUtilRt; +import com.intellij.util.ui.UIUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.io.File; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author Denis Zhdanov + * @since 4/1/13 1:31 PM + */ +public class ExternalSystemApiUtil { + + private static final Logger LOG = Logger.getInstance("#" + ExternalSystemApiUtil.class.getName()); + + @NotNull public static final String PATH_SEPARATOR = "/"; + + @NotNull private static final Pattern ARTIFACT_PATTERN = Pattern.compile("(?:.*/)?(.+?)(?:-([\\d+](?:\\.[\\d]+)*))?(?:\\.[^\\.]+?)?"); + + @NotNull private static final NotNullLazyValue>> MANAGERS = + new AtomicNotNullLazyValue>>() { + @NotNull + @Override + protected Map> compute() { + Map> result = ContainerUtilRt.newHashMap(); + for (ExternalSystemManager manager : ExternalSystemManager.EP_NAME.getExtensions()) { + result.put(manager.getSystemId(), manager); + } + return result; + } + }; + + @NotNull public static final Comparator ORDER_AWARE_COMPARATOR = new Comparator() { + @Override + public int compare(Object o1, Object o2) { + int order1 = getOrder(o1); + int order2 = getOrder(o2); + return order1 > order2 ? 1 : order1 < order2 ? -1 : 0; + } + + private int getOrder(@NotNull Object o) { + Queue> toCheck = new ArrayDeque>(); + toCheck.add(o.getClass()); + while (!toCheck.isEmpty()) { + Class clazz = toCheck.poll(); + Order annotation = clazz.getAnnotation(Order.class); + if (annotation != null) { + return annotation.value(); + } + toCheck.add(clazz.getSuperclass()); + Class[] interfaces = clazz.getInterfaces(); + if (interfaces != null) { + Collections.addAll(toCheck, interfaces); + } + } + return ExternalSystemConstants.UNORDERED; + } + }; + + + private ExternalSystemApiUtil() { + } + + @NotNull + public static String extractNameFromPath(@NotNull String path) { + String strippedPath = stripPath(path); + final int i = strippedPath.lastIndexOf(PATH_SEPARATOR); + final String result; + if (i < 0 || i >= strippedPath.length() - 1) { + result = strippedPath; + } + else { + result = strippedPath.substring(i + 1); + } + return result; + } + + @NotNull + private static String stripPath(@NotNull String path) { + String[] endingsToStrip = {"/", "!", ".jar"}; + StringBuilder buffer = new StringBuilder(path); + for (String ending : endingsToStrip) { + if (buffer.lastIndexOf(ending) == buffer.length() - ending.length()) { + buffer.setLength(buffer.length() - ending.length()); + } + } + return buffer.toString(); + } + + @NotNull + public static String getLibraryName(@NotNull Library library) { + final String result = library.getName(); + if (result != null) { + return result; + } + for (OrderRootType type : OrderRootType.getAllTypes()) { + for (String url : library.getUrls(type)) { + String candidate = extractNameFromPath(url); + if (!StringUtil.isEmpty(candidate)) { + return candidate; + } + } + } + assert false; + return "unknown-lib"; + } + + @Nullable + public static ArtifactInfo parseArtifactInfo(@NotNull String fileName) { + Matcher matcher = ARTIFACT_PATTERN.matcher(fileName); + if (!matcher.matches()) { + return null; + } + return new ArtifactInfo(matcher.group(1), null, matcher.group(2)); + } + + public static void orderAwareSort(@NotNull List data) { + Collections.sort(data, ORDER_AWARE_COMPARATOR); + } + + /** + * @param path target path + * @return absolute path that points to the same location as the given one and that uses only slashes + */ + @NotNull + public static String toCanonicalPath(@NotNull String path) { + return PathUtil.getCanonicalPath(new File(path).getAbsolutePath()); + } + + @NotNull + public static String getLocalFileSystemPath(@NotNull VirtualFile file) { + if (file.getFileType() == FileTypes.ARCHIVE) { + final VirtualFile jar = JarFileSystem.getInstance().getVirtualFileForJar(file); + if (jar != null) { + return jar.getPath(); + } + } + return file.getPath(); + } + + @Nullable + public static ExternalSystemManager getManager(@NotNull ProjectSystemId externalSystemId) { + return MANAGERS.getValue().get(externalSystemId); + } + + @NotNull + public static Map, Collection>> group(@NotNull Collection> nodes) { + if (nodes.isEmpty()) { + return Collections.emptyMap(); + } + Map, Collection>> result = ContainerUtilRt.newHashMap(); + for (DataNode node : nodes) { + Collection> n = result.get(node.getKey()); + if (n == null) { + result.put(node.getKey(), n = ContainerUtilRt.newArrayList()); + } + n.add(node); + } + return result; + } + + @NotNull + public static Map, Collection>> groupBy(@NotNull Collection> nodes, @NotNull Key key) { + Map, Collection>> result = ContainerUtilRt.newHashMap(); + for (DataNode data : nodes) { + DataNode grouper = data.getDataNode(key); + if (grouper == null) { + LOG.warn(String.format( + "Skipping entry '%s' during grouping. Reason: it doesn't provide a value for key %s. Given entries: %s", + data, key, nodes + )); + continue; + } + Collection> grouped = result.get(grouper); + if (grouped == null) { + result.put(grouper, grouped = ContainerUtilRt.newArrayList()); + } + grouped.add(data); + } + return result; + } + + @SuppressWarnings("unchecked") + @NotNull + public static Collection> getChildren(@NotNull DataNode node, @NotNull Key key) { + Collection> result = null; + for (DataNode child : node.getChildren()) { + if (!key.equals(child.getKey())) { + continue; + } + if (result == null) { + result = ContainerUtilRt.newArrayList(); + } + result.add((DataNode)child); + } + return result == null ? Collections.>emptyList() : result; + } + + @SuppressWarnings("unchecked") + @Nullable + public static DataNode find(@NotNull DataNode node, @NotNull Key key) { + for (DataNode child : node.getChildren()) { + if (key.equals(child.getKey())) { + return (DataNode)child; + } + } + return null; + } + + @SuppressWarnings("unchecked") + @Nullable + public static DataNode find(@NotNull DataNode node, @NotNull Key key, BooleanFunction> predicate) { + for (DataNode child : node.getChildren()) { + if (key.equals(child.getKey()) && predicate.fun((DataNode)child)) { + return (DataNode)child; + } + } + return null; + } + + @SuppressWarnings("unchecked") + @NotNull + public static Collection> findAll(@NotNull DataNode parent, @NotNull Key key) { + Collection> result = null; + for (DataNode child : parent.getChildren()) { + if (!key.equals(child.getKey())) { + continue; + } + if (result == null) { + result = ContainerUtilRt.newArrayList(); + } + result.add((DataNode)child); + } + return result == null ? Collections.>emptyList() : result; + } + + @NotNull + public static String toReadableName(@NotNull ProjectSystemId id) { + return StringUtil.capitalize(id.toString().toLowerCase()); + } + + public static void executeProjectChangeAction(@NotNull Project project, + @NotNull final ProjectSystemId externalSystemId, + @NotNull Object entityToChange, + @NotNull Runnable task) + { + executeProjectChangeAction(project, externalSystemId, entityToChange, false, task); + } + + public static void executeProjectChangeAction(@NotNull Project project, + @NotNull final ProjectSystemId externalSystemId, + @NotNull Object entityToChange, + boolean synchronous, + @NotNull Runnable task) + { + executeProjectChangeAction(project, externalSystemId, Collections.singleton(entityToChange), synchronous, task); + } + + public static void executeProjectChangeAction(@NotNull final Project project, + @NotNull final ProjectSystemId externalSystemId, + @NotNull final Iterable entitiesToChange, + @NotNull final Runnable task) + { + executeProjectChangeAction(project, externalSystemId, entitiesToChange, false, task); + } + + public static void executeProjectChangeAction(@NotNull final Project project, + @NotNull final ProjectSystemId externalSystemId, + @NotNull final Iterable entitiesToChange, + boolean synchronous, + @NotNull final Runnable task) + { + Runnable wrappedTask = new Runnable() { + public void run() { + ApplicationManager.getApplication().runWriteAction(new Runnable() { + @Override + public void run() { + task.run(); + } + }); + } + }; + + if (synchronous) { + if (ApplicationManager.getApplication().isDispatchThread()) { + wrappedTask.run(); + } + else { + UIUtil.invokeAndWaitIfNeeded(wrappedTask); + } + } + else { + UIUtil.invokeLaterIfNeeded(wrappedTask); + } + } +} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/util/ExternalSystemBundle.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemBundle.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/util/ExternalSystemBundle.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemBundle.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/util/ExternalSystemConstants.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemConstants.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/util/ExternalSystemConstants.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemConstants.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/util/IdeEntityVisitor.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/IdeEntityVisitor.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/util/IdeEntityVisitor.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/util/IdeEntityVisitor.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/util/IntegrationKey.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/IntegrationKey.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/util/IntegrationKey.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/util/IntegrationKey.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/util/Order.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/Order.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/util/Order.java rename to platform/external-system-api/src/com/intellij/openapi/externalSystem/util/Order.java diff --git a/platform/external-system/external-system.iml b/platform/external-system-impl/external-system-impl.iml similarity index 73% rename from platform/external-system/external-system.iml rename to platform/external-system-impl/external-system-impl.iml index 75dee1c2680c..019eb88f1c07 100644 --- a/platform/external-system/external-system.iml +++ b/platform/external-system-impl/external-system-impl.iml @@ -8,17 +8,13 @@ - - - - - - - - + + + - + + diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/settings/LocationSettingType.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/model/settings/LocationSettingType.java similarity index 87% rename from platform/external-system/src/com/intellij/openapi/externalSystem/model/settings/LocationSettingType.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/model/settings/LocationSettingType.java index 96a142377a95..e546176d545e 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/settings/LocationSettingType.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/model/settings/LocationSettingType.java @@ -1,8 +1,8 @@ package com.intellij.openapi.externalSystem.model.settings; import com.intellij.openapi.externalSystem.model.ProjectSystemId; +import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil; import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.PropertyKey; @@ -35,6 +35,6 @@ public enum LocationSettingType { * @return human-readable description of the current setting type */ public String getDescription(@NotNull ProjectSystemId externalSystemId) { - return ExternalSystemBundle.message(myKey, ExternalSystemUtil.toReadableName(externalSystemId)); + return ExternalSystemBundle.message(myKey, ExternalSystemApiUtil.toReadableName(externalSystemId)); } } diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/task/AbstractExternalSystemTask.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/model/task/AbstractExternalSystemTask.java similarity index 96% rename from platform/external-system/src/com/intellij/openapi/externalSystem/model/task/AbstractExternalSystemTask.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/model/task/AbstractExternalSystemTask.java index 7f94daacd1ea..ce4c9e23f691 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/task/AbstractExternalSystemTask.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/model/task/AbstractExternalSystemTask.java @@ -6,8 +6,8 @@ import com.intellij.openapi.externalSystem.model.ProjectSystemId; import com.intellij.openapi.externalSystem.service.ExternalSystemFacadeManager; import com.intellij.openapi.externalSystem.service.RemoteExternalSystemFacade; import com.intellij.openapi.externalSystem.service.notification.ExternalSystemProgressNotificationManager; +import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil; import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.project.Project; import com.intellij.util.ArrayUtil; @@ -155,6 +155,6 @@ public abstract class AbstractExternalSystemTask implements ExternalSystemTask { @Override public String toString() { - return String.format("%s task %s: %s", ExternalSystemUtil.toReadableName(myExternalSystemId), myId, myState); + return String.format("%s task %s: %s", ExternalSystemApiUtil.toReadableName(myExternalSystemId), myId, myState); } } diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemResolveProjectTask.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemResolveProjectTask.java similarity index 77% rename from platform/external-system/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemResolveProjectTask.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemResolveProjectTask.java index 29531c15c08c..ef808df112ea 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemResolveProjectTask.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemResolveProjectTask.java @@ -5,12 +5,11 @@ import com.intellij.openapi.externalSystem.model.DataNode; import com.intellij.openapi.externalSystem.model.ProjectSystemId; import com.intellij.openapi.externalSystem.model.project.ProjectData; import com.intellij.openapi.externalSystem.service.ExternalSystemFacadeManager; -import com.intellij.openapi.externalSystem.service.project.change.ProjectStructureChangesModel; -import com.intellij.openapi.externalSystem.service.remote.ExternalSystemExecutionSettings; +import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings; import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolver; import com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsManager; +import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil; import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; import com.intellij.openapi.project.Project; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -48,10 +47,6 @@ public class ExternalSystemResolveProjectTask extends AbstractExternalSystemTask setState(ExternalSystemTaskState.IN_PROGRESS); ExternalSystemSettingsManager settingsManager = ServiceManager.getService(ExternalSystemSettingsManager.class); - ProjectStructureChangesModel model = null; - if (!ideProject.isDisposed()) { - model = ServiceManager.getService(ProjectStructureChangesModel.class); - } ExternalSystemExecutionSettings settings = settingsManager.getExecutionSettings(ideProject, getExternalSystemId()); DataNode project = resolver.resolveProjectInfo(getId(), myProjectPath, myResolveLibraries, settings); @@ -60,13 +55,6 @@ public class ExternalSystemResolveProjectTask extends AbstractExternalSystemTask } myExternalProject.set(project); setState(ExternalSystemTaskState.FINISHED); - - if (model != null) { - // This task may be called during the 'import from gradle' processing, hence, no project-level IoC is up. - // Model update is necessary for the correct tool window project structure diff showing but we don't have - // gradle tool window on this stage. - model.update(project, ideProject, false); - } } @Nullable @@ -77,6 +65,6 @@ public class ExternalSystemResolveProjectTask extends AbstractExternalSystemTask @Override @NotNull protected String wrapProgressText(@NotNull String text) { - return ExternalSystemBundle.message("progress.update.text", ExternalSystemUtil.toReadableName(getExternalSystemId()), text); + return ExternalSystemBundle.message("progress.update.text", ExternalSystemApiUtil.toReadableName(getExternalSystemId()), text); } } diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskAware.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskAware.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskAware.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/model/task/ExternalSystemTaskAware.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/DisposableExternalSystemService.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/DisposableExternalSystemService.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/DisposableExternalSystemService.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/DisposableExternalSystemService.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/ExternalSystemFacadeImpl.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ExternalSystemFacadeImpl.java similarity index 99% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/ExternalSystemFacadeImpl.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ExternalSystemFacadeImpl.java index e17a74be1c4a..32084132f17f 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/ExternalSystemFacadeImpl.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ExternalSystemFacadeImpl.java @@ -1,6 +1,7 @@ package com.intellij.openapi.externalSystem.service; import com.intellij.execution.rmi.RemoteServer; +import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationEvent; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskType; diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/ExternalSystemFacadeManager.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ExternalSystemFacadeManager.java similarity index 97% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/ExternalSystemFacadeManager.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ExternalSystemFacadeManager.java index 8a41dd8e8638..1e1b757bc791 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/ExternalSystemFacadeManager.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ExternalSystemFacadeManager.java @@ -23,12 +23,14 @@ import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.openapi.externalSystem.ExternalSystemManager; import com.intellij.openapi.externalSystem.model.ProjectSystemId; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId; +import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListener; import com.intellij.openapi.externalSystem.service.notification.ExternalSystemProgressNotificationManager; -import com.intellij.openapi.externalSystem.service.remote.ExternalSystemExecutionSettings; +import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings; import com.intellij.openapi.externalSystem.service.remote.ExternalSystemProgressNotificationManagerImpl; import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProgressNotificationManager; import com.intellij.openapi.externalSystem.service.remote.wrapper.ExternalSystemFacadeWrapper; import com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsManager; +import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil; import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; import com.intellij.openapi.externalSystem.util.IntegrationKey; import com.intellij.openapi.project.Project; @@ -153,6 +155,7 @@ public class ExternalSystemFacadeManager { ContainerUtil.addIfNotNull(PathUtil.getJarPathForClass(JavaSdkVersion.class), classPath); ContainerUtil.addIfNotNull(PathUtil.getJarPathForClass(ExtensionPointName.class), classPath); ContainerUtil.addIfNotNull(PathUtil.getJarPathForClass(OpenProjectFileChooserDescriptor.class), classPath); + ContainerUtil.addIfNotNull(PathUtil.getJarPathForClass(ExternalSystemTaskNotificationListener.class), classPath); // External system module jars ContainerUtil.addIfNotNull(PathUtil.getJarPathForClass(getClass()), classPath); @@ -172,7 +175,7 @@ public class ExternalSystemFacadeManager { ProjectSystemId externalSystemId = myTargetExternalSystemId.get(); if (externalSystemId != null) { - ExternalSystemManager manager = ExternalSystemUtil.getManager(externalSystemId); + ExternalSystemManager manager = ExternalSystemApiUtil.getManager(externalSystemId); if (manager != null) { params.getProgramParametersList().add(manager.getProjectResolverClass().getName()); params.getProgramParametersList().add(manager.getBuildManagerClass().getName()); @@ -260,7 +263,7 @@ public class ExternalSystemFacadeManager { @SuppressWarnings("ConstantConditions") @NotNull private RemoteExternalSystemFacade doGetFacade(@NotNull IntegrationKey key, @NotNull Project project) throws Exception { - ExternalSystemManager manager = ExternalSystemUtil.getManager(key.getExternalSystemId()); + ExternalSystemManager manager = ExternalSystemApiUtil.getManager(key.getExternalSystemId()); if (project.isDisposed() || manager == null || !manager.isReady(project)) { return RemoteExternalSystemFacade.NULL_OBJECT; } diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/RemoteExternalSystemFacade.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/RemoteExternalSystemFacade.java similarity index 98% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/RemoteExternalSystemFacade.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/RemoteExternalSystemFacade.java index 6018ef59d03e..1560144e2314 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/RemoteExternalSystemFacade.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/RemoteExternalSystemFacade.java @@ -3,7 +3,7 @@ package com.intellij.openapi.externalSystem.service; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskAware; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskType; -import com.intellij.openapi.externalSystem.service.remote.ExternalSystemExecutionSettings; +import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings; import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemBuildManager; import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProgressNotificationManager; import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolver; diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/RemoteExternalSystemService.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/RemoteExternalSystemService.java similarity index 95% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/RemoteExternalSystemService.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/RemoteExternalSystemService.java index 959753f94a1c..d33419323b4e 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/RemoteExternalSystemService.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/RemoteExternalSystemService.java @@ -1,7 +1,7 @@ package com.intellij.openapi.externalSystem.service; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskAware; -import com.intellij.openapi.externalSystem.service.remote.ExternalSystemExecutionSettings; +import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListener; import org.jetbrains.annotations.NotNull; diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/notification/ExternalSystemProgressNotificationManager.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/ExternalSystemProgressNotificationManager.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/notification/ExternalSystemProgressNotificationManager.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/ExternalSystemProgressNotificationManager.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/ExternalLibraryPathTypeMapperImpl.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/ExternalLibraryPathTypeMapperImpl.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/project/ExternalLibraryPathTypeMapperImpl.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/ExternalLibraryPathTypeMapperImpl.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/PlatformFacadeImpl.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/PlatformFacadeImpl.java similarity index 86% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/project/PlatformFacadeImpl.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/PlatformFacadeImpl.java index 43fcc9b5fd52..206fb245995f 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/PlatformFacadeImpl.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/PlatformFacadeImpl.java @@ -1,6 +1,6 @@ package com.intellij.openapi.externalSystem.service.project; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; +import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.project.Project; @@ -28,12 +28,6 @@ public class PlatformFacadeImpl implements PlatformFacade { return ProjectLibraryTable.getInstance(project); } - @NotNull - @Override - public LanguageLevel getLanguageLevel(@NotNull Project project) { - return LanguageLevelProjectExtension.getInstance(project).getLanguageLevel(); - } - @NotNull @Override public Collection getModules(@NotNull Project project) { @@ -66,6 +60,6 @@ public class PlatformFacadeImpl implements PlatformFacade { @NotNull @Override public String getLocalFileSystemPath(@NotNull VirtualFile file) { - return ExternalSystemUtil.getLocalFileSystemPath(file); + return ExternalSystemApiUtil.getLocalFileSystemPath(file); } } diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/ProjectStructureHelper.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/ProjectStructureHelper.java new file mode 100644 index 000000000000..60b14574f4ca --- /dev/null +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/ProjectStructureHelper.java @@ -0,0 +1,252 @@ +package com.intellij.openapi.externalSystem.service.project; + +import com.intellij.openapi.externalSystem.model.DataNode; +import com.intellij.openapi.externalSystem.model.ProjectKeys; +import com.intellij.openapi.externalSystem.model.project.ContentRootData; +import com.intellij.openapi.externalSystem.model.project.LibraryData; +import com.intellij.openapi.externalSystem.model.project.ModuleData; +import com.intellij.openapi.externalSystem.model.project.ModuleDependencyData; +import com.intellij.openapi.externalSystem.util.ArtifactInfo; +import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil; +import com.intellij.openapi.module.Module; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.roots.*; +import com.intellij.openapi.roots.impl.ModuleLibraryOrderEntryImpl; +import com.intellij.openapi.roots.libraries.Library; +import com.intellij.openapi.roots.libraries.LibraryTable; +import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Thread-safe. + * + * @author Denis Zhdanov + * @since 2/6/12 3:28 PM + */ +public class ProjectStructureHelper { + + @NotNull private final PlatformFacade myFacade; + @NotNull private final ExternalLibraryPathTypeMapper myLibraryPathTypeMapper; + + public ProjectStructureHelper(@NotNull PlatformFacade facade, @NotNull ExternalLibraryPathTypeMapper mapper) { + myFacade = facade; + myLibraryPathTypeMapper = mapper; + } + + @Nullable + public Module findIdeModule(@NotNull ModuleData module, @NotNull Project ideProject) { + return findIdeModule(module.getName(), ideProject); + } + + @Nullable + public Module findIdeModule(@NotNull String ideModuleName, @NotNull Project ideProject) { + for (Module module : myFacade.getModules(ideProject)) { + if (ideModuleName.equals(module.getName())) { + return module; + } + } + return null; + } + + @Nullable + public ModuleAwareContentRoot findIdeContentRoot(@NotNull DataNode node, @NotNull Project ideProject) { + ModuleData moduleData = node.getData(ProjectKeys.MODULE); + if (moduleData == null) { + return null; + } + final Module module = findIdeModule(moduleData.getName(), ideProject); + if (module == null) { + return null; + } + for (ModuleAwareContentRoot contentRoot : myFacade.getContentRoots(module)) { + final VirtualFile file = contentRoot.getFile(); + if (node.getData().getRootPath().equals(file.getPath())) { + return contentRoot; + } + } + return null; + } + + @Nullable + public Library findIdeLibrary(@NotNull final LibraryData library, @NotNull Project ideProject) { + return findIdeLibrary(library.getName(), ideProject); + } + + /** + * Gradle library names follow the following pattern: {@code '[base library name]-[library-version]'}. + *

+ * This methods serves as an utility which tries to find a library by it's given base name. + * + * @param baseName base name of the target library + * @param ideProject target ide project + * @return target library for the given base name if there is one and only one library for it; + * null otherwise (if there are no libraries or more than one library for the given base name) + */ + @Nullable + public Library findIdeLibraryByBaseName(@NotNull String baseName, @NotNull Project ideProject) { + final LibraryTable libraryTable = myFacade.getProjectLibraryTable(ideProject); + Library result = null; + for (Library library : libraryTable.getLibraries()) { + ArtifactInfo info = ExternalSystemApiUtil.parseArtifactInfo(ExternalSystemApiUtil.getLibraryName(library)); + if (info == null || !baseName.equals(info.getName())) { + continue; + } + if (result != null) { + return null; + } + result = library; + } + return result; + } + + @Nullable + public Library findIdeLibrary(@NotNull String libraryName, @NotNull Project ideProject) { + final LibraryTable libraryTable = myFacade.getProjectLibraryTable(ideProject); + for (Library ideLibrary : libraryTable.getLibraries()) { + if (libraryName.equals(ExternalSystemApiUtil.getLibraryName(ideLibrary))) { + return ideLibrary; + } + } + return null; + } + + @Nullable + public Library findIdeLibrary(@NotNull String libraryName, + @NotNull OrderRootType jarType, + @NotNull String jarPath, + @NotNull Project ideProject) + { + Library library = findIdeLibrary(libraryName, ideProject); + if (library == null) { + return null; + } + for (VirtualFile file : library.getFiles(jarType)) { + if (jarPath.equals(ExternalSystemApiUtil.getLocalFileSystemPath(file))) { + return library; + } + } + return null; + } + + @Nullable + public LibraryOrderEntry findIdeLibraryDependency(@NotNull final String moduleName, + @NotNull final String libraryName, + @NotNull Project ideProject) + { + final Module ideModule = findIdeModule(moduleName, ideProject); + if (ideModule == null) { + return null; + } + RootPolicy visitor = new RootPolicy() { + @Override + public LibraryOrderEntry visitLibraryOrderEntry(LibraryOrderEntry ideDependency, LibraryOrderEntry value) { + if (libraryName.equals(ideDependency.getLibraryName())) { + return ideDependency; + } + return value; + } + }; + for (OrderEntry entry : myFacade.getOrderEntries(ideModule)) { + final LibraryOrderEntry result = entry.accept(visitor, null); + if (result != null) { + return result; + } + } + return null; + } + + @Nullable + public ModuleLibraryOrderEntryImpl findIdeModuleLocalLibraryDependency(@NotNull final String moduleName, + @NotNull final String libraryName, + @NotNull Project ideProject) + { + final Module ideModule = findIdeModule(moduleName, ideProject); + if (ideModule == null) { + return null; + } + RootPolicy visitor = new RootPolicy() { + @Override + public ModuleLibraryOrderEntryImpl visitLibraryOrderEntry(LibraryOrderEntry ideDependency, ModuleLibraryOrderEntryImpl value) { + Library library = ideDependency.getLibrary(); + if (library == null) { + return value; + } + if (ideDependency instanceof ModuleLibraryOrderEntryImpl && libraryName.equals(ExternalSystemApiUtil.getLibraryName(library))) { + return (ModuleLibraryOrderEntryImpl)ideDependency; + } + return value; + } + }; + for (OrderEntry entry : myFacade.getOrderEntries(ideModule)) { + final ModuleLibraryOrderEntryImpl result = entry.accept(visitor, null); + if (result != null) { + return result; + } + } + return null; + } + + @SuppressWarnings("MethodMayBeStatic") + @Nullable + public LibraryOrderEntry findIdeLibraryDependency(@NotNull final String libraryName, + @NotNull ModifiableRootModel model) + { + for (OrderEntry entry : model.getOrderEntries()) { + if (entry instanceof LibraryOrderEntry) { + LibraryOrderEntry candidate = (LibraryOrderEntry)entry; + if (libraryName.equals(candidate.getLibraryName())) { + return candidate; + } + } + } + return null; + } + + @Nullable + public ModuleOrderEntry findIdeModuleDependency(@NotNull final ModuleDependencyData gradleDependency, @NotNull Project ideProject) { + return findIdeModuleDependency(gradleDependency.getOwnerModule().getName(), gradleDependency.getTarget().getName(), ideProject); + } + + @Nullable + public ModuleOrderEntry findIdeModuleDependency(@NotNull final String ownerModuleName, + @NotNull final String dependencyModuleName, + @NotNull Project ideProject) + { + final Module ideOwnerModule = findIdeModule(ownerModuleName, ideProject); + if (ideOwnerModule == null) { + return null; + } + + RootPolicy visitor = new RootPolicy() { + @Override + public ModuleOrderEntry visitModuleOrderEntry(ModuleOrderEntry ideDependency, ModuleOrderEntry value) { + if (dependencyModuleName.equals(ideDependency.getModuleName())) { + return ideDependency; + } + return value; + } + }; + for (OrderEntry orderEntry : myFacade.getOrderEntries(ideOwnerModule)) { + final ModuleOrderEntry result = orderEntry.accept(visitor, null); + if (result != null) { + return result; + } + } + return null; + } + + @SuppressWarnings("MethodMayBeStatic") + @Nullable + public ModuleOrderEntry findIdeModuleDependency(@NotNull ModuleDependencyData dependency, @NotNull ModifiableRootModel model) { + for (OrderEntry entry : model.getOrderEntries()) { + if (entry instanceof ModuleOrderEntry) { + ModuleOrderEntry candidate = (ModuleOrderEntry)entry; + if (dependency.getName().equals(candidate.getModuleName())) { + return candidate; + } + } + } + return null; + } +} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/ProjectStructureServices.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/ProjectStructureServices.java similarity index 76% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/project/ProjectStructureServices.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/ProjectStructureServices.java index 41ff1c6f0e86..1e6dadd0d3b8 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/ProjectStructureServices.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/ProjectStructureServices.java @@ -1,6 +1,5 @@ package com.intellij.openapi.externalSystem.service.project; -import com.intellij.openapi.externalSystem.service.project.change.ProjectStructureChangesModel; import org.jetbrains.annotations.NotNull; /** @@ -15,17 +14,14 @@ public class ProjectStructureServices { @NotNull private final ProjectStructureHelper myProjectStructureHelper; @NotNull private final PlatformFacade myPlatformFacade; - @NotNull private final ProjectStructureChangesModel myChangesModel; @NotNull private final ExternalLibraryPathTypeMapper myLibraryPathTypeMapper; public ProjectStructureServices(@NotNull ProjectStructureHelper projectStructureHelper, @NotNull PlatformFacade platformFacade, - @NotNull ProjectStructureChangesModel changesModel, @NotNull ExternalLibraryPathTypeMapper mapper) { myProjectStructureHelper = projectStructureHelper; myPlatformFacade = platformFacade; - myChangesModel = changesModel; myLibraryPathTypeMapper = mapper; } @@ -39,11 +35,6 @@ public class ProjectStructureServices { return myPlatformFacade; } - @NotNull - public ProjectStructureChangesModel getChangesModel() { - return myChangesModel; - } - @NotNull public ExternalLibraryPathTypeMapper getLibraryPathTypeMapper() { return myLibraryPathTypeMapper; diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/AbstractDependencyDataService.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/AbstractDependencyDataService.java similarity index 90% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/AbstractDependencyDataService.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/AbstractDependencyDataService.java index d861c585ff27..3b5edec073bd 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/AbstractDependencyDataService.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/AbstractDependencyDataService.java @@ -17,7 +17,7 @@ package com.intellij.openapi.externalSystem.service.project.manage; import com.intellij.openapi.externalSystem.model.ProjectSystemId; import com.intellij.openapi.externalSystem.model.project.AbstractDependencyData; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; +import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.*; @@ -37,7 +37,7 @@ public abstract class AbstractDependencyDataService() { @@ -78,7 +78,7 @@ public abstract class AbstractDependencyDataService() { diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/ContentRootDataService.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ContentRootDataService.java similarity index 93% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/ContentRootDataService.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ContentRootDataService.java index 29e97eccd151..cbf19928bb0d 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/ContentRootDataService.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ContentRootDataService.java @@ -2,15 +2,15 @@ package com.intellij.openapi.externalSystem.service.project.manage; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.externalSystem.model.DataNode; -import com.intellij.openapi.externalSystem.model.ProjectKeys; import com.intellij.openapi.externalSystem.model.Key; +import com.intellij.openapi.externalSystem.model.ProjectKeys; import com.intellij.openapi.externalSystem.model.ProjectSystemId; import com.intellij.openapi.externalSystem.model.project.ContentRootData; import com.intellij.openapi.externalSystem.model.project.ExternalSystemSourceType; import com.intellij.openapi.externalSystem.model.project.ModuleData; import com.intellij.openapi.externalSystem.service.project.ModuleAwareContentRoot; import com.intellij.openapi.externalSystem.service.project.ProjectStructureHelper; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; +import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ContentEntry; @@ -56,7 +56,7 @@ public class ContentRootDataService implements ProjectDataService, Collection>> byModule - = ExternalSystemUtil.groupBy(toImport, ProjectKeys.MODULE); + = ExternalSystemApiUtil.groupBy(toImport, ProjectKeys.MODULE); for (Map.Entry, Collection>> entry : byModule.entrySet()) { final Module module = myProjectStructureHelper.findIdeModule(entry.getKey().getData(), project); if (module == null) { @@ -76,7 +76,7 @@ public class ContentRootDataService implements ProjectDataService,Collection>> byModule - = ExternalSystemUtil.groupBy(toRemove, ProjectKeys.MODULE); + = ExternalSystemApiUtil.groupBy(toRemove, ProjectKeys.MODULE); for (Map.Entry, Collection>> entry : byModule.entrySet()) { final Module module = myProjectStructureHelper.findIdeModule(entry.getKey().getData(), project); if (module == null) { @@ -134,7 +134,7 @@ public class ContentRootDataService implements ProjectDataService contentRoots = ContainerUtilRt.newArrayList(); for (DataNode holder : entry.getValue()) { - ModuleAwareContentRoot contentRoot = myProjectStructureHelper.findIdeContentRoot(holder.getData().getId(holder), project); + ModuleAwareContentRoot contentRoot = myProjectStructureHelper.findIdeContentRoot(holder, project); if (contentRoot != null) { contentRoots.add(contentRoot); } @@ -147,7 +147,7 @@ public class ContentRootDataService implements ProjectDataService { @NotNull private final PlatformFacade myPlatformFacade; @NotNull private final ProjectStructureHelper myProjectStructureHelper; @NotNull private final ExternalLibraryPathTypeMapper myLibraryPathTypeMapper; - @NotNull private final JarDataService myJarManager; public LibraryDataService(@NotNull PlatformFacade platformFacade, @NotNull ProjectStructureHelper helper, - @NotNull ExternalLibraryPathTypeMapper mapper, - @NotNull JarDataService manager) + @NotNull ExternalLibraryPathTypeMapper mapper) { myPlatformFacade = platformFacade; myProjectStructureHelper = helper; myLibraryPathTypeMapper = mapper; - myJarManager = manager; } @NotNull @@ -89,7 +88,7 @@ public class LibraryDataService implements ProjectDataService { @NotNull final Project project, boolean synchronous) { - ExternalSystemUtil.executeProjectChangeAction(project, externalSystemId, libraryName, synchronous, new Runnable() { + ExternalSystemApiUtil.executeProjectChangeAction(project, externalSystemId, libraryName, synchronous, new Runnable() { @Override public void run() { // Is assumed to be called from the EDT. @@ -161,7 +160,7 @@ public class LibraryDataService implements ProjectDataService { if (libraries.isEmpty()) { return; } - ExternalSystemUtil.executeProjectChangeAction(project, ProjectSystemId.IDE, libraries, synchronous, new Runnable() { + ExternalSystemApiUtil.executeProjectChangeAction(project, ProjectSystemId.IDE, libraries, synchronous, new Runnable() { @Override public void run() { final LibraryTable libraryTable = myPlatformFacade.getProjectLibraryTable(project); @@ -192,7 +191,7 @@ public class LibraryDataService implements ProjectDataService { Set toRemove = ContainerUtilRt.newHashSet(); Set toAdd = ContainerUtilRt.newHashSet(externalLibrary.getPaths(LibraryPathType.BINARY)); for (VirtualFile ideFile : ideLibrary.getFiles(OrderRootType.CLASSES)) { - String idePath = ExternalSystemUtil.getLocalFileSystemPath(ideFile); + String idePath = ExternalSystemApiUtil.getLocalFileSystemPath(ideFile); if (!toAdd.remove(idePath)) { toRemove.add(idePath); } @@ -200,23 +199,6 @@ public class LibraryDataService implements ProjectDataService { if (toRemove.isEmpty() && toAdd.isEmpty()) { return; } - - Function> jarMapper = new Function>() { - @Override - public DataNode fun(String path) { - JarData data = new JarData(path, LibraryPathType.BINARY, ideLibrary, null, ProjectSystemId.IDE); - return new DataNode(ProjectKeys.JAR, data, null); - } - }; - - if (!toRemove.isEmpty()) { - List> jarsToRemove = ContainerUtil.map(toRemove, jarMapper); - myJarManager.removeData(jarsToRemove, project, synchronous); - } - - if (!toAdd.isEmpty()) { - List> jarsToAdd = ContainerUtil.map(toAdd, jarMapper); - myJarManager.importJars(jarsToAdd, ideLibrary, externalLibrary.getOwner(), project, synchronous); - } + // TODO den implement } } diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDependencyDataService.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDependencyDataService.java similarity index 91% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDependencyDataService.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDependencyDataService.java index 42093dfffe31..47d0628a6bbc 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDependencyDataService.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDependencyDataService.java @@ -18,8 +18,8 @@ package com.intellij.openapi.externalSystem.service.project.manage; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.externalSystem.model.DataNode; -import com.intellij.openapi.externalSystem.model.ProjectKeys; import com.intellij.openapi.externalSystem.model.Key; +import com.intellij.openapi.externalSystem.model.ProjectKeys; import com.intellij.openapi.externalSystem.model.ProjectSystemId; import com.intellij.openapi.externalSystem.model.project.LibraryData; import com.intellij.openapi.externalSystem.model.project.LibraryDependencyData; @@ -27,17 +27,23 @@ import com.intellij.openapi.externalSystem.model.project.ModuleData; import com.intellij.openapi.externalSystem.model.project.ProjectData; import com.intellij.openapi.externalSystem.service.project.PlatformFacade; import com.intellij.openapi.externalSystem.service.project.ProjectStructureHelper; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; +import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.*; +import com.intellij.openapi.roots.ExportableOrderEntry; +import com.intellij.openapi.roots.LibraryOrderEntry; +import com.intellij.openapi.roots.ModifiableRootModel; +import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.roots.libraries.LibraryTable; import com.intellij.util.BooleanFunction; import com.intellij.util.containers.ContainerUtilRt; import org.jetbrains.annotations.NotNull; -import java.util.*; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Map; import static com.intellij.openapi.externalSystem.model.ProjectKeys.MODULE; @@ -77,7 +83,7 @@ public class LibraryDependencyDataService extends AbstractDependencyDataService< return; } - Map, Collection>> byModule = ExternalSystemUtil.groupBy(toImport, MODULE); + Map, Collection>> byModule = ExternalSystemApiUtil.groupBy(toImport, MODULE); for (Map.Entry, Collection>> entry : byModule.entrySet()) { Module module = myProjectStructureHelper.findIdeModule(entry.getKey().getData(), project); if (module == null) { @@ -100,7 +106,7 @@ public class LibraryDependencyDataService extends AbstractDependencyDataService< @NotNull final Module module, final boolean synchronous) { - ExternalSystemUtil.executeProjectChangeAction(module.getProject(), externalSystemId, nodesToImport, synchronous, new Runnable() { + ExternalSystemApiUtil.executeProjectChangeAction(module.getProject(), externalSystemId, nodesToImport, synchronous, new Runnable() { @Override public void run() { LibraryTable libraryTable = myPlatformFacade.getProjectLibraryTable(module.getProject()); @@ -112,7 +118,7 @@ public class LibraryDependencyDataService extends AbstractDependencyDataService< DataNode projectNode = dataNode.getDataNode(ProjectKeys.PROJECT); if (projectNode != null) { DataNode libraryNode = - ExternalSystemUtil.find(projectNode, ProjectKeys.LIBRARY, new BooleanFunction>() { + ExternalSystemApiUtil.find(projectNode, ProjectKeys.LIBRARY, new BooleanFunction>() { @Override public boolean fun(DataNode node) { return node.getData().equals(dependencyData.getTarget()); @@ -166,7 +172,7 @@ public class LibraryDependencyDataService extends AbstractDependencyDataService< if (toRemove.isEmpty()) { return; } - Map, Collection>> byModule = ExternalSystemUtil.groupBy(toRemove, MODULE); + Map, Collection>> byModule = ExternalSystemApiUtil.groupBy(toRemove, MODULE); for (Map.Entry, Collection>> entry : byModule.entrySet()) { Module module = myProjectStructureHelper.findIdeModule(entry.getKey().getData(), project); if (module == null) { diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDataService.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDataService.java similarity index 96% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDataService.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDataService.java index b20c879fcbb0..38187f9a0cfa 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDataService.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDataService.java @@ -9,7 +9,7 @@ import com.intellij.openapi.externalSystem.model.ProjectKeys; import com.intellij.openapi.externalSystem.model.ProjectSystemId; import com.intellij.openapi.externalSystem.model.project.ModuleData; import com.intellij.openapi.externalSystem.service.project.ProjectStructureHelper; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; +import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.module.StdModuleTypes; @@ -137,7 +137,7 @@ public class ModuleDataService implements ProjectDataService { if (nodes.isEmpty()) { return; } - ExternalSystemUtil.executeProjectChangeAction(project, nodes.iterator().next().getData().getOwner(), nodes, true, new Runnable() { + ExternalSystemApiUtil.executeProjectChangeAction(project, nodes.iterator().next().getData().getOwner(), nodes, true, new Runnable() { @Override public void run() { LocalFileSystem fileSystem = LocalFileSystem.getInstance(); @@ -176,7 +176,7 @@ public class ModuleDataService implements ProjectDataService { return; } Project project = modules.iterator().next().getProject(); - ExternalSystemUtil.executeProjectChangeAction(project, ProjectSystemId.IDE, modules, synchronous, new Runnable() { + ExternalSystemApiUtil.executeProjectChangeAction(project, ProjectSystemId.IDE, modules, synchronous, new Runnable() { @Override public void run() { for (Module module : modules) { diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDependencyDataService.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDependencyDataService.java similarity index 93% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDependencyDataService.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDependencyDataService.java index 445cd6248782..0b3d4b27bcd2 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDependencyDataService.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDependencyDataService.java @@ -24,7 +24,7 @@ import com.intellij.openapi.externalSystem.model.project.ModuleData; import com.intellij.openapi.externalSystem.model.project.ModuleDependencyData; import com.intellij.openapi.externalSystem.model.project.ProjectData; import com.intellij.openapi.externalSystem.service.project.ProjectStructureHelper; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; +import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ExportableOrderEntry; @@ -66,8 +66,7 @@ public class ModuleDependencyDataService extends AbstractDependencyDataService> toImport, @NotNull Project project, boolean synchronous) { - Map, Collection>> byModule - = ExternalSystemUtil.groupBy(toImport, ProjectKeys.MODULE); + Map, Collection>> byModule= ExternalSystemApiUtil.groupBy(toImport, MODULE); for (Map.Entry, Collection>> entry : byModule.entrySet()) { Module ideModule = myProjectStructureHelper.findIdeModule(entry.getKey().getData(), project); if (ideModule == null) { @@ -90,7 +89,7 @@ public class ModuleDependencyDataService extends AbstractDependencyDataService projectNode = dependencyNode.getDataNode(ProjectKeys.PROJECT); if (projectNode != null) { DataNode n - = ExternalSystemUtil.find(projectNode, ProjectKeys.MODULE, new BooleanFunction>() { + = ExternalSystemApiUtil.find(projectNode, MODULE, new BooleanFunction>() { @Override public boolean fun(DataNode node) { return node.getData().equals(dependencyData.getTarget()); @@ -146,7 +145,7 @@ public class ModuleDependencyDataService extends AbstractDependencyDataService, Collection>> byModule = ExternalSystemUtil.groupBy(toRemove, MODULE); + Map, Collection>> byModule = ExternalSystemApiUtil.groupBy(toRemove, MODULE); for (Map.Entry, Collection>> entry : byModule.entrySet()) { Module module = myProjectStructureHelper.findIdeModule(entry.getKey().getData(), project); if (module == null) { diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataManager.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataManager.java similarity index 96% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataManager.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataManager.java index f2a7e991b9b1..bf97f9741304 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataManager.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataManager.java @@ -18,7 +18,7 @@ package com.intellij.openapi.externalSystem.service.project.manage; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.externalSystem.model.DataNode; import com.intellij.openapi.externalSystem.model.Key; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; +import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.NotNullLazyValue; import com.intellij.util.containers.ContainerUtilRt; @@ -53,7 +53,7 @@ public class ProjectDataManager { } for (List> services : result.values()) { - ExternalSystemUtil.orderAwareSort(services); + ExternalSystemApiUtil.orderAwareSort(services); } return result; @@ -62,7 +62,7 @@ public class ProjectDataManager { @SuppressWarnings("unchecked") public void importData(@NotNull Collection> nodes, @NotNull Project project, boolean synchronous) { - Map, Collection>> grouped = ExternalSystemUtil.group(nodes); + Map, Collection>> grouped = ExternalSystemApiUtil.group(nodes); for (Map.Entry, Collection>> entry : grouped.entrySet()) { // Simple class cast makes ide happy but compiler fails. Collection> dummy = ContainerUtilRt.newArrayList(); diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataServiceImpl.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataServiceImpl.java similarity index 92% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataServiceImpl.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataServiceImpl.java index a618078da725..5a304f39638b 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataServiceImpl.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataServiceImpl.java @@ -20,7 +20,7 @@ import com.intellij.openapi.externalSystem.model.Key; import com.intellij.openapi.externalSystem.model.ProjectKeys; import com.intellij.openapi.externalSystem.model.ProjectSystemId; import com.intellij.openapi.externalSystem.model.project.ProjectData; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; +import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ex.ProjectEx; import org.jetbrains.annotations.NotNull; @@ -59,7 +59,7 @@ public class ProjectDataServiceImpl implements ProjectDataService { if (!(project instanceof ProjectEx) || newName.equals(project.getName())) { return; } - ExternalSystemUtil.executeProjectChangeAction(project, ProjectSystemId.IDE, project, synchronous, new Runnable() { + ExternalSystemApiUtil.executeProjectChangeAction(project, ProjectSystemId.IDE, project, synchronous, new Runnable() { @Override public void run() { ((ProjectEx)project).setProjectName(newName); diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectEntityChangeListener.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectEntityChangeListener.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectEntityChangeListener.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectEntityChangeListener.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalProjectImportBuilder.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalProjectImportBuilder.java similarity index 94% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalProjectImportBuilder.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalProjectImportBuilder.java index 5080e8a70e6d..b8844bcbc3f1 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalProjectImportBuilder.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalProjectImportBuilder.java @@ -13,6 +13,7 @@ import com.intellij.openapi.externalSystem.service.project.manage.ProjectDataMan import com.intellij.openapi.externalSystem.service.settings.AbstractExternalProjectConfigurable; import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings; import com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsManager; +import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil; import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; import com.intellij.openapi.externalSystem.util.ExternalSystemConstants; import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; @@ -140,16 +141,16 @@ public abstract class AbstractExternalProjectImportBuilder> modules = ExternalSystemUtil.findAll(externalProjectNode, ProjectKeys.MODULE); + Collection> modules = ExternalSystemApiUtil.findAll(externalProjectNode, ProjectKeys.MODULE); myProjectDataManager.importData(ProjectKeys.MODULE, modules, project, true); } - }); + }); } }); @@ -157,7 +158,7 @@ public abstract class AbstractExternalProjectImportBuilder projectWithResolvedLibraries, final Project project) { - Collection> libraries = ExternalSystemUtil.findAll(projectWithResolvedLibraries, ProjectKeys.LIBRARY); - ExternalSystemUtil.executeProjectChangeAction(project, projectWithResolvedLibraries.getData().getOwner(), libraries, new Runnable() { + Collection> libraries = ExternalSystemApiUtil.findAll(projectWithResolvedLibraries, ProjectKeys.LIBRARY); + ExternalSystemApiUtil.executeProjectChangeAction(project, projectWithResolvedLibraries.getData().getOwner(), libraries, new Runnable() { @Override public void run() { ProjectRootManagerEx.getInstanceEx(project).mergeRootsChangesDuring(new Runnable() { @@ -270,7 +271,7 @@ public abstract class AbstractExternalProjectImportBuilder errorDetails = new Ref(); try { final Project project = getProject(wizardContext); - myExternalProjectNode= ExternalSystemUtil.refreshProject(project, myExternalSystemId, projectFile.getAbsolutePath(), errorReason, - errorDetails, false, true); + myExternalProjectNode = ExternalSystemUtil.refreshProject(project, myExternalSystemId, projectFile.getAbsolutePath(), errorReason, + errorDetails, false, true); } catch (IllegalArgumentException e) { throw new ConfigurationException(e.getMessage(), ExternalSystemBundle.message("error.cannot.parse.project", externalSystemName)); diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalProjectImportProvider.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalProjectImportProvider.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalProjectImportProvider.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalProjectImportProvider.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractImportFromExternalSystemWizardStep.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractImportFromExternalSystemWizardStep.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractImportFromExternalSystemWizardStep.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractImportFromExternalSystemWizardStep.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/wizard/ExternalProjectOpenProcessor.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/ExternalProjectOpenProcessor.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/project/wizard/ExternalProjectOpenProcessor.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/ExternalProjectOpenProcessor.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/wizard/SelectExternalProjectStepBase.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/SelectExternalProjectStepBase.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/project/wizard/SelectExternalProjectStepBase.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/SelectExternalProjectStepBase.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/AbstractRemoteExternalSystemService.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/remote/AbstractRemoteExternalSystemService.java similarity index 97% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/AbstractRemoteExternalSystemService.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/remote/AbstractRemoteExternalSystemService.java index 7b32ba53f216..be40f1755a0a 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/AbstractRemoteExternalSystemService.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/remote/AbstractRemoteExternalSystemService.java @@ -15,6 +15,7 @@ */ package com.intellij.openapi.externalSystem.service.remote; +import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskType; import com.intellij.openapi.externalSystem.service.RemoteExternalSystemService; diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/ExternalSystemProgressNotificationManagerImpl.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/remote/ExternalSystemProgressNotificationManagerImpl.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/ExternalSystemProgressNotificationManagerImpl.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/remote/ExternalSystemProgressNotificationManagerImpl.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemBuildManager.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemBuildManager.java similarity index 97% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemBuildManager.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemBuildManager.java index ff39664f34ab..d7aca856c978 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemBuildManager.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemBuildManager.java @@ -16,6 +16,7 @@ package com.intellij.openapi.externalSystem.service.remote; import com.intellij.openapi.externalSystem.model.ExternalSystemException; +import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskDescriptor; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskType; diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemBuildManagerImpl.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemBuildManagerImpl.java similarity index 96% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemBuildManagerImpl.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemBuildManagerImpl.java index 8e928b411c56..8aa428d85e17 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemBuildManagerImpl.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemBuildManagerImpl.java @@ -17,6 +17,7 @@ package com.intellij.openapi.externalSystem.service.remote; import com.intellij.openapi.externalSystem.build.ExternalSystemBuildManager; import com.intellij.openapi.externalSystem.model.ExternalSystemException; +import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskDescriptor; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId; import com.intellij.util.Producer; diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemProgressNotificationManager.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemProgressNotificationManager.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemProgressNotificationManager.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemProgressNotificationManager.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemProjectResolver.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemProjectResolver.java similarity index 97% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemProjectResolver.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemProjectResolver.java index 90c85cdd8440..dd60f4dac4bc 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemProjectResolver.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemProjectResolver.java @@ -18,6 +18,7 @@ package com.intellij.openapi.externalSystem.service.remote; import com.intellij.openapi.externalSystem.model.DataNode; import com.intellij.openapi.externalSystem.model.ExternalSystemException; import com.intellij.openapi.externalSystem.model.project.ProjectData; +import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskType; import com.intellij.openapi.externalSystem.service.RemoteExternalSystemService; diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemProjectResolverImpl.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemProjectResolverImpl.java similarity index 95% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemProjectResolverImpl.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemProjectResolverImpl.java index bb5bd551a016..e90dd2288437 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemProjectResolverImpl.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemProjectResolverImpl.java @@ -3,6 +3,7 @@ package com.intellij.openapi.externalSystem.service.remote; import com.intellij.openapi.externalSystem.model.DataNode; import com.intellij.openapi.externalSystem.model.ExternalSystemException; import com.intellij.openapi.externalSystem.model.project.ProjectData; +import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId; import com.intellij.openapi.externalSystem.service.project.ExternalSystemProjectResolver; import com.intellij.util.Producer; diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/wrapper/AbstractRemoteExternalSystemServiceWrapper.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/remote/wrapper/AbstractRemoteExternalSystemServiceWrapper.java similarity index 97% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/wrapper/AbstractRemoteExternalSystemServiceWrapper.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/remote/wrapper/AbstractRemoteExternalSystemServiceWrapper.java index cfe65c47a39e..620afc518fca 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/wrapper/AbstractRemoteExternalSystemServiceWrapper.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/remote/wrapper/AbstractRemoteExternalSystemServiceWrapper.java @@ -18,7 +18,7 @@ package com.intellij.openapi.externalSystem.service.remote.wrapper; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskType; import com.intellij.openapi.externalSystem.service.RemoteExternalSystemService; -import com.intellij.openapi.externalSystem.service.remote.ExternalSystemExecutionSettings; +import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListener; import org.jetbrains.annotations.NotNull; diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/wrapper/ExternalSystemBuildManagerWrapper.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/remote/wrapper/ExternalSystemBuildManagerWrapper.java similarity index 97% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/wrapper/ExternalSystemBuildManagerWrapper.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/remote/wrapper/ExternalSystemBuildManagerWrapper.java index aa7042d541cb..343e0ead1e43 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/wrapper/ExternalSystemBuildManagerWrapper.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/remote/wrapper/ExternalSystemBuildManagerWrapper.java @@ -18,7 +18,7 @@ package com.intellij.openapi.externalSystem.service.remote.wrapper; import com.intellij.openapi.externalSystem.model.ExternalSystemException; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskDescriptor; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId; -import com.intellij.openapi.externalSystem.service.remote.ExternalSystemExecutionSettings; +import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings; import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemBuildManager; import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProgressNotificationManager; import org.jetbrains.annotations.NotNull; diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/wrapper/ExternalSystemFacadeWrapper.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/remote/wrapper/ExternalSystemFacadeWrapper.java similarity index 97% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/wrapper/ExternalSystemFacadeWrapper.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/remote/wrapper/ExternalSystemFacadeWrapper.java index 147935238bc4..25c6f313ac86 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/wrapper/ExternalSystemFacadeWrapper.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/remote/wrapper/ExternalSystemFacadeWrapper.java @@ -3,7 +3,7 @@ package com.intellij.openapi.externalSystem.service.remote.wrapper; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskType; import com.intellij.openapi.externalSystem.service.RemoteExternalSystemFacade; -import com.intellij.openapi.externalSystem.service.remote.ExternalSystemExecutionSettings; +import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings; import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemBuildManager; import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProgressNotificationManager; import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolver; diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/wrapper/ExternalSystemProjectResolverWrapper.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/remote/wrapper/ExternalSystemProjectResolverWrapper.java similarity index 97% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/wrapper/ExternalSystemProjectResolverWrapper.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/remote/wrapper/ExternalSystemProjectResolverWrapper.java index 2a641f76f709..878080baeb70 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/remote/wrapper/ExternalSystemProjectResolverWrapper.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/remote/wrapper/ExternalSystemProjectResolverWrapper.java @@ -4,7 +4,7 @@ import com.intellij.openapi.externalSystem.model.DataNode; import com.intellij.openapi.externalSystem.model.ExternalSystemException; import com.intellij.openapi.externalSystem.model.project.ProjectData; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId; -import com.intellij.openapi.externalSystem.service.remote.ExternalSystemExecutionSettings; +import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings; import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProgressNotificationManager; import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolver; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListener; diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalProjectConfigurable.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalProjectConfigurable.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalProjectConfigurable.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalProjectConfigurable.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/task/ExternalSystemTaskManager.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/task/ExternalSystemTaskManager.java similarity index 100% rename from platform/external-system/src/com/intellij/openapi/externalSystem/service/task/ExternalSystemTaskManager.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/task/ExternalSystemTaskManager.java diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/settings/ExternalSystemSettingsManager.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/settings/ExternalSystemSettingsManager.java similarity index 98% rename from platform/external-system/src/com/intellij/openapi/externalSystem/settings/ExternalSystemSettingsManager.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/settings/ExternalSystemSettingsManager.java index 2fbbbec2d607..c3acd21b8b1b 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/settings/ExternalSystemSettingsManager.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/settings/ExternalSystemSettingsManager.java @@ -17,8 +17,8 @@ package com.intellij.openapi.externalSystem.settings; import com.intellij.openapi.externalSystem.ExternalSystemManager; import com.intellij.openapi.externalSystem.model.ProjectSystemId; +import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings; import com.intellij.openapi.externalSystem.service.DisposableExternalSystemService; -import com.intellij.openapi.externalSystem.service.remote.ExternalSystemExecutionSettings; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.NotNullLazyValue; import com.intellij.util.Function; diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/util/ExternalSystemUiUtil.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUiUtil.java similarity index 59% rename from platform/external-system/src/com/intellij/openapi/externalSystem/util/ExternalSystemUiUtil.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUiUtil.java index 7495474f6517..8a7135ca3ca2 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/util/ExternalSystemUiUtil.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUiUtil.java @@ -16,16 +16,12 @@ package com.intellij.openapi.externalSystem.util; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.externalSystem.model.project.id.GradleSyntheticId; -import com.intellij.openapi.externalSystem.model.project.id.ProjectEntityId; -import com.intellij.openapi.externalSystem.ui.ProjectStructureNodeDescriptor; import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.ui.popup.Balloon; import com.intellij.openapi.ui.popup.BalloonBuilder; import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.ui.awt.RelativePoint; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; @@ -37,32 +33,6 @@ import java.util.concurrent.TimeUnit; */ public class ExternalSystemUiUtil { - public static final ProjectStructureNodeDescriptor DEPENDENCIES_NODE_DESCRIPTOR - = buildSyntheticDescriptor(ExternalSystemBundle.message("entity.type.dependencies")); - - public static final ProjectStructureNodeDescriptor MODULES_NODE_DESCRIPTOR - = buildSyntheticDescriptor(ExternalSystemBundle.message("entity.type.modules")); - - public static final ProjectStructureNodeDescriptor LIBRARIES_NODE_DESCRIPTOR - = buildSyntheticDescriptor(ExternalSystemBundle.message("entity.type.libraries")); - - private ExternalSystemUiUtil() { - } - - @NotNull - public static ProjectStructureNodeDescriptor buildDescriptor(@NotNull T id, @NotNull String name) { - return new ProjectStructureNodeDescriptor(id, name, id.getType().getIcon()); - } - - @NotNull - public static ProjectStructureNodeDescriptor buildSyntheticDescriptor(@NotNull String text) { - return buildSyntheticDescriptor(text, null); - } - - public static ProjectStructureNodeDescriptor buildSyntheticDescriptor(@NotNull String text, @Nullable Icon icon) { - return new ProjectStructureNodeDescriptor(new GradleSyntheticId(text), text, icon); - } - /** * Asks to show balloon that contains information related to the given component. * diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java similarity index 55% rename from platform/external-system/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java rename to platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java index 747f92221db3..e02959902248 100644 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java @@ -24,19 +24,15 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.PathManager; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.externalSystem.ExternalSystemManager; import com.intellij.openapi.externalSystem.model.DataNode; import com.intellij.openapi.externalSystem.model.ExternalSystemException; -import com.intellij.openapi.externalSystem.model.Key; import com.intellij.openapi.externalSystem.model.ProjectSystemId; import com.intellij.openapi.externalSystem.model.project.ProjectData; import com.intellij.openapi.externalSystem.model.project.ProjectEntityData; import com.intellij.openapi.externalSystem.model.task.ExternalSystemResolveProjectTask; import com.intellij.openapi.externalSystem.service.project.ModuleAwareContentRoot; -import com.intellij.openapi.externalSystem.service.project.manage.ProjectEntityChangeListener; import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings; import com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsManager; -import com.intellij.openapi.fileTypes.FileTypes; import com.intellij.openapi.module.Module; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; @@ -48,164 +44,36 @@ import com.intellij.openapi.projectRoots.ProjectJdkTable; import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.roots.LibraryOrderEntry; import com.intellij.openapi.roots.ModuleOrderEntry; -import com.intellij.openapi.roots.OrderRootType; import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.util.AtomicNotNullLazyValue; -import com.intellij.openapi.util.NotNullLazyValue; import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.openapi.vfs.JarFileSystem; -import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.wm.ToolWindow; import com.intellij.openapi.wm.ToolWindowManager; import com.intellij.ui.content.Content; import com.intellij.ui.content.ContentManager; -import com.intellij.util.BooleanFunction; import com.intellij.util.Consumer; -import com.intellij.util.PathUtil; import com.intellij.util.PathsList; -import com.intellij.util.containers.ContainerUtilRt; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; -import java.io.File; import java.io.PrintWriter; import java.io.StringWriter; -import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; +import java.util.Collections; +import java.util.List; /** * @author Denis Zhdanov - * @since 4/1/13 1:31 PM + * @since 4/22/13 9:36 AM */ public class ExternalSystemUtil { private static final Logger LOG = Logger.getInstance("#" + ExternalSystemUtil.class.getName()); - @NotNull public static final String PATH_SEPARATOR = "/"; - - @NotNull private static final Pattern ARTIFACT_PATTERN = Pattern.compile("(?:.*/)?(.+?)(?:-([\\d+](?:\\.[\\d]+)*))?(?:\\.[^\\.]+?)?"); - - @NotNull private static final NotNullLazyValue>> MANAGERS = - new AtomicNotNullLazyValue>>() { - @NotNull - @Override - protected Map> compute() { - Map> result = ContainerUtilRt.newHashMap(); - for (ExternalSystemManager manager : ExternalSystemManager.EP_NAME.getExtensions()) { - result.put(manager.getSystemId(), manager); - } - return result; - } - }; - - @NotNull public static final Comparator ORDER_AWARE_COMPARATOR = new Comparator() { - @Override - public int compare(Object o1, Object o2) { - int order1 = getOrder(o1); - int order2 = getOrder(o2); - return order1 > order2 ? 1 : order1 < order2 ? -1 : 0; - } - - private int getOrder(@NotNull Object o) { - Queue> toCheck = new ArrayDeque>(); - toCheck.add(o.getClass()); - while (!toCheck.isEmpty()) { - Class clazz = toCheck.poll(); - Order annotation = clazz.getAnnotation(Order.class); - if (annotation != null) { - return annotation.value(); - } - toCheck.add(clazz.getSuperclass()); - Class[] interfaces = clazz.getInterfaces(); - if (interfaces != null) { - Collections.addAll(toCheck, interfaces); - } - } - return ExternalSystemConstants.UNORDERED; - } - }; - - private ExternalSystemUtil() { } - /** - * @param path target path - * @return absolute path that points to the same location as the given one and that uses only slashes - */ - @NotNull - public static String toCanonicalPath(@NotNull String path) { - return PathUtil.getCanonicalPath(new File(path).getAbsolutePath()); - } - - @NotNull - public static String extractNameFromPath(@NotNull String path) { - String strippedPath = stripPath(path); - final int i = strippedPath.lastIndexOf(PATH_SEPARATOR); - final String result; - if (i < 0 || i >= strippedPath.length() - 1) { - result = strippedPath; - } - else { - result = strippedPath.substring(i + 1); - } - return result; - } - - @NotNull - private static String stripPath(@NotNull String path) { - String[] endingsToStrip = {"/", "!", ".jar"}; - StringBuilder buffer = new StringBuilder(path); - for (String ending : endingsToStrip) { - if (buffer.lastIndexOf(ending) == buffer.length() - ending.length()) { - buffer.setLength(buffer.length() - ending.length()); - } - } - return buffer.toString(); - } - - @NotNull - public static String getLibraryName(@NotNull Library library) { - final String result = library.getName(); - if (result != null) { - return result; - } - for (OrderRootType type : OrderRootType.getAllTypes()) { - for (String url : library.getUrls(type)) { - String candidate = extractNameFromPath(url); - if (!StringUtil.isEmpty(candidate)) { - return candidate; - } - } - } - assert false; - return "unknown-lib"; - } - - @Nullable - public static ArtifactInfo parseArtifactInfo(@NotNull String fileName) { - Matcher matcher = ARTIFACT_PATTERN.matcher(fileName); - if (!matcher.matches()) { - return null; - } - return new ArtifactInfo(matcher.group(1), null, matcher.group(2)); - } - - @NotNull - public static String getLocalFileSystemPath(@NotNull VirtualFile file) { - if (file.getFileType() == FileTypes.ARCHIVE) { - final VirtualFile jar = JarFileSystem.getInstance().getVirtualFileForJar(file); - if (jar != null) { - return jar.getPath(); - } - } - return file.getPath(); - } - /** * Tries to dispatch given entity via the given visitor. * @@ -248,72 +116,6 @@ public class ExternalSystemUtil { } } - public static void executeProjectChangeAction(@NotNull Project project, - @NotNull final ProjectSystemId externalSystemId, - @NotNull Object entityToChange, - @NotNull Runnable task) - { - executeProjectChangeAction(project, externalSystemId, entityToChange, false, task); - } - - public static void executeProjectChangeAction(@NotNull Project project, - @NotNull final ProjectSystemId externalSystemId, - @NotNull Object entityToChange, - boolean synchronous, - @NotNull Runnable task) - { - executeProjectChangeAction(project, externalSystemId, Collections.singleton(entityToChange), synchronous, task); - } - - public static void executeProjectChangeAction(@NotNull final Project project, - @NotNull final ProjectSystemId externalSystemId, - @NotNull final Iterable entitiesToChange, - @NotNull final Runnable task) - { - executeProjectChangeAction(project, externalSystemId, entitiesToChange, false, task); - } - - public static void executeProjectChangeAction(@NotNull final Project project, - @NotNull final ProjectSystemId externalSystemId, - @NotNull final Iterable entitiesToChange, - boolean synchronous, - @NotNull final Runnable task) - { - Runnable wrappedTask = new Runnable() { - public void run() { - ApplicationManager.getApplication().runWriteAction(new Runnable() { - @Override - public void run() { - final ProjectEntityChangeListener publisher = project.getMessageBus().syncPublisher(ProjectEntityChangeListener.TOPIC); - for (Object e : entitiesToChange) { - publisher.onChangeStart(e, externalSystemId); - } - try { - task.run(); - } - finally { - for (Object e : entitiesToChange) { - publisher.onChangeEnd(e, externalSystemId); - } - } - } - }); - } - }; - - if (synchronous) { - if (ApplicationManager.getApplication().isDispatchThread()) { - wrappedTask.run(); - } - else { - UIUtil.invokeAndWaitIfNeeded(wrappedTask); - } - } - else { - UIUtil.invokeLaterIfNeeded(wrappedTask); - } - } - @NotNull public static String getOutdatedEntityName(@NotNull String entityName, @NotNull String gradleVersion, @NotNull String ideVersion) { return String.format("%s (%s -> %s)", entityName, ideVersion, gradleVersion); @@ -380,11 +182,6 @@ public class ExternalSystemUtil { return null; } - @Nullable - public static ExternalSystemManager getManager(@NotNull ProjectSystemId externalSystemId) { - return MANAGERS.getValue().get(externalSystemId); - } - /** * Configures given classpath to reference target i18n bundle file(s). * @@ -427,102 +224,6 @@ public class ExternalSystemUtil { } } - @NotNull - public static Map, Collection>> group(@NotNull Collection> nodes) { - if (nodes.isEmpty()) { - return Collections.emptyMap(); - } - Map, Collection>> result = ContainerUtilRt.newHashMap(); - for (DataNode node : nodes) { - Collection> n = result.get(node.getKey()); - if (n == null) { - result.put(node.getKey(), n = ContainerUtilRt.newArrayList()); - } - n.add(node); - } - return result; - } - - @NotNull - public static Map, Collection>> groupBy(@NotNull Collection> nodes, @NotNull Key key) { - Map, Collection>> result = ContainerUtilRt.newHashMap(); - for (DataNode data : nodes) { - DataNode grouper = data.getDataNode(key); - if (grouper == null) { - LOG.warn(String.format( - "Skipping entry '%s' during grouping. Reason: it doesn't provide a value for key %s. Given entries: %s", - data, key, nodes - )); - continue; - } - Collection> grouped = result.get(grouper); - if (grouped == null) { - result.put(grouper, grouped = ContainerUtilRt.newArrayList()); - } - grouped.add(data); - } - return result; - } - - @SuppressWarnings("unchecked") - @NotNull - public static Collection> getChildren(@NotNull DataNode node, @NotNull Key key) { - Collection> result = null; - for (DataNode child : node.getChildren()) { - if (!key.equals(child.getKey())) { - continue; - } - if (result == null) { - result = ContainerUtilRt.newArrayList(); - } - result.add((DataNode)child); - } - return result == null ? Collections.>emptyList() : result; - } - - @SuppressWarnings("unchecked") - @Nullable - public static DataNode find(@NotNull DataNode node, @NotNull Key key) { - for (DataNode child : node.getChildren()) { - if (key.equals(child.getKey())) { - return (DataNode)child; - } - } - return null; - } - - @SuppressWarnings("unchecked") - @Nullable - public static DataNode find(@NotNull DataNode node, @NotNull Key key, BooleanFunction> predicate) { - for (DataNode child : node.getChildren()) { - if (key.equals(child.getKey()) && predicate.fun((DataNode)child)) { - return (DataNode)child; - } - } - return null; - } - - @SuppressWarnings("unchecked") - @NotNull - public static Collection> findAll(@NotNull DataNode parent, @NotNull Key key) { - Collection> result = null; - for (DataNode child : parent.getChildren()) { - if (!key.equals(child.getKey())) { - continue; - } - if (result == null) { - result = ContainerUtilRt.newArrayList(); - } - result.add((DataNode)child); - } - return result == null ? Collections.>emptyList() : result; - } - - @NotNull - public static String toReadableName(@NotNull ProjectSystemId id) { - return StringUtil.capitalize(id.toString().toLowerCase()); - } - public static void refreshProject(@NotNull Project project, @NotNull ProjectSystemId externalSystemId) { refreshProject(project, externalSystemId, new Ref()); } @@ -611,7 +312,7 @@ public class ExternalSystemUtil { if (StringUtil.isEmpty(message)) { errorMessageHolder.set(String.format( "Can't resolve %s project at '%s'. Reason: %s", - toReadableName(externalSystemId), externalProjectPath, message + ExternalSystemApiUtil.toReadableName(externalSystemId), externalProjectPath, message )); } else { @@ -634,7 +335,7 @@ public class ExternalSystemUtil { @Override public void run() { if (modal) { - String title = ExternalSystemBundle.message("progress.import.text", toReadableName(externalSystemId)); + String title = ExternalSystemBundle.message("progress.import.text", ExternalSystemApiUtil.toReadableName(externalSystemId)); ProgressManager.getInstance().run(new Task.Modal(project, title, false) { @Override public void run(@NotNull ProgressIndicator indicator) { @@ -646,7 +347,7 @@ public class ExternalSystemUtil { }); } else { - String title = ExternalSystemBundle.message("progress.refresh.text", toReadableName(externalSystemId)); + String title = ExternalSystemBundle.message("progress.refresh.text", ExternalSystemApiUtil.toReadableName(externalSystemId)); ProgressManager.getInstance().run(new Task.Backgroundable(project, title) { @Override public void run(@NotNull ProgressIndicator indicator) { @@ -666,24 +367,5 @@ public class ExternalSystemUtil { void execute(@NotNull ProgressIndicator indicator); } - @Nullable - public static Sdk findJdk(@NotNull JavaSdkVersion version) { - JavaSdk javaSdk = JavaSdk.getInstance(); - List javaSdks = ProjectJdkTable.getInstance().getSdksOfType(javaSdk); - Sdk candidate = null; - for (Sdk sdk : javaSdks) { - JavaSdkVersion v = javaSdk.getVersion(sdk); - if (v == version) { - return sdk; - } - else if (candidate == null && v != null && version.getMaxLanguageLevel().isAtLeast(version.getMaxLanguageLevel())) { - candidate = sdk; - } - } - return candidate; - } - - public static void orderAwareSort(@NotNull List data) { - Collections.sort(data, ORDER_AWARE_COMPARATOR); - } + } diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/ExternalSystemDataKeys.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/ExternalSystemDataKeys.java deleted file mode 100644 index 983c38780e39..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/ExternalSystemDataKeys.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.intellij.openapi.externalSystem.model; - -import com.intellij.openapi.actionSystem.DataKey; -import com.intellij.openapi.externalSystem.ui.ProjectStructureNode; -import com.intellij.ui.treeStructure.Tree; -import com.intellij.openapi.externalSystem.ui.ExternalProjectStructureTreeModel; - -import java.util.Collection; - -/** - * @author Denis Zhdanov - * @since 2/7/12 11:19 AM - */ -public class ExternalSystemDataKeys { - - /** Key for obtaining 'external system project structure' tree. */ - public static final DataKey PROJECT_TREE = DataKey.create("external.system.project.tree"); - - /** Key for obtaining 'external system project structure' tree model. */ - public static final DataKey PROJECT_TREE_MODEL = DataKey.create("external.system.project.tree.model"); - - /** Key for obtaining currently selected nodes at the 'external system project structure' tree. */ - public static final DataKey>> PROJECT_TREE_SELECTED_NODE - = DataKey.create("gradle.sync.tree.node.selected"); - - /** Key for obtaining node under mouse cursor at the 'external system project structure' tree. */ - public static final DataKey> SYNC_TREE_NODE_UNDER_MOUSE - = DataKey.create("gradle.sync.tree.node.under.mouse"); - - // TODO den uncomment - -// public static final DataKey RECENT_TASKS_LIST = DataKey.create("gradle.recent.tasks.list"); - -// public static final DataKey ALL_TASKS_MODEL = DataKey.create("gradle.all.tasks.model"); - - private ExternalSystemDataKeys() { - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/AbstractCompositeData.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/AbstractCompositeData.java deleted file mode 100644 index a7afdfcf0234..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/AbstractCompositeData.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.model.project; - -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import org.jetbrains.annotations.NotNull; - -/** - * There is a possible case that the same entity (e.g. library or jar) has different versions at external system and ide side. - * We treat that not as two entities (external system- and ide-local) but as a single composite entity. This class is a base class - * for such types of entities. - *

- * Thread-safe. - * - * @author Denis Zhdanov - * @since 1/23/13 9:19 AM - */ -public abstract class AbstractCompositeData extends AbstractProjectEntityData { - - @NotNull private final E myExternalEntity; - @NotNull private final I myIdeEntity; - - public AbstractCompositeData(@NotNull E externalEntity, @NotNull I ideEntity) { - super(ProjectSystemId.IDE); - myExternalEntity = externalEntity; - myIdeEntity = ideEntity; - } - - @NotNull - public E getExternalEntity() { - return myExternalEntity; - } - - @NotNull - public I getIdeEntity() { - return myIdeEntity; - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + myExternalEntity.hashCode(); - result = 31 * result + myIdeEntity.hashCode(); - return result; - } - - @Override - public boolean equals(Object o) { - if (!super.equals(o)) return false; - - AbstractCompositeData entity = (AbstractCompositeData)o; - - if (!myExternalEntity.equals(entity.myExternalEntity)) return false; - if (!myIdeEntity.equals(entity.myIdeEntity)) return false; - - return true; - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/CompositeLibraryDependencyData.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/CompositeLibraryDependencyData.java deleted file mode 100644 index ff618a928c0f..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/CompositeLibraryDependencyData.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.model.project; - -import com.intellij.openapi.externalSystem.model.DataNode; -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.id.CompositeLibraryDependencyId; -import com.intellij.openapi.externalSystem.model.project.id.LibraryDependencyId; -import com.intellij.openapi.externalSystem.model.project.id.ProjectEntityId; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; -import com.intellij.openapi.roots.LibraryOrderEntry; -import com.intellij.openapi.roots.libraries.Library; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Stands for an entity which references two library dependencies. - * - * @author Denis Zhdanov - * @since 1/22/13 5:28 PM - */ -public class CompositeLibraryDependencyData extends AbstractCompositeData { - - public CompositeLibraryDependencyData(@NotNull LibraryDependencyData libraryDependencyData, - @NotNull LibraryOrderEntry ideLibraryDependency) - { - super(libraryDependencyData, ideLibraryDependency); - } - - @NotNull - @Override - public ProjectEntityId getId(@Nullable DataNode dataNode) { - Library library = getIdeEntity().getLibrary(); - assert library != null; - return new CompositeLibraryDependencyId( - new LibraryDependencyId(getOwner(), getExternalEntity().getOwnerModule().getName(), getExternalEntity().getName()), - new LibraryDependencyId(ProjectSystemId.IDE, getIdeEntity().getOwnerModule().getName(), ExternalSystemUtil.getLibraryName(library)) - ); - } - - @Override - public String toString() { - return String.format("composite library dependency - external: %s, ide: %s", getExternalEntity(), getIdeEntity()); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/ExternalEntityCloneContext.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/ExternalEntityCloneContext.java deleted file mode 100644 index 10556c4b42d9..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/ExternalEntityCloneContext.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.intellij.openapi.externalSystem.model.project; - -import com.intellij.util.containers.hash.HashMap; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.Map; - -/** - * We need to be able to perform cloning of external project entities. However, there is a possible case that particular entity - * encapsulates graph of other entities. For example, {@link ModuleData} has a number of - * {@link ModuleData#getDependencies() dependencies} where those dependencies can reference other modules that, in turn, also - * have dependencies. - *

- * The problem is that we need to ensure that particular entity is shared within a single entities graph (e.g. there should - * be a single shared instance of {@link ModuleData gradle module} after cloning). That's why we need some place to serve - * as a cache during cloning. This class serves that purpose. - * - * @author Denis Zhdanov - * @since 9/28/11 12:36 PM - */ -public class ExternalEntityCloneContext { - - private final Map myLibraries = new HashMap(); - private final Map myModules = new HashMap(); - - @Nullable - public LibraryData getLibrary(@NotNull LibraryData library) { - return myLibraries.get(library); - } - - public void store(@NotNull LibraryData key, @NotNull LibraryData value) { - myLibraries.put(key, value); - } - - @Nullable - public ModuleData getModule(@NotNull ModuleData module) { - return myModules.get(module); - } - - public void store(@NotNull ModuleData key, @NotNull ModuleData value) { - myModules.put(key, value); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/JarData.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/JarData.java deleted file mode 100644 index 302dff1aa3c3..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/JarData.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.intellij.openapi.externalSystem.model.project; - -import com.intellij.openapi.externalSystem.model.DataNode; -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.id.JarId; -import com.intellij.openapi.externalSystem.model.project.id.LibraryId; -import com.intellij.openapi.externalSystem.model.project.id.ProjectEntityId; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; -import com.intellij.openapi.roots.libraries.Library; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * @author Denis Zhdanov - * @since 12/11/12 3:07 PM - */ -public class JarData extends AbstractNamedData { - - @NotNull private final String myPath; - - @Nullable private final Library myIdeLibrary; - @Nullable private final LibraryData myLibraryData; - @NotNull private final LibraryPathType myPathType; - @Nullable private final ProjectSystemId myExternalSystemId; - - public JarData(@NotNull String path, - @NotNull LibraryPathType pathType, - @Nullable Library ideLibrary, - @Nullable LibraryData libraryData, - @Nullable ProjectSystemId owner) - { - super(ExternalSystemUtil.detectOwner(libraryData, ideLibrary), ExternalSystemUtil.extractNameFromPath(path)); - myPathType = pathType; - myExternalSystemId = owner; - assert ideLibrary == null ^ libraryData == null; - myPath = path; - myIdeLibrary = ideLibrary; - myLibraryData = libraryData; - } - - @NotNull - @Override - public ProjectEntityId getId(@Nullable DataNode dataNode) { - return getId(); - } - - @NotNull - public String getPath() { - return myPath; - } - - @NotNull - public LibraryPathType getPathType() { - return myPathType; - } - - @NotNull - public JarId getId() { - return new JarId(myPath, myPathType, getLibraryId()); - } - - @NotNull - public LibraryId getLibraryId() { - if (myIdeLibrary != null) { - return new LibraryId(ProjectSystemId.IDE, ExternalSystemUtil.getLibraryName(myIdeLibrary)); - } - assert myExternalSystemId != null; - assert myLibraryData != null; - return new LibraryId(myExternalSystemId, myLibraryData.getName()); - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + myPath.hashCode(); - result = 31 * result + myPathType.hashCode(); - result = 31 * result + (myIdeLibrary != null ? myIdeLibrary.hashCode() : 0); - result = 31 * result + (myLibraryData != null ? myLibraryData.hashCode() : 0); - return result; - } - - @Override - public boolean equals(Object o) { - if (!super.equals(o)) return false; - - JarData that = (JarData)o; - - if (!myPath.equals(that.myPath)) return false; - if (!myPathType.equals(that.myPathType)) return false; - if (myLibraryData != null ? !myLibraryData.equals(that.myLibraryData) : that.myLibraryData != null) return false; - if (myIdeLibrary == null && that.myIdeLibrary != null) { - return false; - } - else if (myIdeLibrary != null) { - if (that.myIdeLibrary == null) { - return false; - } - else if (!ExternalSystemUtil.getLibraryName(myIdeLibrary).equals(ExternalSystemUtil.getLibraryName(that.myIdeLibrary))) { - return false; - } - } - return true; - } - - @SuppressWarnings("ConstantConditions") - @Override - public String toString() { - return String.format( - "%s jar at '%s'. Belongs to library '%s'", - myPathType.toString().toLowerCase(), myPath, - myIdeLibrary == null ? myLibraryData.getName() : ExternalSystemUtil.getLibraryName(myIdeLibrary) - ); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/LibraryDependencyData.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/LibraryDependencyData.java deleted file mode 100644 index b5344599d34e..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/LibraryDependencyData.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.intellij.openapi.externalSystem.model.project; - -import com.intellij.openapi.externalSystem.model.DataNode; -import com.intellij.openapi.externalSystem.model.project.id.LibraryDependencyId; -import com.intellij.openapi.externalSystem.model.project.id.ProjectEntityId; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Not thread-safe. - * - * @author Denis Zhdanov - * @since 8/10/11 6:46 PM - */ -public class LibraryDependencyData extends AbstractDependencyData implements Named { - - public LibraryDependencyData(@NotNull ModuleData ownerModule, @NotNull LibraryData library) { - super(ownerModule, library); - } - - @NotNull - @Override - public ProjectEntityId getId(@Nullable DataNode dataNode) { - return new LibraryDependencyId(getOwner(), getOwnerModule().getName(), getName()); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/ProjectEntityType.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/ProjectEntityType.java deleted file mode 100644 index 0b8308d1f612..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/ProjectEntityType.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.intellij.openapi.externalSystem.model.project; - -import com.intellij.icons.AllIcons; -import com.intellij.openapi.application.ex.ApplicationInfoEx; -import com.intellij.openapi.util.IconLoader; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import javax.swing.*; - -/** - * @author Denis Zhdanov - * @since 2/7/12 11:18 AM - */ -public class ProjectEntityType { - - @NotNull public static final ProjectEntityType PROJECT = new ProjectEntityType("PROJECT", getProjectIcon()); - @NotNull public static final ProjectEntityType MODULE = new ProjectEntityType("MODULE", AllIcons.Nodes.Module); - @NotNull public static final ProjectEntityType MODULE_DEPENDENCY = new ProjectEntityType("MODULE_DEPENDENCY", MODULE.getIcon()); - @NotNull public static final ProjectEntityType LIBRARY = new ProjectEntityType("LIBRARY", AllIcons.Nodes.PpLib); - @NotNull public static final ProjectEntityType LIBRARY_DEPENDENCY = new ProjectEntityType("LIBRARY_DEPENDENCY", LIBRARY.getIcon()); - @NotNull public static final ProjectEntityType CONTENT_ROOT = new ProjectEntityType("CONTENT_ROOT", null); - @NotNull public static final ProjectEntityType SYNTHETIC = new ProjectEntityType("SYNTHETIC", null); - @NotNull public static final ProjectEntityType JAR = new ProjectEntityType("JAR", AllIcons.FileTypes.Archive); - - @NotNull public static final ProjectEntityType DEPENDENCY_TO_OUTDATED_LIBRARY = new ProjectEntityType( - "DEPENDENCY_TO_OUTDATED_LIBRARY", LIBRARY.getIcon() - ); - - @NotNull private final String myId; - @Nullable private final Icon myIcon; - - ProjectEntityType(@NotNull String id, @Nullable Icon icon) { - myId = id; - myIcon = icon; - } - - @Nullable - public Icon getIcon() { - return myIcon; - } - - @NotNull - public String getId() { - return myId; - } - - @Override - public int hashCode() { - return myId.hashCode(); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ProjectEntityType type = (ProjectEntityType)o; - - if (!myId.equals(type.myId)) return false; - - return true; - } - - @Override - public String toString() { - return myId; - } - - @NotNull - private static Icon getProjectIcon() { - try { - return IconLoader.getIcon(ApplicationInfoEx.getInstanceEx().getSmallIconUrl()); - } - catch (Exception e) { - // Control flow may reach this place if we run tests and platform IoC has not been initialised. - return IconLoader.getIcon("/nodes/ideProject.png"); - } - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/AbstractConflictingPropertyChange.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/AbstractConflictingPropertyChange.java deleted file mode 100644 index 639d35513cf4..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/AbstractConflictingPropertyChange.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2000-2011 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.model.project.change; - -import com.intellij.openapi.externalSystem.model.project.id.ProjectEntityId; -import org.jetbrains.annotations.NotNull; - -/** - * Defines general contract for a change that encapsulates information about conflicting property value of the matched external system - * and ide entities. - *

- * For example we may match particular external system library to an ide library but they may have different set of attached binaries. - *

- * Thread-safe. - * - * @author Denis Zhdanov - * @since 11/15/11 7:57 PM - * @param target property value type - */ -public abstract class AbstractConflictingPropertyChange extends AbstractExternalProjectStructureChange { - - @NotNull private final ProjectEntityId myEntityId; - @NotNull private final String myPropertyDescription; - @NotNull private final T myExternalValue; - @NotNull private final T myIdeValue; - - public AbstractConflictingPropertyChange(@NotNull ProjectEntityId id, - @NotNull String propertyDescription, - @NotNull T externalValue, - @NotNull T ideValue) - { - myEntityId = id; - myPropertyDescription = propertyDescription; - myExternalValue = externalValue; - myIdeValue = ideValue; - } - - @NotNull - public ProjectEntityId getEntityId() { - return myEntityId; - } - - /** - * @return target property's value at external system side - */ - @NotNull - public T getExternalValue() { - return myExternalValue; - } - - /** - * @return target property's value at ide side - */ - @NotNull - public T getIdeValue() { - return myIdeValue; - } - - @Override - public int hashCode() { - int result = 31 * super.hashCode() + myEntityId.hashCode(); - result = 31 * result + myExternalValue.hashCode(); - return 31 * result + myIdeValue.hashCode(); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - if (!super.equals(o)) return false; - - AbstractConflictingPropertyChange that = (AbstractConflictingPropertyChange)o; - - return myEntityId.equals(that.myEntityId) && myExternalValue.equals(that.myExternalValue) && myIdeValue.equals(that.myIdeValue); - } - - @Override - public String toString() { - return String.format("%s change: external='%s', ide='%s'", myPropertyDescription, myExternalValue, myIdeValue); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/AbstractExternalProjectStructureChange.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/AbstractExternalProjectStructureChange.java deleted file mode 100644 index 4f2e825ad22a..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/AbstractExternalProjectStructureChange.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2000-2011 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.model.project.change; - -import com.intellij.openapi.externalSystem.model.project.change.ExternalProjectStructureChange; - -/** - * @author Denis Zhdanov - * @since 11/15/11 1:33 PM - */ -public abstract class AbstractExternalProjectStructureChange implements ExternalProjectStructureChange { - - @Override - public int hashCode() { - return 31; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - return o != null && getClass() == o.getClass(); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/AbstractProjectEntityPresenceChange.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/AbstractProjectEntityPresenceChange.java deleted file mode 100644 index d63d76a98979..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/AbstractProjectEntityPresenceChange.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2000-2011 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.model.project.change; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Defines common interface for a change that indicates that particular entity has been added/removed at Gradle or IntelliJ IDEA. - *

- * Thread-safe. - * - * @author Denis Zhdanov - * @since 11/17/11 12:43 PM - * @param entity type - */ -public abstract class AbstractProjectEntityPresenceChange extends AbstractExternalProjectStructureChange { - - private final T myExternalEntity; - private final T myIdeEntity; - private final String myEntityName; - - /** - * Creates new AbstractProjectEntityPresenceChange change. - * - * @param externalEntity target entity at external system side. null as indication that the entity was - * removed at external system side or added at ide side - * @param ideEntity target entity at ide side. null as indication that the entity was removed - * at ide side or added at ide side - * @throws IllegalArgumentException if both of the given entities are defined or undefined. Expecting this constructor to be - * called with one null argument and one non-null argument - */ - public AbstractProjectEntityPresenceChange(@NotNull String entityName, - @Nullable T externalEntity, - @Nullable T ideEntity) - throws IllegalArgumentException - { - if (!(externalEntity == null ^ ideEntity == null)) { - throw new IllegalArgumentException(String.format( - "Can't construct %s object. Reason: expected that only gradle or ide entity is null, actual: external='%s'; ide='%s'", - getClass(), externalEntity, ideEntity - )); - } - myExternalEntity = externalEntity; - myIdeEntity = ideEntity; - myEntityName = entityName; - } - - @Nullable - public T getExternalEntity() { - return myExternalEntity; - } - - @Nullable - public T getIdeEntity() { - return myIdeEntity; - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + (myExternalEntity != null ? myExternalEntity.hashCode() : 0); - return 31 * result + (myIdeEntity != null ? myIdeEntity.hashCode() : 0); - } - - @SuppressWarnings("EqualsWhichDoesntCheckParameterClass") - @Override - public boolean equals(Object o) { - if (!super.equals(o)) return false; - - AbstractProjectEntityPresenceChange that = (AbstractProjectEntityPresenceChange)o; - - if (myExternalEntity != null ? !myExternalEntity.equals(that.myExternalEntity) : that.myExternalEntity != null) return false; - if (myIdeEntity != null ? !myIdeEntity.equals(that.myIdeEntity) : that.myIdeEntity != null) return false; - - return true; - } - - @Override - public String toString() { - return String.format("%s presence change: external='%s', ide='%s'", myEntityName, myExternalEntity, myIdeEntity); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/ContentRootPresenceChange.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/ContentRootPresenceChange.java deleted file mode 100644 index 6a617238dfb7..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/ContentRootPresenceChange.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.intellij.openapi.externalSystem.model.project.change; - -import com.intellij.openapi.externalSystem.model.project.ContentRootData; -import com.intellij.openapi.externalSystem.model.project.id.ContentRootId; -import com.intellij.openapi.externalSystem.model.project.id.EntityIdMapper; -import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; -import com.intellij.openapi.roots.ContentEntry; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * @author Denis Zhdanov - * @since 2/22/12 5:12 PM - */ -public class ContentRootPresenceChange extends AbstractProjectEntityPresenceChange { - - public ContentRootPresenceChange(@Nullable ContentRootData gradleEntity, @Nullable ContentEntry intellijEntity) - throws IllegalArgumentException - { - super(ExternalSystemBundle.message("entity.type.content.root"), of(gradleEntity), of(intellijEntity)); - } - - @Nullable - private static ContentRootId of(@Nullable Object contentRoot) { - if (contentRoot == null) { - return null; - } - return EntityIdMapper.mapEntityToId(contentRoot); - } - - @Override - public void invite(@NotNull ExternalProjectStructureChangeVisitor visitor) { - visitor.visit(this); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/DependencyExportedChange.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/DependencyExportedChange.java deleted file mode 100644 index 3aa9f47ac799..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/DependencyExportedChange.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.intellij.openapi.externalSystem.model.project.change; - -import com.intellij.openapi.externalSystem.model.project.id.AbstractExternalDependencyId; -import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; -import org.jetbrains.annotations.NotNull; - -/** - * @author Denis Zhdanov - * @since 3/14/12 1:34 PM - */ -public class DependencyExportedChange extends AbstractConflictingPropertyChange { - - public DependencyExportedChange(@NotNull AbstractExternalDependencyId id, boolean gradleValue, boolean intellijValue) { - super(id, ExternalSystemBundle.message("change.dependency.exported", id), gradleValue, intellijValue); - } - - @NotNull - @Override - public AbstractExternalDependencyId getEntityId() { - return (AbstractExternalDependencyId)super.getEntityId(); - } - - @Override - public void invite(@NotNull ExternalProjectStructureChangeVisitor visitor) { - visitor.visit(this); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/DependencyScopeChange.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/DependencyScopeChange.java deleted file mode 100644 index b462756ee1ba..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/DependencyScopeChange.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.intellij.openapi.externalSystem.model.project.change; - -import com.intellij.openapi.externalSystem.model.project.id.AbstractExternalDependencyId; -import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; -import com.intellij.openapi.roots.DependencyScope; -import org.jetbrains.annotations.NotNull; - -/** - * @author Denis Zhdanov - * @since 3/12/12 6:02 PM - */ -public class DependencyScopeChange extends AbstractConflictingPropertyChange { - - public DependencyScopeChange(@NotNull AbstractExternalDependencyId id, - @NotNull DependencyScope gradleValue, - @NotNull DependencyScope intellijValue) - { - super(id, ExternalSystemBundle.message("change.dependency.scope", id), gradleValue, intellijValue); - } - - @NotNull - @Override - public AbstractExternalDependencyId getEntityId() { - return (AbstractExternalDependencyId)super.getEntityId(); - } - - @Override - public void invite(@NotNull ExternalProjectStructureChangeVisitor visitor) { - visitor.visit(this); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/ExternalProjectStructureChange.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/ExternalProjectStructureChange.java deleted file mode 100644 index 77c89a9f73c3..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/ExternalProjectStructureChange.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.intellij.openapi.externalSystem.model.project.change; - -import org.jetbrains.annotations.NotNull; - -/** - * Defines common interface for the change between Gradle and IntelliJ IDEA project structures. - *

- * Implementations of this interface are assumed to provide correct {@link #hashCode()}/{@link #equals(Object)}. - *

- * Implementations of this interface are not obliged to be thread-safe. - * - * @author Denis Zhdanov - * @since 11/3/11 3:54 PM - */ -public interface ExternalProjectStructureChange { - - /** - * Allows to perform double-dispatch of the current change object within the given visitor. - * - * @param visitor visitor to use - */ - void invite(@NotNull ExternalProjectStructureChangeVisitor visitor); -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/ExternalProjectStructureChangeVisitor.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/ExternalProjectStructureChangeVisitor.java deleted file mode 100644 index e62594b3a052..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/ExternalProjectStructureChangeVisitor.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2000-2011 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.model.project.change; - -import org.jetbrains.annotations.NotNull; - -/** - * Defines common interface for dispatching gradle project structure change objects. - * - * @author Denis Zhdanov - * @since 11/16/11 8:48 PM - */ -public interface ExternalProjectStructureChangeVisitor { - void visit(@NotNull GradleProjectRenameChange change); - void visit(@NotNull LanguageLevelChange change); - void visit(@NotNull ModulePresenceChange change); - void visit(@NotNull ContentRootPresenceChange change); - void visit(@NotNull LibraryDependencyPresenceChange change); - void visit(@NotNull JarPresenceChange change); - void visit(@NotNull OutdatedLibraryVersionChange change); - void visit(@NotNull ModuleDependencyPresenceChange change); - void visit(@NotNull DependencyScopeChange change); - void visit(@NotNull DependencyExportedChange change); -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/ExternalProjectStructureChangeVisitorAdapter.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/ExternalProjectStructureChangeVisitorAdapter.java deleted file mode 100644 index 0bce40453b9f..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/ExternalProjectStructureChangeVisitorAdapter.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.intellij.openapi.externalSystem.model.project.change; - -import org.jetbrains.annotations.NotNull; - -/** - * @author Denis Zhdanov - * @since 3/2/12 4:21 PM - */ -public abstract class ExternalProjectStructureChangeVisitorAdapter implements ExternalProjectStructureChangeVisitor { - @Override - public void visit(@NotNull GradleProjectRenameChange change) { - } - - @Override - public void visit(@NotNull LanguageLevelChange change) { - } - - @Override - public void visit(@NotNull ModulePresenceChange change) { - } - - @Override - public void visit(@NotNull ContentRootPresenceChange change) { - } - - @Override - public void visit(@NotNull LibraryDependencyPresenceChange change) { - } - - @Override - public void visit(@NotNull JarPresenceChange change) { - } - - @Override - public void visit(@NotNull OutdatedLibraryVersionChange change) { - } - - @Override - public void visit(@NotNull ModuleDependencyPresenceChange change) { - } - - @Override - public void visit(@NotNull DependencyScopeChange change) { - } - - @Override - public void visit(@NotNull DependencyExportedChange change) { - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/ExternalProjectStructureChangesCalculator.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/ExternalProjectStructureChangesCalculator.java deleted file mode 100644 index d391e124c053..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/ExternalProjectStructureChangesCalculator.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.intellij.openapi.externalSystem.model.project.change; - -import com.intellij.openapi.externalSystem.model.project.ProjectEntityData; -import com.intellij.openapi.externalSystem.service.project.change.ExternalProjectChangesCalculationContext; -import org.jetbrains.annotations.NotNull; - -/** - * Defines common interface to the strategy that calculates difference between the corresponding external system and ide entities - * (e.g. between an external and ide module). - *

- * Implementations of this interface are expected to be thread-safe. - * - * @author Denis Zhdanov - * @since 1/24/12 12:15 PM - * @param target intellij entity type - * @param target gradle entity type - */ -public interface ExternalProjectStructureChangesCalculator { - - /** - * Calculates changes between the given entities. - * - * @param externalEntity target external system entity - * @param ideEntity target ide entity - * @param context target diff calculation context - */ - void calculate(@NotNull G externalEntity, @NotNull I ideEntity, @NotNull ExternalProjectChangesCalculationContext context); -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/GradleProjectRenameChange.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/GradleProjectRenameChange.java deleted file mode 100644 index 8c479335cc3d..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/GradleProjectRenameChange.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.intellij.openapi.externalSystem.model.project.change; - -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.id.ProjectId; -import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; -import org.jetbrains.annotations.NotNull; - -/** - * Describes project name change. - * - * @author Denis Zhdanov - * @since 11/3/11 3:54 PM - */ -public class GradleProjectRenameChange extends AbstractConflictingPropertyChange { - - public GradleProjectRenameChange(@NotNull String gradleName, @NotNull String intellijName) { - super(new ProjectId(ProjectSystemId.IDE), ExternalSystemBundle.message("change.project.name"), gradleName, intellijName); - } - - @Override - public void invite(@NotNull ExternalProjectStructureChangeVisitor visitor) { - visitor.visit(this); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/JarPresenceChange.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/JarPresenceChange.java deleted file mode 100644 index 6e37443771a6..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/JarPresenceChange.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.intellij.openapi.externalSystem.model.project.change; - -import com.intellij.openapi.externalSystem.model.project.id.JarId; -import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * @author Denis Zhdanov - * @since 12/11/12 7:52 PM - */ -public class JarPresenceChange extends AbstractProjectEntityPresenceChange { - - public JarPresenceChange(@Nullable JarId gradleEntity, @Nullable JarId ideEntity) { - super(ExternalSystemBundle.message("entity.type.jar"), gradleEntity, ideEntity); - } - - @Override - public void invite(@NotNull ExternalProjectStructureChangeVisitor visitor) { - visitor.visit(this); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/LanguageLevelChange.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/LanguageLevelChange.java deleted file mode 100644 index f8472d95e468..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/LanguageLevelChange.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2000-2011 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.model.project.change; - -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.id.ProjectId; -import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; -import com.intellij.pom.java.LanguageLevel; -import org.jetbrains.annotations.NotNull; - -/** - * @author Denis Zhdanov - * @since 11/15/11 8:05 PM - */ -public class LanguageLevelChange extends AbstractConflictingPropertyChange { - - public LanguageLevelChange(@NotNull LanguageLevel gradleValue, @NotNull LanguageLevel intellijValue) { - super(new ProjectId(ProjectSystemId.IDE), ExternalSystemBundle.message("change.project.language.level"), gradleValue, intellijValue); - } - - @Override - public void invite(@NotNull ExternalProjectStructureChangeVisitor visitor) { - visitor.visit(this); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/LibraryDependencyPresenceChange.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/LibraryDependencyPresenceChange.java deleted file mode 100644 index 0502252b99ea..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/LibraryDependencyPresenceChange.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.intellij.openapi.externalSystem.model.project.change; - -import com.intellij.openapi.externalSystem.model.project.LibraryDependencyData; -import com.intellij.openapi.externalSystem.model.project.id.EntityIdMapper; -import com.intellij.openapi.externalSystem.model.project.id.LibraryDependencyId; -import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; -import com.intellij.openapi.roots.LibraryOrderEntry; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Thread-safe. - * - * @author Denis Zhdanov - * @since 1/24/12 9:48 AM - */ -public class LibraryDependencyPresenceChange extends AbstractProjectEntityPresenceChange { - - public LibraryDependencyPresenceChange(@Nullable LibraryDependencyData gradleDependency, - @Nullable LibraryOrderEntry intellijDependency) throws IllegalArgumentException - { - super(ExternalSystemBundle.message("entity.type.library.dependency"), of(gradleDependency), of(intellijDependency)); - } - - @Override - public void invite(@NotNull ExternalProjectStructureChangeVisitor visitor) { - visitor.visit(this); - } - - @Nullable - private static LibraryDependencyId of(@Nullable Object dependency) { - if (dependency == null) { - return null; - } - return EntityIdMapper.mapEntityToId(dependency); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/ModuleDependencyPresenceChange.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/ModuleDependencyPresenceChange.java deleted file mode 100644 index b258c9538d77..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/ModuleDependencyPresenceChange.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.intellij.openapi.externalSystem.model.project.change; - -import com.intellij.openapi.externalSystem.model.project.ModuleDependencyData; -import com.intellij.openapi.externalSystem.model.project.id.EntityIdMapper; -import com.intellij.openapi.externalSystem.model.project.id.ModuleDependencyId; -import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; -import com.intellij.openapi.roots.ModuleOrderEntry; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * @author Denis Zhdanov - * @since 2/17/12 3:14 PM - */ -public class ModuleDependencyPresenceChange extends AbstractProjectEntityPresenceChange { - - public ModuleDependencyPresenceChange(@Nullable ModuleDependencyData gradle, @Nullable ModuleOrderEntry intellij) { - super(ExternalSystemBundle.message("entity.type.module.dependency"), of(gradle), of(intellij)); - } - - @Override - public void invite(@NotNull ExternalProjectStructureChangeVisitor visitor) { - visitor.visit(this); - } - - @Nullable - private static ModuleDependencyId of(@Nullable Object dependency) { - if (dependency == null) { - return null; - } - return EntityIdMapper.mapEntityToId(dependency); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/ModulePresenceChange.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/ModulePresenceChange.java deleted file mode 100644 index 72c369ca224c..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/ModulePresenceChange.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2000-2011 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.model.project.change; - -import com.intellij.openapi.externalSystem.model.project.ModuleData; -import com.intellij.openapi.externalSystem.model.project.id.EntityIdMapper; -import com.intellij.openapi.externalSystem.model.project.id.ModuleId; -import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; -import com.intellij.openapi.module.Module; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * @author Denis Zhdanov - * @since 11/17/11 12:50 PM - */ -public class ModulePresenceChange extends AbstractProjectEntityPresenceChange { - - public ModulePresenceChange(@Nullable ModuleData externalModule, @Nullable Module ideModule) - throws IllegalArgumentException - { - super(ExternalSystemBundle.message("entity.type.module"), of(externalModule), of(ideModule)); - } - - @Override - public void invite(@NotNull ExternalProjectStructureChangeVisitor visitor) { - visitor.visit(this); - } - - @Nullable - private static ModuleId of(@Nullable Object module) { - if (module == null) { - return null; - } - return EntityIdMapper.mapEntityToId(module); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/OutdatedLibraryVersionChange.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/OutdatedLibraryVersionChange.java deleted file mode 100644 index 00352548bcd4..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/OutdatedLibraryVersionChange.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.model.project.change; - -import org.jetbrains.annotations.NotNull; -import com.intellij.openapi.externalSystem.model.project.id.LibraryId; - -/** - * There is a possible case that particular library has different versions at external system and ide sides. Object of this class - * encapsulates that information. - * - * @author Denis Zhdanov - * @since 1/22/13 12:21 PM - */ -public class OutdatedLibraryVersionChange extends AbstractExternalProjectStructureChange { - - @NotNull private final String myBaseLibraryName; - @NotNull private final LibraryId myLibraryId; - @NotNull private final String myExternalLibraryVersion; - @NotNull private final LibraryId myIdeLibraryId; - @NotNull private final String myIdeLibraryVersion; - - public OutdatedLibraryVersionChange(@NotNull String baseLibraryName, - @NotNull LibraryId libraryId, - @NotNull String externalLibraryVersion, - @NotNull LibraryId ideLibraryId, - @NotNull String ideLibraryVersion) - { - myBaseLibraryName = baseLibraryName; - myLibraryId = libraryId; - myExternalLibraryVersion = externalLibraryVersion; - myIdeLibraryId = ideLibraryId; - myIdeLibraryVersion = ideLibraryVersion; - } - - @NotNull - public String getBaseLibraryName() { - return myBaseLibraryName; - } - - @NotNull - public LibraryId getLibraryId() { - return myLibraryId; - } - - @NotNull - public String getExternalLibraryVersion() { - return myExternalLibraryVersion; - } - - @NotNull - public LibraryId getIdeLibraryId() { - return myIdeLibraryId; - } - - @NotNull - public String getIdeLibraryVersion() { - return myIdeLibraryVersion; - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + myBaseLibraryName.hashCode(); - result = 31 * result + myLibraryId.hashCode(); - result = 31 * result + myExternalLibraryVersion.hashCode(); - result = 31 * result + myIdeLibraryId.hashCode(); - result = 31 * result + myIdeLibraryVersion.hashCode(); - return result; - } - - @Override - public boolean equals(Object o) { - if (!super.equals(o)) return false; - - OutdatedLibraryVersionChange change = (OutdatedLibraryVersionChange)o; - - if (!myBaseLibraryName.equals(change.myBaseLibraryName)) return false; - if (!myLibraryId.equals(change.myLibraryId)) return false; - if (!myExternalLibraryVersion.equals(change.myExternalLibraryVersion)) return false; - if (!myIdeLibraryId.equals(change.myIdeLibraryId)) return false; - if (!myIdeLibraryVersion.equals(change.myIdeLibraryVersion)) return false; - - return true; - } - - @Override - public void invite(@NotNull ExternalProjectStructureChangeVisitor visitor) { - visitor.visit(this); - } - - @Override - public String toString() { - return String.format("'%s' library version change: '%s' -> '%s'", myBaseLibraryName, myIdeLibraryVersion, myExternalLibraryVersion); - } -} \ No newline at end of file diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/AbstractDependencyAwareUserChange.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/AbstractDependencyAwareUserChange.java deleted file mode 100644 index 30bff617891c..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/AbstractDependencyAwareUserChange.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.model.project.change.user; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * @author Denis Zhdanov - * @since 2/19/13 8:54 AM - */ -public abstract class AbstractDependencyAwareUserChange> - extends AbstractModuleAwareUserChange -{ - - @Nullable - private String myDependencyName; - - protected AbstractDependencyAwareUserChange() { - // Required for IJ serialization - } - - @SuppressWarnings("NullableProblems") - protected AbstractDependencyAwareUserChange(@NotNull String moduleName, @NotNull String dependencyName) { - super(moduleName); - myDependencyName = dependencyName; - } - - @Nullable - public String getDependencyName() { - return myDependencyName; - } - - public void setDependencyName(@Nullable String dependencyName) { - myDependencyName = dependencyName; - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + (myDependencyName != null ? myDependencyName.hashCode() : 0); - return result; - } - - @Override - public boolean equals(Object o) { - if (!super.equals(o)) return false; - - AbstractDependencyAwareUserChange change = (AbstractDependencyAwareUserChange)o; - - if (myDependencyName != null ? !myDependencyName.equals(change.myDependencyName) : change.myDependencyName != null) return false; - - return true; - } - - @SuppressWarnings({"unchecked"}) - @Override - public int compareTo(@NotNull UserProjectChange o) { - int cmp = super.compareTo(o); - if (cmp != 0 || (!(o instanceof AbstractDependencyAwareUserChange))) { - return cmp; - } - - AbstractDependencyAwareUserChange that = (AbstractDependencyAwareUserChange)o; - if (myDependencyName == null) { - return that.myDependencyName == null ? 0 : 1; - } - else if (that.myDependencyName == null) { - return -1; - } - else { - return myDependencyName.compareTo(that.myDependencyName); - } - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/AbstractDependencyExportedUserChange.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/AbstractDependencyExportedUserChange.java deleted file mode 100644 index 8bbefc552d61..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/AbstractDependencyExportedUserChange.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.model.project.change.user; - -import org.jetbrains.annotations.NotNull; - -/** - * @author Denis Zhdanov - * @since 3/4/13 12:17 PM - */ -public abstract class AbstractDependencyExportedUserChange> - extends AbstractDependencyAwareUserChange -{ - private boolean myExported; - - protected AbstractDependencyExportedUserChange() { - // Required for IJ serialization - } - - protected AbstractDependencyExportedUserChange(@NotNull String moduleName, @NotNull String dependencyName, boolean exported) { - super(moduleName, dependencyName); - myExported = exported; - } - - public boolean isExported() { - return myExported; - } - - @SuppressWarnings("UnusedDeclaration") - public void setExported(boolean exported) { - myExported = exported; - } - - @Override - public int hashCode() { - int result = super.hashCode(); - return 31 * result + (myExported ? 1 : 0); - } - - @Override - public boolean equals(Object o) { - if (!super.equals(o)) return false; - - AbstractDependencyExportedUserChange change = (AbstractDependencyExportedUserChange)o; - - return myExported == change.myExported; - } - - @SuppressWarnings({"unchecked"}) - @Override - public int compareTo(@NotNull UserProjectChange o) { - int cmp = super.compareTo(o); - if (cmp != 0 || (!(o instanceof AbstractDependencyExportedUserChange))) { - return cmp; - } - - AbstractDependencyExportedUserChange that = (AbstractDependencyExportedUserChange)o; - if (myExported) { - return that.myExported ? 0 : 1; - } - else { - return that.myExported ? -1 : 0; - } - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/AbstractDependencyScopeUserChange.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/AbstractDependencyScopeUserChange.java deleted file mode 100644 index 0aac800ac994..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/AbstractDependencyScopeUserChange.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.model.project.change.user; - -import com.intellij.openapi.roots.DependencyScope; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * @author Denis Zhdanov - * @since 3/4/13 12:08 PM - */ -public abstract class AbstractDependencyScopeUserChange> - extends AbstractDependencyAwareUserChange -{ - @Nullable - private DependencyScope myScope; - - protected AbstractDependencyScopeUserChange() { - // Required for IJ serialization - } - - @SuppressWarnings("NullableProblems") - protected AbstractDependencyScopeUserChange(@NotNull String moduleName, - @NotNull String dependencyName, - @NotNull DependencyScope scope) - { - super(moduleName, dependencyName); - myScope = scope; - } - - @Nullable - public DependencyScope getScope() { - return myScope; - } - - @SuppressWarnings("UnusedDeclaration") - public void setScope(@Nullable DependencyScope scope) { - myScope = scope; - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + (myScope != null ? myScope.hashCode() : 0); - return result; - } - - @Override - public boolean equals(Object o) { - if (!super.equals(o)) return false; - - AbstractDependencyScopeUserChange change = (AbstractDependencyScopeUserChange)o; - - if (myScope != null ? !myScope.equals(change.myScope) : change.myScope != null) return false; - - return true; - } - - @SuppressWarnings({"unchecked"}) - @Override - public int compareTo(@NotNull UserProjectChange o) { - int cmp = super.compareTo(o); - if (cmp != 0 || (!(o instanceof AbstractDependencyScopeUserChange))) { - return cmp; - } - - AbstractDependencyScopeUserChange that = (AbstractDependencyScopeUserChange)o; - if (myScope == null) { - return that.myScope == null ? 0 : 1; - } - else if (that.myScope == null) { - return -1; - } - else { - return myScope.compareTo(that.myScope); - } - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/AbstractModuleAwareUserChange.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/AbstractModuleAwareUserChange.java deleted file mode 100644 index 0b6421cb0875..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/AbstractModuleAwareUserChange.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.model.project.change.user; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * @author Denis Zhdanov - * @since 2/19/13 8:48 AM - */ -public abstract class AbstractModuleAwareUserChange> extends AbstractUserProjectChange { - - @Nullable - private String myModuleName; - - @SuppressWarnings("UnusedDeclaration") - protected AbstractModuleAwareUserChange() { - // Required for IJ serialization - } - - @SuppressWarnings("NullableProblems") - protected AbstractModuleAwareUserChange(@NotNull String moduleName) { - myModuleName = moduleName; - } - - @Nullable - public String getModuleName() { - return myModuleName; - } - - public void setModuleName(@Nullable String moduleName) { - myModuleName = moduleName; - } - - @Override - public int hashCode() { - return myModuleName != null ? myModuleName.hashCode() : 0; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - AbstractModuleAwareUserChange change = (AbstractModuleAwareUserChange)o; - - if (myModuleName != null ? !myModuleName.equals(change.myModuleName) : change.myModuleName != null) return false; - - return true; - } - - @SuppressWarnings("unchecked") - @Override - public int compareTo(@NotNull UserProjectChange o) { - int cmp = super.compareTo(o); - if (cmp != 0 || !(o instanceof AbstractModuleAwareUserChange)) { - return cmp; - } - AbstractModuleAwareUserChange that = (AbstractModuleAwareUserChange)o; - if (myModuleName == null) { - return that.myModuleName == null ? 0 : 1; - } - else if (that.myModuleName == null) { - return -1; - } - else { - return myModuleName.compareTo(that.myModuleName); - } - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/AbstractUserProjectChange.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/AbstractUserProjectChange.java deleted file mode 100644 index d18cd85b51c4..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/AbstractUserProjectChange.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.model.project.change.user; - -import com.intellij.util.xmlb.XmlSerializerUtil; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * @author Denis Zhdanov - * @since 2/18/13 8:29 PM - */ -public abstract class AbstractUserProjectChange> implements UserProjectChange { - - @SuppressWarnings("unchecked") - @Nullable - @Override - public T getState() { - return (T)this; - } - - @Override - public void loadState(T state) { - XmlSerializerUtil.copyBean(state, this); - } - - @Override - public int compareTo(@NotNull UserProjectChange o) { - return getClass().getName().compareTo(o.getClass().getName()); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/AddLibraryDependencyUserChange.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/AddLibraryDependencyUserChange.java deleted file mode 100644 index cc92367575bf..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/AddLibraryDependencyUserChange.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.model.project.change.user; - -import org.jetbrains.annotations.NotNull; - -/** - * @author Denis Zhdanov - * @since 2/18/13 8:51 PM - */ -public class AddLibraryDependencyUserChange extends AbstractDependencyAwareUserChange { - - @SuppressWarnings("UnusedDeclaration") - public AddLibraryDependencyUserChange() { - // Necessary for IJ serialization. - } - - public AddLibraryDependencyUserChange(@NotNull String moduleName, @NotNull String dependencyName) { - super(moduleName, dependencyName); - } - - @Override - public void invite(@NotNull UserProjectChangeVisitor visitor) { - visitor.visit(this); - } - - @Override - public String toString() { - return String.format("library '%s' is added as a dependency to module '%s'", getDependencyName(), getModuleName()); - } -} \ No newline at end of file diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/AddModuleDependencyUserChange.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/AddModuleDependencyUserChange.java deleted file mode 100644 index 874a54371502..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/AddModuleDependencyUserChange.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.model.project.change.user; - -import org.jetbrains.annotations.NotNull; - -/** - * @author Denis Zhdanov - * @since 2/19/13 9:05 AM - */ -public class AddModuleDependencyUserChange extends AbstractDependencyAwareUserChange { - - @SuppressWarnings("UnusedDeclaration") - public AddModuleDependencyUserChange() { - // Necessary for IJ serialization. - } - - public AddModuleDependencyUserChange(@NotNull String moduleName, @NotNull String dependencyName) { - super(moduleName, dependencyName); - } - - @Override - public void invite(@NotNull UserProjectChangeVisitor visitor) { - visitor.visit(this); - } - - @Override - public String toString() { - return String.format("module '%s' is added as a dependency to module '%s'", getDependencyName(), getModuleName()); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/AddModuleUserChange.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/AddModuleUserChange.java deleted file mode 100644 index c1022c603705..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/AddModuleUserChange.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.model.project.change.user; - -import org.jetbrains.annotations.NotNull; - -/** - * @author Denis Zhdanov - * @since 2/18/13 8:28 PM - */ -public class AddModuleUserChange extends AbstractModuleAwareUserChange { - - @SuppressWarnings("UnusedDeclaration") - public AddModuleUserChange() { - // Required for IJ serialization - } - - @SuppressWarnings("NullableProblems") - public AddModuleUserChange(@NotNull String moduleName) { - super(moduleName); - } - - @Override - public void invite(@NotNull UserProjectChangeVisitor visitor) { - visitor.visit(this); - } - - @Override - public String toString() { - return "added module " + getModuleName(); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/LibraryDependencyExportedChange.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/LibraryDependencyExportedChange.java deleted file mode 100644 index 107625596d34..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/LibraryDependencyExportedChange.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.model.project.change.user; - -import org.jetbrains.annotations.NotNull; - -/** - * @author Denis Zhdanov - * @since 3/4/13 12:22 PM - */ -public class LibraryDependencyExportedChange - extends AbstractDependencyExportedUserChange -{ - - @SuppressWarnings("UnusedDeclaration") - public LibraryDependencyExportedChange() { - // Required for IJ serialization - } - - public LibraryDependencyExportedChange(@NotNull String moduleName, @NotNull String dependencyName, boolean exported) { - super(moduleName, dependencyName, exported); - } - - @Override - public void invite(@NotNull UserProjectChangeVisitor visitor) { - visitor.visit(this); - } - - @Override - public String toString() { - return String.format("library dependency '%s' is %sexported at module '%s'", - getDependencyName(), isExported() ? "" : "non-", getModuleName()); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/LibraryDependencyScopeUserChange.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/LibraryDependencyScopeUserChange.java deleted file mode 100644 index c64bedaaaae6..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/LibraryDependencyScopeUserChange.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.model.project.change.user; - -import com.intellij.openapi.roots.DependencyScope; -import org.jetbrains.annotations.NotNull; - -/** - * @author Denis Zhdanov - * @since 3/4/13 12:12 PM - */ -public class LibraryDependencyScopeUserChange extends AbstractDependencyScopeUserChange { - - @SuppressWarnings("UnusedDeclaration") - public LibraryDependencyScopeUserChange() { - // Required for IJ serialization - } - - public LibraryDependencyScopeUserChange(@NotNull String moduleName, - @NotNull String dependencyName, - @NotNull DependencyScope scope) - { - super(moduleName, dependencyName, scope); - } - - @Override - public void invite(@NotNull UserProjectChangeVisitor visitor) { - visitor.visit(this); - } - - @Override - public String toString() { - return String.format("scope set to '%s' for library dependency '%s' of module '%s'", getScope(), getDependencyName(), getModuleName()); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/ModuleDependencyExportedChange.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/ModuleDependencyExportedChange.java deleted file mode 100644 index c0cf21f3084e..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/ModuleDependencyExportedChange.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.model.project.change.user; - -import org.jetbrains.annotations.NotNull; - -/** - * @author Denis Zhdanov - * @since 3/4/13 12:24 PM - */ -public class ModuleDependencyExportedChange - extends AbstractDependencyExportedUserChange -{ - - @SuppressWarnings("UnusedDeclaration") - public ModuleDependencyExportedChange() { - // Required for IJ serialization - } - - public ModuleDependencyExportedChange(@NotNull String moduleName, @NotNull String dependencyName, boolean exported) { - super(moduleName, dependencyName, exported); - } - - @Override - public void invite(@NotNull UserProjectChangeVisitor visitor) { - visitor.visit(this); - } - - @Override - public String toString() { - return String.format("module dependency '%s' is %sexported at module '%s'", - getDependencyName(), isExported() ? "" : "non-", getModuleName()); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/ModuleDependencyScopeUserChange.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/ModuleDependencyScopeUserChange.java deleted file mode 100644 index 42f95e366414..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/ModuleDependencyScopeUserChange.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.model.project.change.user; - -import com.intellij.openapi.roots.DependencyScope; -import org.jetbrains.annotations.NotNull; - -/** - * @author Denis Zhdanov - * @since 3/4/13 12:16 PM - */ -@SuppressWarnings("UnusedDeclaration") -public class ModuleDependencyScopeUserChange extends AbstractDependencyScopeUserChange { - - public ModuleDependencyScopeUserChange() { - // Required for IJ serialization - } - - public ModuleDependencyScopeUserChange(@NotNull String moduleName, - @NotNull String dependencyName, - @NotNull DependencyScope scope) - { - super(moduleName, dependencyName, scope); - } - - @Override - public void invite(@NotNull UserProjectChangeVisitor visitor) { - visitor.visit(this); - } - - @Override - public String toString() { - return String.format("scope set to '%s' for module dependency '%s' of module '%s'", getScope(), getDependencyName(), getModuleName()); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/RemoveLibraryDependencyUserChange.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/RemoveLibraryDependencyUserChange.java deleted file mode 100644 index 3f534f8e83e5..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/RemoveLibraryDependencyUserChange.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.model.project.change.user; - -import org.jetbrains.annotations.NotNull; - -/** - * @author Denis Zhdanov - * @since 2/19/13 9:09 AM - */ -public class RemoveLibraryDependencyUserChange extends AbstractDependencyAwareUserChange { - - @SuppressWarnings("UnusedDeclaration") - public RemoveLibraryDependencyUserChange() { - // Necessary for IJ serialization. - } - - public RemoveLibraryDependencyUserChange(@NotNull String moduleName, @NotNull String dependencyName) { - super(moduleName, dependencyName); - } - - @Override - public void invite(@NotNull UserProjectChangeVisitor visitor) { - visitor.visit(this); - } - - @Override - public String toString() { - return String.format("dependency to library '%s' is removed from module '%s' config", getDependencyName(), getModuleName()); - } -} \ No newline at end of file diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/RemoveModuleDependencyUserChange.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/RemoveModuleDependencyUserChange.java deleted file mode 100644 index 537a525776e2..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/RemoveModuleDependencyUserChange.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.model.project.change.user; - -import org.jetbrains.annotations.NotNull; - -/** - * @author Denis Zhdanov - * @since 2/19/13 9:06 AM - */ -public class RemoveModuleDependencyUserChange extends AbstractDependencyAwareUserChange { - - @SuppressWarnings("UnusedDeclaration") - public RemoveModuleDependencyUserChange() { - // Necessary for IJ serialization. - } - - public RemoveModuleDependencyUserChange(@NotNull String moduleName, @NotNull String dependencyName) { - super(moduleName, dependencyName); - } - - @Override - public void invite(@NotNull UserProjectChangeVisitor visitor) { - visitor.visit(this); - } - - @Override - public String toString() { - return String.format("dependency to module '%s' is removed from module '%s' config", getDependencyName(), getModuleName()); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/RemoveModuleUserChange.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/RemoveModuleUserChange.java deleted file mode 100644 index 3cb87c7705c8..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/RemoveModuleUserChange.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.model.project.change.user; - -import org.jetbrains.annotations.NotNull; - -/** - * @author Denis Zhdanov - * @since 2/18/13 8:50 PM - */ -public class RemoveModuleUserChange extends AbstractModuleAwareUserChange { - - @SuppressWarnings("UnusedDeclaration") - public RemoveModuleUserChange() { - // Required for IJ serialization - } - - @SuppressWarnings("NullableProblems") - public RemoveModuleUserChange(@NotNull String moduleName) { - super(moduleName); - } - - @Override - public void invite(@NotNull UserProjectChangeVisitor visitor) { - visitor.visit(this); - } - - @Override - public String toString() { - return "removed module " + getModuleName(); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/UserProjectChange.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/UserProjectChange.java deleted file mode 100644 index e79baa5a6917..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/UserProjectChange.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.model.project.change.user; - -import com.intellij.openapi.components.PersistentStateComponent; -import org.jetbrains.annotations.NotNull; - -/** - * Stands for a project change explicitly made by a user (e.g. a 'new module is added' or 'particular library dependency - * is removed from particular module') etc. - *

- * This interface also requires the implementations to be IS-A {@link Comparable}. That is a limitation of IJ serialization - * sub-system (see CollectionBinding.getIterable() which wraps any set into a TreeSet). - * - * @author Denis Zhdanov - * @since 2/18/13 8:03 PM - */ -public interface UserProjectChange extends PersistentStateComponent, Comparable> { - - void invite(@NotNull UserProjectChangeVisitor visitor); -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/UserProjectChangeVisitor.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/UserProjectChangeVisitor.java deleted file mode 100644 index 276944726f69..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/change/user/UserProjectChangeVisitor.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.model.project.change.user; - -import org.jetbrains.annotations.NotNull; - -/** - * @author Denis Zhdanov - * @since 2/19/13 9:16 AM - */ -public interface UserProjectChangeVisitor { - - void visit(@NotNull AddModuleUserChange change); - void visit(@NotNull RemoveModuleUserChange change); - void visit(@NotNull AddModuleDependencyUserChange change); - void visit(@NotNull RemoveModuleDependencyUserChange change); - void visit(@NotNull AddLibraryDependencyUserChange change); - void visit(@NotNull RemoveLibraryDependencyUserChange change); - void visit(@NotNull LibraryDependencyScopeUserChange change); - void visit(@NotNull ModuleDependencyScopeUserChange change); - void visit(@NotNull LibraryDependencyExportedChange change); - void visit(@NotNull ModuleDependencyExportedChange change); -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/AbstractCompositeExternalEntityId.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/AbstractCompositeExternalEntityId.java deleted file mode 100644 index 2a9d48ab1924..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/AbstractCompositeExternalEntityId.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.model.project.id; - -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.ProjectEntityType; -import org.jetbrains.annotations.NotNull; - -/** - * There is a possible case that we need to work with an entity which references both external and ide entities. For example, - * there is a possible case that particular library is outdated (external system and ide are configured to use different versions of it). - * We need to have an id entity which references both of them then. This class serves that purposes. - *

- * Thread-safe. - * - * @author Denis Zhdanov - * @since 1/22/13 5:17 PM - */ -public abstract class AbstractCompositeExternalEntityId extends AbstractExternalEntityId { - - @NotNull private final T myBaseId; - @NotNull private final T myCounterPartyId; - - public AbstractCompositeExternalEntityId(@NotNull ProjectEntityType type, - @NotNull ProjectSystemId baseOwner, - @NotNull T baseId, - @NotNull T counterPartyId) - { - super(type, baseOwner); - myBaseId = baseId; - myCounterPartyId = counterPartyId; - } - - @NotNull - protected T getBaseId() { - return myBaseId; - } - - @NotNull - protected T getCounterPartyId() { - return myCounterPartyId; - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + myBaseId.hashCode(); - result = 31 * result + myCounterPartyId.hashCode(); - return result; - } - - @Override - public boolean equals(Object o) { - if (!super.equals(o)) return false; - - AbstractCompositeExternalEntityId id = (AbstractCompositeExternalEntityId)o; - - if (!myBaseId.equals(id.myBaseId)) return false; - if (!myCounterPartyId.equals(id.myCounterPartyId)) return false; - - return true; - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/AbstractExternalDependencyId.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/AbstractExternalDependencyId.java deleted file mode 100644 index a1d47e979856..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/AbstractExternalDependencyId.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.intellij.openapi.externalSystem.model.project.id; - -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.ProjectEntityType; -import org.jetbrains.annotations.NotNull; - -/** - * @author Denis Zhdanov - * @since 2/20/12 12:01 PM - */ -public abstract class AbstractExternalDependencyId extends AbstractExternalEntityId { - - @NotNull private final String myOwnerModuleName; - @NotNull private final String myDependencyName; - - public AbstractExternalDependencyId(@NotNull ProjectEntityType type, - @NotNull ProjectSystemId owner, - @NotNull String ownerModuleName, - @NotNull String dependencyName) - { - super(type, owner); - myOwnerModuleName = ownerModuleName; - myDependencyName = dependencyName; - } - - @NotNull - public String getOwnerModuleName() { - return myOwnerModuleName; - } - - @NotNull - public String getDependencyName() { - return myDependencyName; - } - - @NotNull - public ModuleId getOwnerModuleId() { - return new ModuleId(getOwner(), myOwnerModuleName); - } - - @Override - public int hashCode() { - int result = 31 * super.hashCode() + myOwnerModuleName.hashCode(); - return 31 * result + myDependencyName.hashCode(); - } - - @Override - public boolean equals(Object o) { - if (!super.equals(o)) { - return false; - } - AbstractExternalDependencyId that = (AbstractExternalDependencyId)o; - return myOwnerModuleName.equals(that.myOwnerModuleName) && myDependencyName.equals(that.myDependencyName); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/AbstractExternalEntityId.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/AbstractExternalEntityId.java deleted file mode 100644 index fa98bb1d7bbc..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/AbstractExternalEntityId.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.intellij.openapi.externalSystem.model.project.id; - -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.ProjectEntityType; -import org.jetbrains.annotations.NotNull; - -import java.util.concurrent.atomic.AtomicReference; - -/** - * Thread-safe. - * - * @author Denis Zhdanov - * @since 2/14/12 1:32 PM - */ -public abstract class AbstractExternalEntityId implements ProjectEntityId { - - @NotNull private final AtomicReference myOwner = new AtomicReference(); - @NotNull private final ProjectEntityType myType; - - public AbstractExternalEntityId(@NotNull ProjectEntityType type, @NotNull ProjectSystemId owner) { - myType = type; - myOwner.set(owner); - } - - @Override - @NotNull - public ProjectEntityType getType() { - return myType; - } - - @Override - @NotNull - public ProjectSystemId getOwner() { - return myOwner.get(); - } - - @Override - public void setOwner(@NotNull ProjectSystemId owner) { - myOwner.set(owner); - } - - @Override - public int hashCode() { - return myType.hashCode(); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - AbstractExternalEntityId that = (AbstractExternalEntityId)o; - return myType.equals(that.myType); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/CompositeLibraryDependencyId.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/CompositeLibraryDependencyId.java deleted file mode 100644 index 76bcee8264bd..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/CompositeLibraryDependencyId.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.model.project.id; - -import com.intellij.openapi.externalSystem.model.DataNode; -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.CompositeLibraryDependencyData; -import com.intellij.openapi.externalSystem.model.project.LibraryDependencyData; -import com.intellij.openapi.externalSystem.model.project.ProjectEntityType; -import com.intellij.openapi.externalSystem.service.project.ProjectStructureHelper; -import com.intellij.openapi.externalSystem.service.project.ProjectStructureServices; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.LibraryOrderEntry; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * @author Denis Zhdanov - * @since 1/22/13 5:26 PM - */ -public class CompositeLibraryDependencyId extends AbstractCompositeExternalEntityId { - - public CompositeLibraryDependencyId(@NotNull LibraryDependencyId libraryDependencyId, - @NotNull LibraryDependencyId ideLibraryDependencyId) - { - super(ProjectEntityType.DEPENDENCY_TO_OUTDATED_LIBRARY, ProjectSystemId.IDE, ideLibraryDependencyId, libraryDependencyId); - } - - @Nullable - @Override - public Object mapToEntity(@NotNull ProjectStructureServices services, @NotNull Project ideProject) { - ProjectStructureHelper helper = services.getProjectStructureHelper(); - DataNode externalDataNode - = helper.findExternalLibraryDependency(getCounterPartyId(), getOwner(), ideProject); - if (externalDataNode == null) { - return null; - } - - LibraryOrderEntry ideLibraryDependency = helper.findIdeLibraryDependency(getBaseId(), ideProject); - if (ideLibraryDependency == null) { - return null; - } - - return new CompositeLibraryDependencyData(externalDataNode.getData(), ideLibraryDependency); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/ContentRootId.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/ContentRootId.java deleted file mode 100644 index fd248918672f..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/ContentRootId.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.intellij.openapi.externalSystem.model.project.id; - -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.ProjectEntityType; -import com.intellij.openapi.externalSystem.service.project.ProjectStructureServices; -import com.intellij.openapi.project.Project; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * @author Denis Zhdanov - * @since 2/16/12 12:22 PM - */ -public class ContentRootId extends AbstractExternalEntityId { - - @NotNull private final String myModuleName; - @NotNull private final String myRootPath; - - public ContentRootId(@NotNull ProjectSystemId owner, @NotNull String moduleName, @NotNull String rootPath) { - super(ProjectEntityType.CONTENT_ROOT, owner); - myModuleName = moduleName; - myRootPath = rootPath; - } - - @NotNull - public String getModuleName() { - return myModuleName; - } - - @NotNull - public String getRootPath() { - return myRootPath; - } - - @NotNull - public ModuleId getModuleId() { - return new ModuleId(getOwner(), myModuleName); - } - - @Nullable - @Override - public Object mapToEntity(@NotNull ProjectStructureServices services, @NotNull Project ideProject) { - return services.getProjectStructureHelper().findContentRoot(this, getOwner(), ideProject); - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + myModuleName.hashCode(); - result = 31 * result + myRootPath.hashCode(); - return result; - } - - @Override - public boolean equals(Object o) { - if (!super.equals(o)) return false; - - ContentRootId that = (ContentRootId)o; - - if (!myModuleName.equals(that.myModuleName)) return false; - if (!myRootPath.equals(that.myRootPath)) return false; - - return true; - } - - @Override - public String toString() { - return "content root '" + myRootPath + "'"; - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/EntityIdMapper.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/EntityIdMapper.java deleted file mode 100644 index 46842687add3..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/EntityIdMapper.java +++ /dev/null @@ -1,121 +0,0 @@ -package com.intellij.openapi.externalSystem.model.project.id; - -import com.intellij.openapi.externalSystem.model.DataNode; -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.*; -import com.intellij.openapi.externalSystem.service.project.ModuleAwareContentRoot; -import com.intellij.openapi.externalSystem.service.project.ProjectStructureServices; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; -import com.intellij.openapi.externalSystem.util.IdeEntityVisitor; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.LibraryOrderEntry; -import com.intellij.openapi.roots.ModuleOrderEntry; -import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.util.Ref; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Encapsulates functionality of mapping project structure entities (mutable object) to id object (immutable) and vice versa. - * That's why we provide {@code 'entity <--> id'} mapping and make it possible to store the unique 'id' element within the node. - *

- * Thread-safe. - * - * @author Denis Zhdanov - * @since 2/14/12 12:20 PM - * @see ProjectEntityId - */ -public class EntityIdMapper { - - @NotNull private final ProjectStructureServices myServices; - - public EntityIdMapper(@NotNull ProjectStructureServices services) { - myServices = services; - } - - /** - * Performs {@code 'entity -> id'} mapping. Check class-level javadoc for more details. - * - * @param entity target entity to map - * @return 'id object' mapped to the given entity in case of successful match; null otherwise - * @throws IllegalArgumentException if it's not possible to map given entity to id - */ - @SuppressWarnings({"MethodMayBeStatic", "unchecked"}) - @NotNull - public static T mapEntityToId(@NotNull Object entity) throws IllegalArgumentException { - final Ref result = new Ref(); - if (entity instanceof DataNode) { - Object data = ((DataNode)entity).getData(); - if (data instanceof ProjectEntityData) { - return (T)((ProjectEntityData)data).getId((DataNode)entity); - } - } - - if (result.get() == null) { - ExternalSystemUtil.dispatch(entity, new IdeEntityVisitor() { - @Override - public void visit(@NotNull Project project) { - result.set(new ProjectId(ProjectSystemId.IDE)); - } - - @Override - public void visit(@NotNull Module module) { - result.set(new ModuleId(ProjectSystemId.IDE, module.getName())); - } - - @Override - public void visit(@NotNull ModuleAwareContentRoot contentRoot) { - final String path = contentRoot.getFile().getPath(); - result.set(new ContentRootId(ProjectSystemId.IDE, contentRoot.getModule().getName(), path)); - } - - @Override - public void visit(@NotNull LibraryOrderEntry libraryDependency) { - String libraryName = libraryDependency.getLibraryName(); - if (libraryName == null) { - final Library library = libraryDependency.getLibrary(); - if (library != null) { - libraryName = ExternalSystemUtil.getLibraryName(library); - } - } - if (libraryName == null) { - return; - } - result.set(new LibraryDependencyId(ProjectSystemId.IDE, libraryDependency.getOwnerModule().getName(), libraryName)); - } - - @Override - public void visit(@NotNull ModuleOrderEntry moduleDependency) { - result.set(new ModuleDependencyId( - ProjectSystemId.IDE, moduleDependency.getOwnerModule().getName(), moduleDependency.getModuleName() - )); - } - - @Override - public void visit(@NotNull Library library) { - result.set(new LibraryId(ProjectSystemId.IDE, ExternalSystemUtil.getLibraryName(library))); - } - }); - } - final Object r = result.get(); - if (r == null) { - throw new IllegalArgumentException(String.format("Can't map entity '%s' to id element", entity)); - } - return (T)r; - } - - /** - * Performs {@code 'id -> entity'} mapping. Check class-level javadoc for more details. - * - * @param id target entity id - * @param ideProject target ide project - * @param target entity type - * @return entity mapped to the given id if any; null otherwise - */ - @SuppressWarnings("unchecked") - @Nullable - public T mapIdToEntity(@NotNull ProjectEntityId id, @NotNull Project ideProject) { - return (T)id.mapToEntity(myServices, ideProject); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/GradleSyntheticId.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/GradleSyntheticId.java deleted file mode 100644 index a67354b6535b..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/GradleSyntheticId.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.intellij.openapi.externalSystem.model.project.id; - -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.ProjectEntityType; -import com.intellij.openapi.externalSystem.service.project.ProjectStructureServices; -import com.intellij.openapi.project.Project; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Whole 'entity id' thing is necessary for mapping 'sync project structures' tree nodes to the domain entities. However, there are - * special types of nodes that don't map to any entity - {@link ProjectEntityType#SYNTHETIC synthetic nodes}. - *

- * This class is designed to serve as a data object for such a nodes. - *

- * Thread-safe. - * - * @author Denis Zhdanov - * @since 2/16/12 11:40 AM - */ -public class GradleSyntheticId extends AbstractExternalEntityId { - - @NotNull private final String myText; - - public GradleSyntheticId(@NotNull String text) { - super(ProjectEntityType.SYNTHETIC, ProjectSystemId.IDE/* no matter what owner is used */); - myText = text; - } - - @Override - public String toString() { - return myText; - } - - @Nullable - @Override - public Object mapToEntity(@NotNull ProjectStructureServices services, @NotNull Project ideProject) { - return null; - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/JarId.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/JarId.java deleted file mode 100644 index 4efd1c7c727c..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/JarId.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.intellij.openapi.externalSystem.model.project.id; - -import com.intellij.openapi.externalSystem.model.DataNode; -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.JarData; -import com.intellij.openapi.externalSystem.model.project.LibraryData; -import com.intellij.openapi.externalSystem.model.project.ProjectEntityType; -import com.intellij.openapi.externalSystem.service.project.ProjectStructureHelper; -import com.intellij.openapi.externalSystem.service.project.ProjectStructureServices; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.OrderRootType; -import com.intellij.openapi.roots.libraries.Library; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import com.intellij.openapi.externalSystem.model.project.LibraryPathType; - -/** - * @author Denis Zhdanov - * @since 12/11/12 3:04 PM - */ -public class JarId extends AbstractExternalEntityId { - - @NotNull private final String myPath; - @NotNull private final LibraryId myLibraryId; - @NotNull private final LibraryPathType myPathType; - - public JarId(@NotNull String path, @NotNull LibraryPathType pathType, @NotNull LibraryId libraryId) { - super(ProjectEntityType.JAR, libraryId.getOwner()); - myPath = path; - myPathType = pathType; - myLibraryId = libraryId; - } - - @NotNull - public String getPath() { - return myPath; - } - - @NotNull - public LibraryId getLibraryId() { - return myLibraryId; - } - - @NotNull - public LibraryPathType getLibraryPathType() { - return myPathType; - } - - @Nullable - @Override - public JarData mapToEntity(@NotNull ProjectStructureServices services, @NotNull Project ideProject) { - ProjectStructureHelper helper = services.getProjectStructureHelper(); - String libraryName = myLibraryId.getLibraryName(); - OrderRootType jarType = services.getLibraryPathTypeMapper().map(myPathType); - Library ideLibrary = helper.findIdeLibrary(libraryName, jarType, myPath, ideProject); - if (ideLibrary != null) { - return new JarData(myPath, myPathType, ideLibrary, null, ProjectSystemId.IDE); - } - - DataNode gradleLibrary = helper.findExternalLibrary(libraryName, myPathType, myPath, getOwner(), ideProject); - if (gradleLibrary != null) { - return new JarData(myPath, myPathType, null, gradleLibrary.getData(), getOwner()); - } - return null; - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + myPath.hashCode(); - return result; - } - - @Override - public boolean equals(Object o) { - if (!super.equals(o)) return false; - - JarId that = (JarId)o; - return myPath.equals(that.myPath); - } - - @Override - public String toString() { - return String.format("%s jar '%s'", myPathType.toString().toLowerCase(), myPath); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/LibraryDependencyId.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/LibraryDependencyId.java deleted file mode 100644 index 36420feaa570..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/LibraryDependencyId.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.intellij.openapi.externalSystem.model.project.id; - -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.ProjectEntityType; -import com.intellij.openapi.externalSystem.service.project.ProjectStructureServices; -import com.intellij.openapi.project.Project; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * @author Denis Zhdanov - * @since 2/14/12 1:59 PM - */ -public class LibraryDependencyId extends AbstractExternalDependencyId { - - public LibraryDependencyId(@NotNull ProjectSystemId owner, @NotNull String moduleName, @NotNull String libraryName) { - super(ProjectEntityType.LIBRARY_DEPENDENCY, owner, moduleName, libraryName); - } - - @Nullable - @Override - public Object mapToEntity(@NotNull ProjectStructureServices services, @NotNull Project ideProject) { - return services.getProjectStructureHelper().findLibraryDependency(getOwnerModuleName(), getDependencyName(), getOwner(), ideProject); - } - - @NotNull - public LibraryId getLibraryId() { - return new LibraryId(getOwner(), getDependencyName()); - } - - @Override - public String toString() { - return String.format("library dependency:owner module='%s'|library='%s'", getOwnerModuleName(), getDependencyName()); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/LibraryId.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/LibraryId.java deleted file mode 100644 index 4ddcd77aba36..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/LibraryId.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.intellij.openapi.externalSystem.model.project.id; - -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.ProjectEntityType; -import com.intellij.openapi.externalSystem.service.project.ProjectStructureServices; -import com.intellij.openapi.project.Project; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * @author Denis Zhdanov - * @since 2/20/12 7:12 PM - */ -public class LibraryId extends AbstractExternalEntityId { - - @NotNull private final String myLibraryName; - - public LibraryId(@NotNull ProjectSystemId owner, @NotNull String libraryName) { - super(ProjectEntityType.LIBRARY, owner); - myLibraryName = libraryName; - } - - @NotNull - public String getLibraryName() { - return myLibraryName; - } - - @Nullable - @Override - public Object mapToEntity(@NotNull ProjectStructureServices services, @NotNull Project ideProject) { - return services.getProjectStructureHelper().findLibrary(myLibraryName, getOwner(), ideProject); - } - - @Override - public int hashCode() { - return 31 * super.hashCode() + myLibraryName.hashCode(); - } - - @Override - public boolean equals(Object o) { - if (!super.equals(o)) { - return false; - } - LibraryId that = (LibraryId)o; - return myLibraryName.equals(that.myLibraryName); - } - - @Override - public String toString() { - return "library '" + myLibraryName + "'"; - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/ModuleDependencyId.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/ModuleDependencyId.java deleted file mode 100644 index c7f7d3a9076b..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/ModuleDependencyId.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.intellij.openapi.externalSystem.model.project.id; - -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.ProjectEntityType; -import com.intellij.openapi.externalSystem.service.project.ProjectStructureServices; -import com.intellij.openapi.project.Project; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * @author Denis Zhdanov - * @since 2/14/12 2:06 PM - */ -public class ModuleDependencyId extends AbstractExternalDependencyId { - - public ModuleDependencyId(@NotNull ProjectSystemId owner, @NotNull String ownerModuleName, @NotNull String dependencyModuleName) { - super(ProjectEntityType.MODULE_DEPENDENCY, owner, ownerModuleName, dependencyModuleName); - } - - @Nullable - @Override - public Object mapToEntity(@NotNull ProjectStructureServices services, @NotNull Project ideProject) { - return services.getProjectStructureHelper().findModuleDependency(getOwnerModuleName(), getDependencyName(), getOwner(), ideProject); - } - - @Override - public String toString() { - return String.format("module dependency:owner module='%s'|dependency module='%s'", getOwnerModuleName(), getDependencyName()); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/ModuleId.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/ModuleId.java deleted file mode 100644 index c7b2505cf8c5..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/ModuleId.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.intellij.openapi.externalSystem.model.project.id; - -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.ProjectEntityType; -import com.intellij.openapi.externalSystem.service.project.ProjectStructureServices; -import com.intellij.openapi.project.Project; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * @author Denis Zhdanov - * @since 2/14/12 1:55 PM - */ -public class ModuleId extends AbstractExternalEntityId { - - @NotNull private final String myModuleName; - - public ModuleId(@NotNull ProjectSystemId owner, @NotNull String moduleName) { - super(ProjectEntityType.MODULE, owner); - myModuleName = moduleName; - } - - @Nullable - @Override - public Object mapToEntity(@NotNull ProjectStructureServices services, @NotNull Project ideProject) { - return services.getProjectStructureHelper().findModule(myModuleName, getOwner(), ideProject); - } - - @NotNull - public String getModuleName() { - return myModuleName; - } - - @Override - public int hashCode() { - return 31 * super.hashCode() + myModuleName.hashCode(); - } - - @Override - public boolean equals(Object o) { - if (!super.equals(o)) { - return false; - } - ModuleId that = (ModuleId)o; - return myModuleName.equals(that.myModuleName); - } - - @Override - public String toString() { - return "module '" + myModuleName + "'"; - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/ProjectEntityId.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/ProjectEntityId.java deleted file mode 100644 index b1030ce29ba3..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/ProjectEntityId.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.intellij.openapi.externalSystem.model.project.id; - -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.ProjectEntityType; -import com.intellij.openapi.externalSystem.service.project.ProjectStructureServices; -import com.intellij.openapi.project.Project; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Represent unique identifier object for any external system or ide project structure entity (module, library, library dependency etc). - *

- * We need an entity id, for example, at the 'sync project structure' tree - the model needs to keep mappings - * between the existing tree nodes and corresponding project structure entities. However, we can't keep an entity as is because - * it may cause memory leak and be not safe (the entity's hash code may be changed). - *

- * Implementations of this interface are expected to be thread-safe. - * - * @author Denis Zhdanov - * @since 2/14/12 12:26 PM - */ -public interface ProjectEntityId { - - @NotNull - ProjectEntityType getType(); - - @NotNull - ProjectSystemId getOwner(); - - void setOwner(@NotNull ProjectSystemId owner); - - @Nullable - Object mapToEntity(@NotNull ProjectStructureServices services, @NotNull Project ideProject); -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/ProjectId.java b/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/ProjectId.java deleted file mode 100644 index 6c44f3e65037..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/model/project/id/ProjectId.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.intellij.openapi.externalSystem.model.project.id; - -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.ProjectEntityType; -import com.intellij.openapi.externalSystem.service.project.ProjectStructureServices; -import com.intellij.openapi.project.Project; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * @author Denis Zhdanov - * @since 2/14/12 1:34 PM - */ -public class ProjectId extends AbstractExternalEntityId { - - public ProjectId(@NotNull ProjectSystemId owner) { - super(ProjectEntityType.PROJECT, owner); - } - - @Nullable - @Override - public Object mapToEntity(@NotNull ProjectStructureServices services, @NotNull Project ideProject) { - if (ProjectSystemId.IDE.equals(getOwner())) { - return ideProject; - } - else { - return services.getChangesModel().getExternalProject(getOwner(), ideProject); - } - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/ProjectStructureChangesDetector.java b/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/ProjectStructureChangesDetector.java deleted file mode 100644 index 1429364dbd3a..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/ProjectStructureChangesDetector.java +++ /dev/null @@ -1,214 +0,0 @@ -package com.intellij.openapi.externalSystem.service.project; - -import com.intellij.ProjectTopics; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.application.ModalityState; -import com.intellij.openapi.components.ServiceManager; -import com.intellij.openapi.externalSystem.ExternalSystemManager; -import com.intellij.openapi.externalSystem.model.ExternalSystemDataKeys; -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.change.ExternalProjectStructureChange; -import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskType; -import com.intellij.openapi.externalSystem.service.project.change.ExternalProjectStructureChangeListener; -import com.intellij.openapi.externalSystem.service.project.change.ProjectStructureChangesModel; -import com.intellij.openapi.externalSystem.service.project.change.user.UserProjectChangesCalculator; -import com.intellij.openapi.externalSystem.service.project.manage.ProjectEntityChangeListener; -import com.intellij.openapi.externalSystem.service.task.ExternalSystemTaskManager; -import com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsManager; -import com.intellij.openapi.externalSystem.ui.ExternalProjectStructureTreeModel; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.ModuleRootAdapter; -import com.intellij.openapi.roots.ModuleRootEvent; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.util.Alarm; -import com.intellij.util.messages.MessageBusConnection; -import com.intellij.util.ui.UIUtil; -import org.jetbrains.annotations.NotNull; -import com.intellij.openapi.externalSystem.service.project.change.AutoImporter; - -import java.util.Collection; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicLong; - -/** - * Detects project structure changes and triggers linked gradle project update. - * - * @author Denis Zhdanov - * @since 11/3/11 3:57 PM - */ -public class ProjectStructureChangesDetector implements ExternalProjectStructureChangeListener { - - private static final int REFRESH_DELAY_MILLIS = (int)500; - - private final Alarm myAlarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD); - private final AtomicLong myStartRefreshTime = new AtomicLong(); - private final AtomicInteger myImportCounter = new AtomicInteger(); - private final AtomicBoolean myNewChangesDetected = new AtomicBoolean(); - - @NotNull private final ProjectStructureChangesModel myChangesModel; - @NotNull private final ExternalSystemSettingsManager mySettingsManager; - @NotNull private final Project myProject; - @NotNull private final UserProjectChangesCalculator myUserProjectChangesCalculator; - @NotNull private final AutoImporter myAutoImporter; - - public ProjectStructureChangesDetector(@NotNull Project project, - @NotNull ProjectStructureChangesModel model, - @NotNull ExternalSystemSettingsManager manager, - @NotNull UserProjectChangesCalculator calculator, - @NotNull AutoImporter importer) - { - myProject = project; - myChangesModel = model; - mySettingsManager = manager; - myUserProjectChangesCalculator = calculator; - myAutoImporter = importer; - myChangesModel.addListener(this); - subscribeToGradleImport(project); - subscribeToRootChanges(project); - } - - private void subscribeToGradleImport(@NotNull final Project project) { - MessageBusConnection connection = project.getMessageBus().connect(project); - connection.subscribe(ProjectEntityChangeListener.TOPIC, new ProjectEntityChangeListener() { - @Override - public void onChangeStart(@NotNull Object entity, @NotNull ProjectSystemId externalSystemId) { - myImportCounter.incrementAndGet(); - } - - @Override - public void onChangeEnd(@NotNull Object entity, @NotNull ProjectSystemId externalSystemId) { - if (myImportCounter.decrementAndGet() <= 0) { - - myUserProjectChangesCalculator.updateCurrentProjectState(project); - - // TODO den implement -// ProjectData externalProject = myChangesModel.getExternalProject(externalSystemId, project); -// if (externalProject != null) { -// myChangesModel.update(externalProject, project, true); -// } - - // There is a possible case that we need to add/remove IJ-specific new nodes because of the IJ project structure changes - // triggered by gradle. - rebuildTreeModel(externalSystemId); - } - } - }); - } - - private void subscribeToRootChanges(@NotNull final Project project) { - project.getMessageBus().connect(project).subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() { - @Override - public void rootsChanged(ModuleRootEvent event) { - if (myImportCounter.get() <= 0) { - scheduleUpdate(project); - } - } - }); - } - - private void rebuildTreeModel(@NotNull ProjectSystemId externalSystemId) { - final ExternalProjectStructureTreeModel treeModel = ExternalSystemUtil.getToolWindowElement( - ExternalProjectStructureTreeModel.class, myProject, ExternalSystemDataKeys.PROJECT_TREE_MODEL, externalSystemId - ); - if (treeModel != null) { - treeModel.rebuild(myAutoImporter.isInProgress()); - } - } - - @Override - public void onChanges(@NotNull Project ideProject, - @NotNull ProjectSystemId externalSystemId, - @NotNull Collection oldChanges, - @NotNull Collection currentChanges) - { - myNewChangesDetected.set(true); - } - - private void scheduleUpdate(@NotNull Project project) { - for (ExternalSystemManager manager : ExternalSystemManager.EP_NAME.getExtensions()) { - ProjectSystemId systemId = manager.getSystemId(); - scheduleUpdate(project, systemId); - } - } - - private void scheduleUpdate(@NotNull Project ideProject, @NotNull ProjectSystemId externalSystemId) { - if (ApplicationManager.getApplication().isUnitTestMode() - || StringUtil.isEmpty(mySettingsManager.getSettings(myProject, externalSystemId).getLinkedExternalProjectPath())) - { - return; - } - - myUserProjectChangesCalculator.updateChanges(ideProject); - - // We experienced a situation when project root change event has been fired but no actual project structure change has - // occurred (e.g. compile output directory was modified externally). That's why we perform additional check here in order - // to ensure that project structure has really been changed. - // - // The idea is to check are there any new project structure changes comparing to the gradle project structure used last time. - // We don't do anything in case no new changes have been detected. - // TODO den implement -// ProjectData project = myChangesModel.getExternalProject(externalSystemId, ideProject); -// if (project != null) { -// myNewChangesDetected.set(false); -// myChangesModel.update(project, ideProject, true); -// if (!myNewChangesDetected.get()) { -// return; -// } -// } - - myStartRefreshTime.set(System.currentTimeMillis() + REFRESH_DELAY_MILLIS); - myAlarm.cancelAllRequests(); - myAlarm.addRequest(new RefreshRequest(externalSystemId), REFRESH_DELAY_MILLIS); - } - - private class RefreshRequest implements Runnable { - - @NotNull private final ProjectSystemId myExternalSystemId; - - RefreshRequest(@NotNull ProjectSystemId id) { - myExternalSystemId = id; - } - - @Override - public void run() { - if (myProject.isDisposed()) { - myAlarm.cancelAllRequests(); - return; - } - if (!myProject.isInitialized()) { - return; - } - myAlarm.cancelAllRequests(); - final ExternalSystemTaskManager taskManager = ServiceManager.getService(ExternalSystemTaskManager.class); - if (taskManager != null && taskManager.hasTaskOfTypeInProgress(ExternalSystemTaskType.RESOLVE_PROJECT)) { - return; - } - - final long diff = System.currentTimeMillis() - myStartRefreshTime.get(); - if (diff < 0) { - myAlarm.cancelAllRequests(); - myAlarm.addRequest(this, (int)-diff); - return; - } - - UIUtil.invokeAndWaitIfNeeded(new Runnable() { - @Override - public void run() { - if (ModalityState.current() != ModalityState.NON_MODAL) { - // There is a possible case that user performs intellij project structure modification and 'project settings' dialog - // is open. We want to perform the refresh when the editing is completely finished then. - myAlarm.cancelAllRequests(); - myAlarm.addRequest(RefreshRequest.this, REFRESH_DELAY_MILLIS); - return; - } - - // There is a possible case that we need to add/remove IJ-specific new nodes because of the IJ project structure changes. - rebuildTreeModel(myExternalSystemId); - //GradleUtil.refreshProject(myProject); - } - }); - } - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/ProjectStructureHelper.java b/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/ProjectStructureHelper.java deleted file mode 100644 index 65552a705439..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/ProjectStructureHelper.java +++ /dev/null @@ -1,498 +0,0 @@ -package com.intellij.openapi.externalSystem.service.project; - -import com.intellij.openapi.externalSystem.model.DataNode; -import com.intellij.openapi.externalSystem.model.ProjectKeys; -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.*; -import com.intellij.openapi.externalSystem.model.project.id.*; -import com.intellij.openapi.externalSystem.service.project.change.ProjectStructureChangesModel; -import com.intellij.openapi.externalSystem.util.ArtifactInfo; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.*; -import com.intellij.openapi.roots.impl.ModuleLibraryOrderEntryImpl; -import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.roots.libraries.LibraryTable; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.util.BooleanFunction; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import static com.intellij.openapi.externalSystem.model.ProjectKeys.LIBRARY_DEPENDENCY; -import static com.intellij.openapi.externalSystem.model.ProjectKeys.MODULE_DEPENDENCY; - -/** - * Thread-safe. - * - * @author Denis Zhdanov - * @since 2/6/12 3:28 PM - */ -public class ProjectStructureHelper { - - @NotNull private final ProjectStructureChangesModel myChangesModel; - @NotNull private final PlatformFacade myFacade; - @NotNull private final ExternalLibraryPathTypeMapper myLibraryPathTypeMapper; - - public ProjectStructureHelper(@NotNull ProjectStructureChangesModel model, - @NotNull PlatformFacade facade, - @NotNull ExternalLibraryPathTypeMapper mapper) - { - myChangesModel = model; - myFacade = facade; - myLibraryPathTypeMapper = mapper; - } - - /** - * Allows to answer if target library dependency is still available at the target project. - * - * @param id target library id - * @param ideProject target project - * @return true if target library dependency is still available at the target project; - * false otherwise - */ - public boolean isIdeLibraryDependencyExist(@NotNull final LibraryDependencyId id, @NotNull Project ideProject) { - return findIdeLibraryDependency(id.getOwnerModuleName(), id.getDependencyName(), ideProject) != null; - } - - /** - * Allows to answer if target library dependency is still available at the target gradle project. - * - * @param id target library id - * @param externalSystemId target external system id - * @param ideProject target ide project - * @return true if target library dependency is still available at the target external system; - * false otherwise - */ - public boolean isExternalLibraryDependencyExist(@NotNull final LibraryDependencyId id, - @NotNull ProjectSystemId externalSystemId, - @NotNull Project ideProject) - { - return findExternalLibraryDependency(id.getOwnerModuleName(), id.getDependencyName(), externalSystemId, ideProject) != null; - } - - public boolean isIdeModuleDependencyExist(@NotNull final ModuleDependencyId id, @NotNull Project ideProject) { - return findIdeModuleDependency(id.getOwnerModuleName(), id.getDependencyName(), ideProject) != null; - } - - public boolean isExternalModuleDependencyExist(@NotNull final ModuleDependencyId id, @NotNull Project ideProject) { - return findIdeModuleDependency(id.getOwnerModuleName(), id.getDependencyName(), ideProject) != null; - } - - @Nullable - public Module findIdeModule(@NotNull ModuleData module, @NotNull Project ideProject) { - return findIdeModule(module.getName(), ideProject); - } - - @Nullable - public Object findModule(@NotNull String moduleName, @NotNull ProjectSystemId owner, @NotNull Project ideProject) { - if (ProjectSystemId.IDE.equals(owner)) { - return findIdeModule(moduleName, ideProject); - } - else { - return findExternalModule(moduleName, owner, ideProject); - } - } - - @Nullable - public Module findIdeModule(@NotNull String ideModuleName, @NotNull Project ideProject) { - for (Module module : myFacade.getModules(ideProject)) { - if (ideModuleName.equals(module.getName())) { - return module; - } - } - return null; - } - - @Nullable - public DataNode findExternalModule(@NotNull String name, - @NotNull ProjectSystemId externalSystemId, - @NotNull Project ideProject) - { - final DataNode project = myChangesModel.getExternalProject(externalSystemId, ideProject); - if (project == null) { - return null; - } - for (DataNode moduleNode : ExternalSystemUtil.getChildren(project, ProjectKeys.MODULE)) { - if (name.equals(moduleNode.getData().getName())) { - return moduleNode; - } - } - return null; - } - - @Nullable - public DataNode findExternalContentRoot(@NotNull ContentRootId id, - @NotNull ProjectSystemId externalSystemId, - @NotNull Project ideProject) - { - final DataNode moduleNode = findExternalModule(id.getModuleName(), externalSystemId, ideProject); - if (moduleNode == null) { - return null; - } - for (DataNode contentRootNode : ExternalSystemUtil.getChildren(moduleNode, ProjectKeys.CONTENT_ROOT)) { - if (id.getRootPath().equals(contentRootNode.getData().getRootPath())) { - return contentRootNode; - } - } - return null; - } - - @Nullable - public Object findContentRoot(@NotNull ContentRootId id, @NotNull ProjectSystemId owner, @NotNull Project ideProject) { - if (ProjectSystemId.IDE.equals(owner)) { - return findIdeContentRoot(id, ideProject); - } - else { - return findExternalContentRoot(id, owner, ideProject); - } - } - - @Nullable - public ModuleAwareContentRoot findIdeContentRoot(@NotNull ContentRootId id, @NotNull Project ideProject) { - final Module module = findIdeModule(id.getModuleName(), ideProject); - if (module == null) { - return null; - } - for (ModuleAwareContentRoot contentRoot : myFacade.getContentRoots(module)) { - final VirtualFile file = contentRoot.getFile(); - if (id.getRootPath().equals(file.getPath())) { - return contentRoot; - } - } - return null; - } - - @Nullable - public Object findLibrary(@NotNull String libraryName, @NotNull ProjectSystemId owner, @NotNull Project ideProject) { - if (ProjectSystemId.IDE.equals(owner)) { - return findIdeLibrary(libraryName, ideProject); - } - else { - return findExternalLibrary(libraryName, owner, ideProject); - } - } - - @Nullable - public Library findIdeLibrary(@NotNull final LibraryData library, @NotNull Project ideProject) { - return findIdeLibrary(library.getName(), ideProject); - } - - /** - * Gradle library names follow the following pattern: {@code '[base library name]-[library-version]'}. - *

- * This methods serves as an utility which tries to find a library by it's given base name. - * - * @param baseName base name of the target library - * @param ideProject target ide project - * @return target library for the given base name if there is one and only one library for it; - * null otherwise (if there are no libraries or more than one library for the given base name) - */ - @Nullable - public Library findIdeLibraryByBaseName(@NotNull String baseName, @NotNull Project ideProject) { - final LibraryTable libraryTable = myFacade.getProjectLibraryTable(ideProject); - Library result = null; - for (Library library : libraryTable.getLibraries()) { - ArtifactInfo info = ExternalSystemUtil.parseArtifactInfo(ExternalSystemUtil.getLibraryName(library)); - if (info == null || !baseName.equals(info.getName())) { - continue; - } - if (result != null) { - return null; - } - result = library; - } - return result; - } - - @Nullable - public Library findIdeLibrary(@NotNull String libraryName, @NotNull Project ideProject) { - final LibraryTable libraryTable = myFacade.getProjectLibraryTable(ideProject); - for (Library ideLibrary : libraryTable.getLibraries()) { - if (libraryName.equals(ExternalSystemUtil.getLibraryName(ideLibrary))) { - return ideLibrary; - } - } - return null; - } - - @Nullable - public Library findIdeLibrary(@NotNull String libraryName, - @NotNull OrderRootType jarType, - @NotNull String jarPath, - @NotNull Project ideProject) - { - Library library = findIdeLibrary(libraryName, ideProject); - if (library == null) { - return null; - } - for (VirtualFile file : library.getFiles(jarType)) { - if (jarPath.equals(ExternalSystemUtil.getLocalFileSystemPath(file))) { - return library; - } - } - return null; - } - - @Nullable - public LibraryOrderEntry findIdeLibraryDependency(@NotNull LibraryDependencyId id, @NotNull Project ideProject) { - return findIdeLibraryDependency(id.getOwnerModuleName(), id.getLibraryId().getLibraryName(), ideProject); - } - - @Nullable - public LibraryOrderEntry findIdeLibraryDependency(@NotNull final String moduleName, - @NotNull final String libraryName, - @NotNull Project ideProject) - { - final Module ideModule = findIdeModule(moduleName, ideProject); - if (ideModule == null) { - return null; - } - RootPolicy visitor = new RootPolicy() { - @Override - public LibraryOrderEntry visitLibraryOrderEntry(LibraryOrderEntry ideDependency, LibraryOrderEntry value) { - if (libraryName.equals(ideDependency.getLibraryName())) { - return ideDependency; - } - return value; - } - }; - for (OrderEntry entry : myFacade.getOrderEntries(ideModule)) { - final LibraryOrderEntry result = entry.accept(visitor, null); - if (result != null) { - return result; - } - } - return null; - } - - @Nullable - public ModuleLibraryOrderEntryImpl findIdeModuleLocalLibraryDependency(@NotNull final String moduleName, - @NotNull final String libraryName, - @NotNull Project ideProject) - { - final Module ideModule = findIdeModule(moduleName, ideProject); - if (ideModule == null) { - return null; - } - RootPolicy visitor = new RootPolicy() { - @Override - public ModuleLibraryOrderEntryImpl visitLibraryOrderEntry(LibraryOrderEntry ideDependency, ModuleLibraryOrderEntryImpl value) { - Library library = ideDependency.getLibrary(); - if (library == null) { - return value; - } - if (ideDependency instanceof ModuleLibraryOrderEntryImpl && libraryName.equals(ExternalSystemUtil.getLibraryName(library))) { - return (ModuleLibraryOrderEntryImpl)ideDependency; - } - return value; - } - }; - for (OrderEntry entry : myFacade.getOrderEntries(ideModule)) { - final ModuleLibraryOrderEntryImpl result = entry.accept(visitor, null); - if (result != null) { - return result; - } - } - return null; - } - - @SuppressWarnings("MethodMayBeStatic") - @Nullable - public LibraryOrderEntry findIdeLibraryDependency(@NotNull final String libraryName, - @NotNull ModifiableRootModel model) - { - for (OrderEntry entry : model.getOrderEntries()) { - if (entry instanceof LibraryOrderEntry) { - LibraryOrderEntry candidate = (LibraryOrderEntry)entry; - if (libraryName.equals(candidate.getLibraryName())) { - return candidate; - } - } - } - return null; - } - - @Nullable - public DataNode findExternalLibrary(@NotNull final LibraryId id, - @NotNull ProjectSystemId externalSystemId, - @NotNull Project ideProject) - { - return findExternalLibrary(id.getLibraryName(), externalSystemId, ideProject); - } - - @Nullable - public DataNode findExternalLibrary(@NotNull final String libraryName, - @NotNull ProjectSystemId externalSystemId, - @NotNull Project ideProject) - { - final DataNode project = myChangesModel.getExternalProject(externalSystemId, ideProject); - if (project == null) { - return null; - } - for (DataNode libraryNode : ExternalSystemUtil.getChildren(project, ProjectKeys.LIBRARY)) { - if (libraryName.equals(libraryNode.getData().getName())) { - return libraryNode; - } - } - return null; - } - - @Nullable - public DataNode findExternalLibrary(@NotNull String libraryName, - @NotNull LibraryPathType jarType, - @NotNull String jarPath, - @NotNull ProjectSystemId externalSystemId, - @NotNull Project ideProject) - { - DataNode libraryNode = findExternalLibrary(libraryName, externalSystemId, ideProject); - if (libraryNode == null) { - return null; - } - return libraryNode.getData().getPaths(jarType).contains(jarPath) ? libraryNode : null; - } - - @Nullable - public Object findLibraryDependency(@NotNull final String moduleName, - @NotNull final String libraryName, - @NotNull ProjectSystemId owner, - @NotNull Project ideProject) { - if (ProjectSystemId.IDE.equals(owner)) { - return findIdeLibraryDependency(moduleName, libraryName, ideProject); - } - else { - return findExternalLibraryDependency(moduleName, libraryName, owner, ideProject); - } - } - - @Nullable - public DataNode findExternalLibraryDependency(@NotNull LibraryDependencyId id, - @NotNull ProjectSystemId externalSystemId, - @NotNull Project ideProject) - { - return findExternalLibraryDependency(id.getOwnerModuleName(), id.getLibraryId().getLibraryName(), externalSystemId, ideProject); - } - - @Nullable - public DataNode findExternalLibraryDependency(@NotNull final String moduleName, - @NotNull final String libraryName, - @NotNull ProjectSystemId externalSystemId, - @NotNull Project ideProject) - { - final DataNode module = findExternalModule(moduleName, externalSystemId, ideProject); - if (module == null) { - return null; - } - return ExternalSystemUtil.find(module, LIBRARY_DEPENDENCY, new BooleanFunction>() { - @Override - public boolean fun(DataNode node) { - return libraryName.equals(node.getData().getName()); - } - }); - } - - @Nullable - public DataNode findExternalModuleDependency(@NotNull ModuleDependencyId id, - @NotNull ProjectSystemId externalSystemId, - @NotNull Project ideProject) - { - return findExternalModuleDependency(id.getOwnerModuleName(), id.getDependencyName(), externalSystemId, ideProject); - } - - @Nullable - public DataNode findExternalModuleDependency(@NotNull final String ownerModuleName, - @NotNull final String dependencyModuleName, - @NotNull ProjectSystemId externalSystemId, - @NotNull Project ideProject) - { - final DataNode ownerModule = findExternalModule(ownerModuleName, externalSystemId, ideProject); - if (ownerModule == null) { - return null; - } - return ExternalSystemUtil.find(ownerModule, MODULE_DEPENDENCY, new BooleanFunction>() { - @Override - public boolean fun(DataNode node) { - return dependencyModuleName.equals(node.getData().getName()); - } - }); - } - - @Nullable - public ModuleOrderEntry findIdeModuleDependency(@NotNull final ModuleDependencyId id, @NotNull Project ideProject) { - return findIdeModuleDependency(id.getOwnerModuleName(), id.getDependencyName(), ideProject); - } - - @Nullable - public ModuleOrderEntry findIdeModuleDependency(@NotNull final ModuleDependencyData gradleDependency, @NotNull Project ideProject) { - return findIdeModuleDependency(gradleDependency.getOwnerModule().getName(), gradleDependency.getTarget().getName(), ideProject); - } - - @Nullable - public ModuleOrderEntry findIdeModuleDependency(@NotNull final String ownerModuleName, - @NotNull final String dependencyModuleName, - @NotNull Project ideProject) - { - final Module ideOwnerModule = findIdeModule(ownerModuleName, ideProject); - if (ideOwnerModule == null) { - return null; - } - - RootPolicy visitor = new RootPolicy() { - @Override - public ModuleOrderEntry visitModuleOrderEntry(ModuleOrderEntry ideDependency, ModuleOrderEntry value) { - if (dependencyModuleName.equals(ideDependency.getModuleName())) { - return ideDependency; - } - return value; - } - }; - for (OrderEntry orderEntry : myFacade.getOrderEntries(ideOwnerModule)) { - final ModuleOrderEntry result = orderEntry.accept(visitor, null); - if (result != null) { - return result; - } - } - return null; - } - - @Nullable - public Object findModuleDependency(@NotNull final String ownerModuleName, - @NotNull final String dependencyModuleName, - @NotNull ProjectSystemId owner, - @NotNull Project ideProject) { - if (ProjectSystemId.IDE.equals(owner)) { - return findIdeModuleDependency(ownerModuleName, dependencyModuleName, ideProject); - } - else { - return findExternalModuleDependency(ownerModuleName, dependencyModuleName, owner, ideProject); - } - } - - @SuppressWarnings("MethodMayBeStatic") - @Nullable - public ModuleOrderEntry findIdeModuleDependency(@NotNull ModuleDependencyData dependency, @NotNull ModifiableRootModel model) { - for (OrderEntry entry : model.getOrderEntries()) { - if (entry instanceof ModuleOrderEntry) { - ModuleOrderEntry candidate = (ModuleOrderEntry)entry; - if (dependency.getName().equals(candidate.getModuleName())) { - return candidate; - } - } - } - return null; - } - - @Nullable - public JarData findIdeJar(@NotNull JarId jarId, @NotNull Project ideProject) { - Library library = findIdeLibrary(jarId.getLibraryId().getLibraryName(), ideProject); - if (library == null) { - return null; - } - for (VirtualFile file : library.getFiles(myLibraryPathTypeMapper.map(jarId.getLibraryPathType()))) { - if (jarId.getPath().equals(ExternalSystemUtil.getLocalFileSystemPath(file))) { - return new JarData(jarId.getPath(), jarId.getLibraryPathType(), library, null, ProjectSystemId.IDE); - } - } - return null; - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/AutoImporter.java b/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/AutoImporter.java deleted file mode 100644 index 688cb5cc59c8..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/AutoImporter.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.service.project.change; - -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.change.ExternalProjectStructureChange; -import com.intellij.openapi.externalSystem.model.project.change.user.UserProjectChange; -import com.intellij.openapi.externalSystem.service.project.manage.EntityManageHelper; -import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings; -import com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsManager; -import com.intellij.openapi.externalSystem.settings.UserProjectChanges; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.text.StringUtil; -import org.jetbrains.annotations.NotNull; - -import java.util.Collection; -import java.util.Set; -import java.util.concurrent.atomic.AtomicBoolean; - -/** - * Automates a task of keeping gradle and ide projects in sync, - *

- * The general idea is to import all gradle-local entities as soon as they are detected. However, it doesn't that simple. - * Consider a situation when a user, say, renames a module (gradle sub-project). We would like not only import new module - * but remove the old one as well. Unfortunately, we don't have api for distinguishing change like 'gradle sub-project remove' - * from 'new module is added to the project by a user'. They both look like 'new ide-local module'. That's why we use the following - * algorithm for every project structure change here: - *

- * 
    - *
  1. - * Check if there is an {@link UserProjectChange explicitly made project structure change} for the current project - * structure change; - *
  2. - *
  3. - * {@link EntityManageHelper#eliminateChange(Project, Collection, Set, boolean) Resolve the change} if it doesn't occur - * because of user actions (e.g. we don't want to auto-remove a module which is absent at gradle but presents at IDE); - *
  4. - *
- *
- * - * @author Denis Zhdanov - * @since 2/18/13 7:55 PM - */ -public class AutoImporter implements ExternalProjectStructureChangesPostProcessor { - - @NotNull private final AtomicBoolean myInProgress = new AtomicBoolean(); - - @NotNull private final ExternalSystemSettingsManager mySettingsManager; - @NotNull private final EntityManageHelper myEntityManageHelper; - - public AutoImporter(@NotNull ExternalSystemSettingsManager manager, @NotNull EntityManageHelper helper) { - mySettingsManager = manager; - myEntityManageHelper = helper; - } - - public boolean isInProgress() { - return myInProgress.get(); - } - - @SuppressWarnings("unchecked") - @Override - public void processChanges(@NotNull Collection changes, - @NotNull ProjectSystemId externalSystemId, - @NotNull Project project, - boolean onIdeProjectStructureChange) - { - if (onIdeProjectStructureChange) { - return; - } - AbstractExternalSystemSettings settings = mySettingsManager.getSettings(project, externalSystemId); - if (!settings.isUseAutoImport() || StringUtil.isEmpty(settings.getLinkedExternalProjectPath())) { - return; - } - - Set nonProcessed; - myInProgress.set(true); - try { - Set> userChanges = UserProjectChanges.getInstance(project).getUserProjectChanges(); - nonProcessed = myEntityManageHelper.eliminateChange(project, changes, userChanges, true); - } - finally { - myInProgress.set(false); - } - changes.clear(); - changes.addAll(nonProcessed); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/ExternalProjectChangesCalculationContext.java b/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/ExternalProjectChangesCalculationContext.java deleted file mode 100644 index aa6372c960ed..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/ExternalProjectChangesCalculationContext.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.intellij.openapi.externalSystem.service.project.change; - -import com.intellij.openapi.externalSystem.model.project.change.ExternalProjectStructureChange; -import com.intellij.openapi.externalSystem.service.project.ExternalLibraryPathTypeMapper; -import com.intellij.openapi.externalSystem.service.project.PlatformFacade; -import com.intellij.util.containers.ContainerUtilRt; -import org.jetbrains.annotations.NotNull; - -import java.util.Set; - -/** - * 'Parameter object' to use during project structure changes calculations. - *

- * Not thread-safe. - */ -public class ExternalProjectChangesCalculationContext { - - @NotNull private final Set myKnownChanges = ContainerUtilRt.newHashSet(); - @NotNull private final Set myCurrentChanges = ContainerUtilRt.newHashSet(); - - @NotNull private final PlatformFacade myPlatformFacade; - @NotNull private final ExternalLibraryPathTypeMapper myLibraryPathTypeMapper; - - /** - * @param knownChanges changes between the gradle and ide project structure that has been known up until now - * @param platformFacade platform facade to use during the calculations - * @param mapper library path type mapper to use during the calculation - */ - public ExternalProjectChangesCalculationContext(@NotNull Set knownChanges, - @NotNull PlatformFacade platformFacade, - @NotNull ExternalLibraryPathTypeMapper mapper) - { - myLibraryPathTypeMapper = mapper; - myKnownChanges.addAll(knownChanges); - myPlatformFacade = platformFacade; - } - - @NotNull - public Set getKnownChanges() { - return myKnownChanges; - } - - @NotNull - public Set getCurrentChanges() { - return myCurrentChanges; - } - - public void register(@NotNull ExternalProjectStructureChange change) { - myCurrentChanges.add(change); - } - - public boolean hasNewChanges() { - return !myKnownChanges.equals(myCurrentChanges); - } - - @NotNull - public PlatformFacade getPlatformFacade() { - return myPlatformFacade; - } - - @NotNull - public ExternalLibraryPathTypeMapper getLibraryPathTypeMapper() { - return myLibraryPathTypeMapper; - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/ExternalProjectStructureChangeListener.java b/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/ExternalProjectStructureChangeListener.java deleted file mode 100644 index 1de35dd7690a..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/ExternalProjectStructureChangeListener.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.intellij.openapi.externalSystem.service.project.change; - -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.change.ExternalProjectStructureChange; -import com.intellij.openapi.project.Project; -import org.jetbrains.annotations.NotNull; - -import java.util.Collection; - -/** - * Defines common interface for clients interested in project structure change events. - *

- * Implementations of this interface are not obliged to be thread-safe. - * - * @author Denis Zhdanov - * @since 11/3/11 7:04 PM - */ -public interface ExternalProjectStructureChangeListener { - - /** - * Notifies current listener on the newly discovered changes between the external system' and ide project models. - * - * @param ideProject target ide project - * @param externalSystemId if of the external system which project structure has been compared to the given ide project - * @param oldChanges changes between the external system' and ide project models that had been known prior to the current update - * @param currentChanges the most up-to-date changes between the external system and ide project models - */ - void onChanges(@NotNull Project ideProject, - @NotNull ProjectSystemId externalSystemId, - @NotNull Collection oldChanges, - @NotNull Collection currentChanges); -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/ExternalProjectStructureChangesPostProcessor.java b/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/ExternalProjectStructureChangesPostProcessor.java deleted file mode 100644 index f013f360f684..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/ExternalProjectStructureChangesPostProcessor.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.service.project.change; - -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.change.ExternalProjectStructureChange; -import com.intellij.openapi.project.Project; -import org.jetbrains.annotations.NotNull; - -import java.util.Collection; - -/** - * Defines contract for entity which is eligible to adjust project structure changes. - * E.g. resolve changes (auto-import), transform them (build one 'dependency library is outdated from 'external-system-local library' and - * 'ide-local library' changes etc. - *

- * Implementations of this interface are expected to be thread-safe. - * - * @author Denis Zhdanov - * @since 1/16/13 5:24 PM - */ -public interface ExternalProjectStructureChangesPostProcessor { - - /** - * Callback to provide current post processor with information about current changes and ability to adjust them in-place. - *

- * Note: this callback is assumed to be called from EDT, in order to allow synchronous processing such as - * given changes collection's modification is immediately visible to the calling code. - * - * @param changes current changes which might be adjusted - * @param externalSystemId target external system against which given project changes have been detected - * @param project current ide project - * @param onIdeProjectStructureChange a flag which identifies if current update is triggered by ide project structure - * change (an alternative is a manual project structure changes refresh implied by a user) - */ - void processChanges(@NotNull Collection changes, - @NotNull ProjectSystemId externalSystemId, - @NotNull Project project, - boolean onIdeProjectStructureChange); -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/ExternalProjectStructureChangesPreProcessor.java b/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/ExternalProjectStructureChangesPreProcessor.java deleted file mode 100644 index d95615abf829..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/ExternalProjectStructureChangesPreProcessor.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.service.project.change; - -import com.intellij.openapi.externalSystem.model.project.ProjectData; -import com.intellij.openapi.project.Project; -import org.jetbrains.annotations.NotNull; - -/** - * Defines a contract for a callback which is triggered before a project structure changes calculation. - *

- * Implementations of this interface are expected to be thread-safe. - * - * @author Denis Zhdanov - * @since 2/13/13 9:05 AM - */ -public interface ExternalProjectStructureChangesPreProcessor { - - @NotNull - ProjectData preProcess(@NotNull ProjectData externalProject, @NotNull Project ideProject); -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/MovedJarsPostProcessor.java b/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/MovedJarsPostProcessor.java deleted file mode 100644 index 3bbe6d86c574..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/MovedJarsPostProcessor.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.service.project.change; - -import com.intellij.openapi.components.ServiceManager; -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.JarData; -import com.intellij.openapi.externalSystem.model.project.change.ExternalProjectStructureChange; -import com.intellij.openapi.externalSystem.model.project.change.ExternalProjectStructureChangeVisitor; -import com.intellij.openapi.externalSystem.model.project.change.ExternalProjectStructureChangeVisitorAdapter; -import com.intellij.openapi.externalSystem.model.project.change.JarPresenceChange; -import com.intellij.openapi.externalSystem.model.project.id.JarId; -import com.intellij.openapi.externalSystem.service.project.ProjectStructureServices; -import com.intellij.openapi.externalSystem.service.project.manage.JarDataService; -import com.intellij.openapi.externalSystem.util.ArtifactInfo; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.ex.ProjectRootManagerEx; -import com.intellij.util.containers.ContainerUtilRt; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import com.intellij.openapi.externalSystem.model.project.LibraryPathType; - -import java.util.*; - -/** - * {@link ExternalProjectStructureChangesPostProcessor} implementation which adjusts library jars paths when it detects that they - * have been moved. - *

- * Target use-case: external system uses version-specific file system directory for holding downloaded library dependencies. - * I.e. when we build project info with external system of version X, it puts all jars into directory Dx. But when - * external system version is changed to Y, it will store all jars into directory Dy (different from Dx). So, following - * scenario is possible: - *

- * 
    - *
  1. A user imports IJ project from the external system v.X;
  2. - *
  3. All necessary jars are downloaded and stored at Dx;
  4. - *
  5. A user switched the external system to version Y;
  6. - *
  7. - * When the project is refreshed we have a number of changes like 'external-system-local jar with location at Dy' and - * 'ide-local jar with location at Dx'; - *
  8. - *
- *
- * We want to avoid that by auto-adjusting ide library path config within the moved jars info. - *

- * Thread-safe. - * - * @author Denis Zhdanov - * @since 1/16/13 6:19 PM - */ -public class MovedJarsPostProcessor implements ExternalProjectStructureChangesPostProcessor { - - @NotNull private final JarDataService myJarManager; - - public MovedJarsPostProcessor(@NotNull JarDataService manager) { - myJarManager = manager; - } - - @Override - public void processChanges(@NotNull final Collection changes, - @NotNull ProjectSystemId externalSystemId, - @NotNull final Project project, - boolean onIdeProjectStructureChange) - { - if (onIdeProjectStructureChange) { - // Do nothing as project models modification implied by project model change event are prohibited (see IDEA-100625). - return; - } - final Collection toMerge = buildMergeData(project, changes, ServiceManager.getService(ProjectStructureServices.class)); - if (toMerge == null) { - return; - } - - Runnable mergeTask = new Runnable() { - @Override - public void run() { - for (MergeInfo info : toMerge) { - // TODO den implement -// myJarManager.removeJars(Collections.singleton(info.ideJar), project, true); -// myJarManager.importJars(Collections.singleton(info.gradleJar), project, true); - changes.removeAll(info.changes); - } - } - }; - doMerge(mergeTask, project); - } - - /** - * This method is introduced in order to allow to cut 'Execute EDT/Execute under write action' etc stuff during test execution. - * - * @param mergeTask merge changes function object - * @param project target project - */ - public void doMerge(@NotNull final Runnable mergeTask, @NotNull final Project project) { - ExternalSystemUtil.executeProjectChangeAction(project, ProjectSystemId.IDE, mergeTask, true, new Runnable() { - @Override - public void run() { - ProjectRootManagerEx.getInstanceEx(project).mergeRootsChangesDuring(mergeTask); - } - }); - } - - @Nullable - static Collection buildMergeData(@NotNull Project project, - @NotNull Collection changes, - @NotNull ProjectStructureServices services) - { - final Map> changesByLibrary = ContainerUtilRt.newHashMap(); - ExternalProjectStructureChangeVisitor visitor = new ExternalProjectStructureChangeVisitorAdapter() { - @Override - public void visit(@NotNull JarPresenceChange change) { - JarId id = change.getIdeEntity(); - if (id == null) { - id = change.getExternalEntity(); - } - assert id != null; - String libraryName = id.getLibraryId().getLibraryName(); - Set c = changesByLibrary.get(libraryName); - if (c == null) { - changesByLibrary.put(libraryName, c = ContainerUtilRt.newHashSet()); - } - c.add(change); - } - }; - for (ExternalProjectStructureChange change : changes) { - change.invite(visitor); - } - - final Collection toMerge = ContainerUtilRt.newArrayList(); - for (Set c : changesByLibrary.values()) { - processLibraryJarChanges(project, c, services, toMerge); - } - if (toMerge.isEmpty()) { - return null; - } - return toMerge; - } - - private static void processLibraryJarChanges(@NotNull Project project, - @NotNull Set changes, - @NotNull ProjectStructureServices services, - @NotNull Collection toMerge) - { - Map> gradleLocalJars = ContainerUtilRt.newHashMap(); - Map> ideLocalJars = ContainerUtilRt.newHashMap(); - for (JarPresenceChange change : changes) { - Map> storageToUse = gradleLocalJars; - JarId entity = change.getExternalEntity(); - if (entity == null) { - entity = change.getIdeEntity(); - assert entity != null; - storageToUse = ideLocalJars; - } - ArtifactInfo artifactInfo = ExternalSystemUtil.parseArtifactInfo(entity.getPath()); - if (artifactInfo != null) { - Map m = storageToUse.get(entity.getLibraryPathType()); - if (m == null) { - storageToUse.put(entity.getLibraryPathType(), m = ContainerUtilRt.newHashMap()); - } - m.put(artifactInfo, change); - } - } - - for (Map.Entry> entry : gradleLocalJars.entrySet()) { - for (ArtifactInfo info : entry.getValue().keySet()) { - Map m = ideLocalJars.get(entry.getKey()); - if (m == null) { - continue; - } - JarPresenceChange ideLocalJarChange = m.get(info); - if (ideLocalJarChange == null) { - continue; - } - JarId ideJarId = ideLocalJarChange.getIdeEntity(); - assert ideJarId != null; - JarData ideJar = ideJarId.mapToEntity(services, project); - if (ideJar == null) { - continue; - } - - JarPresenceChange gradleLocalJarChange = entry.getValue().get(info); - JarId jarId = gradleLocalJarChange.getExternalEntity(); - assert jarId != null; - JarData gradleJar = jarId.mapToEntity(services, project); - if (gradleJar == null) { - continue; - } - - toMerge.add(new MergeInfo(gradleJar, ideJar, gradleLocalJarChange, ideLocalJarChange)); - } - } - } - - static class MergeInfo { - - @NotNull public final Collection changes = ContainerUtilRt.newArrayList(); - - @NotNull public final JarData gradleJar; - @NotNull public final JarData ideJar; - - MergeInfo(@NotNull JarData gradleJar, @NotNull JarData ideJar, JarPresenceChange... changes) { - this.gradleJar = gradleJar; - this.ideJar = ideJar; - this.changes.addAll(Arrays.asList(changes)); - } - - @Override - public String toString() { - return String.format("jar '%s' for library '%s'", gradleJar.getName(), gradleJar.getLibraryId().getLibraryName()); - } - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/OutdatedLibraryVersionPostProcessor.java b/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/OutdatedLibraryVersionPostProcessor.java deleted file mode 100644 index 90d7ecb65521..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/OutdatedLibraryVersionPostProcessor.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.service.project.change; - -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.change.*; -import com.intellij.openapi.externalSystem.model.project.id.JarId; -import com.intellij.openapi.externalSystem.model.project.id.LibraryDependencyId; -import com.intellij.openapi.externalSystem.util.ArtifactInfo; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; -import com.intellij.openapi.project.Project; -import com.intellij.util.SystemProperties; -import com.intellij.util.containers.ContainerUtilRt; -import org.jetbrains.annotations.NotNull; -import com.intellij.openapi.externalSystem.model.project.id.LibraryId; - -import java.util.Collection; -import java.util.Map; -import java.util.Set; - -/** - * There is a following possible scenario: - *

- * 
    - *
  1. A user imports a project from an external system (ide and external system projects are in sync now);
  2. - *
  3. New version is defined at the external system for particular library;
  4. - *
  5. Now we have two changes - external-system-local library (new version) and ide-local library (old version);
  6. - *
- *
- * It would be more convenient to provide a single change - 'outdated library' version. That gives a benefit that such a change - * might be resolved in a single step instead of two (remove ide-local & import external-system-local). - *

- * This post-processor checks changes and combines that ide- and external-system-local library versions changes into a single one. - *

- * Thread-safe. - * - * @author Denis Zhdanov - * @since 1/22/13 12:17 PM - */ -public class OutdatedLibraryVersionPostProcessor implements ExternalProjectStructureChangesPostProcessor { - - private static final boolean SKIP = SystemProperties.getBooleanProperty("gradle.skip.outdated.processing", false); - - @Override - public void processChanges(@NotNull Collection changes, - @NotNull ProjectSystemId externalSystemId, - @NotNull Project project, - boolean onIdeProjectStructureChange) - { - if (SKIP) { - return; - } - - final Map gradleData = ContainerUtilRt.newHashMap(); - final Map ideData = ContainerUtilRt.newHashMap(); - final Set jarPresenceChanges = ContainerUtilRt.newHashSet(); - - //region Collect library dependency-local changes. - ExternalProjectStructureChangeVisitor visitor = new ExternalProjectStructureChangeVisitorAdapter() { - @Override - public void visit(@NotNull LibraryDependencyPresenceChange change) { - Map container = gradleData; - LibraryDependencyId libraryDependencyId = change.getExternalEntity(); - if (libraryDependencyId == null) { - container = ideData; - libraryDependencyId = change.getIdeEntity(); - } - assert libraryDependencyId != null; - LibraryId libraryId = libraryDependencyId.getLibraryId(); - ArtifactInfo artifactInfo = ExternalSystemUtil.parseArtifactInfo(libraryId.getLibraryName()); - if (artifactInfo == null) { - return; - } - String libraryName = artifactInfo.getName(); - String libraryVersion = artifactInfo.getVersion(); - if (libraryName == null || libraryVersion == null) { - return; - } - Info info = container.get(libraryName); - if (info == null) { - container.put(libraryName, info = new Info(libraryId, libraryName, libraryVersion)); - } - info.dependencyPresenceChanges.add(change); - } - - @Override - public void visit(@NotNull JarPresenceChange change) { - jarPresenceChanges.add(change); - } - }; - for (ExternalProjectStructureChange change : changes) { - change.invite(visitor); - } - //endregion - - Set libraryIds = ContainerUtilRt.newHashSet(); - - //region Build library version change objects and forget ide- and gradle-local library dependency presence changes. - for (Map.Entry entry : gradleData.entrySet()) { - Info ideInfo = ideData.get(entry.getKey()); - if (ideInfo == null) { - continue; - } - Info gradleInfo = entry.getValue(); - changes.add(new OutdatedLibraryVersionChange( - ideInfo.libraryName, gradleInfo.libraryId, gradleInfo.libraryVersion, ideInfo.libraryId, ideInfo.libraryVersion - )); - libraryIds.add(gradleInfo.libraryId); - libraryIds.add(ideInfo.libraryId); - - // There is a possible situation that gradle project has more than one module which depend on the same library - // but some of the corresponding ide modules doesn't have that library dependency at all. We want to show it as - // gradle-local for it then. The same is true for the opposite situation (ide-local outdated library). - Map gradleLibraryDependencies = ContainerUtilRt.newHashMap(); - for (LibraryDependencyPresenceChange c : gradleInfo.dependencyPresenceChanges) { - LibraryDependencyId e = c.getExternalEntity(); - assert e != null; - gradleLibraryDependencies.put(e.getOwnerModuleName(), c); - } - for (LibraryDependencyPresenceChange c : ideInfo.dependencyPresenceChanges) { - LibraryDependencyId e = c.getIdeEntity(); - assert e != null; - LibraryDependencyPresenceChange gradleChange = gradleLibraryDependencies.remove(e.getOwnerModuleName()); - if (gradleChange != null) { - changes.remove(gradleChange); - changes.remove(c); - } - } - } - //endregion - - //region Drop information about jar presence changes for outdated libraries. - for (JarPresenceChange change : jarPresenceChanges) { - JarId jarId = change.getExternalEntity(); - if (jarId == null) { - jarId = change.getIdeEntity(); - } - assert jarId != null; - if (libraryIds.contains(jarId.getLibraryId())) { - changes.remove(change); - } - } - //endregion - - } - - private static class Info { - - @NotNull public final Set dependencyPresenceChanges = ContainerUtilRt.newHashSet(); - - @NotNull public final LibraryId libraryId; - @NotNull public final String libraryName; - @NotNull public final String libraryVersion; - - Info(@NotNull LibraryId id, @NotNull String libraryName, @NotNull String libraryVersion) { - libraryId = id; - this.libraryName = libraryName; - this.libraryVersion = libraryVersion; - } - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/ProjectStructureChangesModel.java b/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/ProjectStructureChangesModel.java deleted file mode 100644 index ae60a27ea00a..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/ProjectStructureChangesModel.java +++ /dev/null @@ -1,221 +0,0 @@ -package com.intellij.openapi.externalSystem.service.project.change; - -import com.intellij.openapi.externalSystem.model.DataNode; -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.ProjectData; -import com.intellij.openapi.externalSystem.model.project.change.ExternalProjectStructureChange; -import com.intellij.openapi.externalSystem.model.project.change.ExternalProjectStructureChangesCalculator; -import com.intellij.openapi.externalSystem.service.DisposableExternalSystemService; -import com.intellij.openapi.externalSystem.service.project.ExternalLibraryPathTypeMapper; -import com.intellij.openapi.externalSystem.service.project.PlatformFacade; -import com.intellij.openapi.externalSystem.util.IntegrationKey; -import com.intellij.openapi.project.Project; -import com.intellij.util.containers.ConcurrentHashSet; -import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.containers.ContainerUtilRt; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.TestOnly; - -import java.util.Collection; -import java.util.Collections; -import java.util.Set; -import java.util.concurrent.ConcurrentMap; - -/** - * Manages information about the changes between the gradle and intellij project structures. - *

- * Thread-safe. - * - * @author Denis Zhdanov - * @since 11/3/11 7:01 PM - */ -public class ProjectStructureChangesModel implements DisposableExternalSystemService { - - private final Set myListeners = new ConcurrentHashSet(); - - private final ConcurrentMap> myChanges = ContainerUtil.newConcurrentMap(); - private final ConcurrentMap> myExternalProjects = ContainerUtil.newConcurrentMap(); - - private final Collection myCommonPreProcessors = ContainerUtilRt.createEmptyCOWList(); - private final Collection myCommonPostProcessors = ContainerUtilRt.createEmptyCOWList(); - - private final ConcurrentMap> mySpecificPreProcessors = - ContainerUtil.newConcurrentMap(); - private final ConcurrentMap> mySpecificPostProcessors = - ContainerUtil.newConcurrentMap(); - - // TODO den uncomment - //@NotNull private final ExternalProjectStructureChangesCalculator myChangesCalculator; - @NotNull private final PlatformFacade myPlatformFacade; - @NotNull private final ExternalLibraryPathTypeMapper myLibraryPathTypeMapper; - - // TODO den uncomment - public ProjectStructureChangesModel(/*@NotNull ExternalProjectStructureChangesCalculator changesCalculator,*/ - @NotNull PlatformFacade platformFacade, - @NotNull ExternalLibraryPathTypeMapper mapper - /*@NotNull AutoImporter autoImporter, - @NotNull MovedJarsPostProcessor movedJarsPostProcessor, - @NotNull OutdatedLibraryVersionPostProcessor changedLibraryVersionPostProcessor*/) - { - // TODO den uncomment - //myChangesCalculator = changesCalculator; - myPlatformFacade = platformFacade; - myLibraryPathTypeMapper = mapper; - // TODO den uncomment - //myCommonPostProcessors.add(autoImporter); - //myCommonPostProcessors.add(movedJarsPostProcessor); - //myCommonPostProcessors.add(changedLibraryVersionPostProcessor); - } - - /** - * Asks the model to update its state according to the given state of the target external project. - *

- * I.e. basically the processing looks as following: - *

    - *
  1. This method is called;
  2. - *
  3. - * The model process given project state within the {@link #getChanges(ProjectSystemId, Project) registered changes} and calculates - * resulting difference between external system and ide projects; - *
  4. - *
  5. - * {@link #addListener(ExternalProjectStructureChangeListener) Registered listeners} are notified - * if any new change is detected; - *
  6. - *
- *

- * Note: the listeners are notified after the actual state change, i.e. {@link #getChanges(ProjectSystemId, Project)} - * during the update returns up-to-date data. - * - * @param externalProject external project to sync with - * @param ideProject target ide project - * @param onIdeProjectStructureChange a flag which identifies if current update is triggered by ide project structure - * change (an alternative is a manual project structure changes refresh implied by a user) - */ - public void update(@NotNull DataNode externalProject, @NotNull Project ideProject, boolean onIdeProjectStructureChange) { - DataNode externalProjectToUse = externalProject; - // TODO den uncomment -// for (ExternalProjectStructureChangesPreProcessor preProcessor : myCommonPreProcessors) { -// externalProjectToUse = preProcessor.preProcess(externalProjectToUse, ideProject); -// } - ProjectSystemId externalSystemId = externalProject.getData().getOwner(); - IntegrationKey key = new IntegrationKey(ideProject, externalSystemId); - myExternalProjects.putIfAbsent(key, externalProjectToUse); - final ExternalProjectChangesCalculationContext context = getCurrentChangesContext( - externalProjectToUse, ideProject, onIdeProjectStructureChange - ); - if (!context.hasNewChanges()) { - return; - } - myChanges.put(key, context.getCurrentChanges()); - for (ExternalProjectStructureChangeListener listener : myListeners) { - listener.onChanges(ideProject, externalSystemId, context.getKnownChanges(), context.getCurrentChanges()); - } - } - - public void addPreProcessor(@NotNull ProjectSystemId externalSystemId, - @NotNull ExternalProjectStructureChangesPostProcessor postProcessor) - { - add(externalSystemId, postProcessor, mySpecificPreProcessors); - } - - public void addPostProcessor(@NotNull ProjectSystemId externalSystemId, - @NotNull ExternalProjectStructureChangesPostProcessor postProcessor) - { - add(externalSystemId, postProcessor, mySpecificPostProcessors); - } - - private static void add(@NotNull ProjectSystemId externalSystemId, - @NotNull T data, - @NotNull ConcurrentMap> holder) - { - Set set = holder.get(externalSystemId); - while (set == null) { - holder.putIfAbsent(externalSystemId, new ConcurrentHashSet()); - set = holder.get(externalSystemId); - } - set.add(data); - } - - /** - * @param id target external system id - * @param ideProject target ide project which might be linked to an external project of the given type - * @return last known external project state (if any) of the given type linked to the given ide project - */ - @SuppressWarnings("unchecked") - @Nullable - public DataNode getExternalProject(@NotNull ProjectSystemId id, @NotNull Project ideProject) { - DataNode result = myExternalProjects.get(new IntegrationKey(ideProject, id)); - if (result == null) { - return null; - } - return result; - } - - @NotNull - @TestOnly - public Collection getCommonPreProcessors() { - return myCommonPreProcessors; - } - - @NotNull - @TestOnly - public Collection getCommonPostProcessors() { - return myCommonPostProcessors; - } - - /** - * Registers given listener within the current model. - * - * @param listener listener to register - * @return true if given listener was not registered before; - * false otherwise - */ - public boolean addListener(@NotNull ExternalProjectStructureChangeListener listener) { - return myListeners.add(listener); - } - - @NotNull - public ExternalProjectChangesCalculationContext getCurrentChangesContext(@NotNull DataNode externalProject, - @NotNull Project ideProject, - boolean onIdeProjectStructureChange) - { - ProjectSystemId owner = externalProject.getData().getOwner(); - IntegrationKey key = new IntegrationKey(ideProject, owner); - Set knownChanges = myChanges.get(key); - if (knownChanges == null) { - knownChanges = Collections.emptySet(); - } - ExternalProjectChangesCalculationContext context - = new ExternalProjectChangesCalculationContext(knownChanges, myPlatformFacade, myLibraryPathTypeMapper); - // TODO den uncomment -// myChangesCalculator.calculate(externalProject, ideProject, context); - for (ExternalProjectStructureChangesPostProcessor processor : myCommonPostProcessors) { - processor.processChanges(context.getCurrentChanges(), owner, ideProject, onIdeProjectStructureChange); - } - Set postProcessors = mySpecificPostProcessors.get(owner); - if (postProcessors != null) - for (ExternalProjectStructureChangesPostProcessor processor : myCommonPostProcessors) { - processor.processChanges(context.getCurrentChanges(), owner, ideProject, onIdeProjectStructureChange); - } - return context; - } - - /** - * @param id target external system id - * @return collection of project structure changes between the external system with the given id and - * given ide project registered within the current model - */ - @NotNull - public Set getChanges(@NotNull ProjectSystemId id, @NotNull Project ideProject) { - Set result = myChanges.get(new IntegrationKey(ideProject, id)); - return result == null ? Collections.emptySet() : result; - } - - @Override - public void onExternalSystemUnlinked(@NotNull ProjectSystemId externalSystemId, @NotNull Project ideProject) { - IntegrationKey key = new IntegrationKey(ideProject, externalSystemId); - myChanges.remove(key); - myExternalProjects.remove(key); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/user/UserProjectChangesCalculator.java b/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/user/UserProjectChangesCalculator.java deleted file mode 100644 index 879db6cc6d89..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/change/user/UserProjectChangesCalculator.java +++ /dev/null @@ -1,500 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.service.project.change.user; - -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.*; -import com.intellij.openapi.externalSystem.model.project.change.user.*; -import com.intellij.openapi.externalSystem.service.project.PlatformFacade; -import com.intellij.openapi.externalSystem.service.project.ProjectStructureHelper; -import com.intellij.openapi.externalSystem.settings.UserProjectChanges; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.*; -import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.util.Pair; -import com.intellij.openapi.util.Ref; -import com.intellij.util.Function; -import com.intellij.util.NullableFunction; -import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.containers.ContainerUtilRt; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.Map; -import java.util.Set; - -/** - * Encapsulates functionality of managing - * {@link UserProjectChanges#getUserProjectChanges() explicit project structure changes made by user}. - * - * @author Denis Zhdanov - * @since 2/19/13 9:27 AM - */ -public class UserProjectChangesCalculator { - - @NotNull - private static final Function> MODULE_ADDED = new Function>() { - @Override - public UserProjectChange fun(String moduleName) { - return new AddModuleUserChange(moduleName); - } - }; - - @NotNull - private static final Function> MODULE_REMOVED = new Function>() { - @Override - public UserProjectChange fun(String moduleName) { - return new RemoveModuleUserChange(moduleName); - } - }; - - @NotNull private final PlatformFacade myFacade; - @NotNull private final ProjectStructureHelper myProjectStructureHelper; - - @Nullable private ProjectData myLastProjectState; - - public UserProjectChangesCalculator(@NotNull PlatformFacade facade, @NotNull ProjectStructureHelper helper) { - myFacade = facade; - myProjectStructureHelper = helper; - } - - /** - * Resets 'last known ide project state' to the current one for the given project. - * - * @param project target project - * @return current ide project state - */ - @Nullable - public ProjectData updateCurrentProjectState(@NotNull Project project) { - ProjectData state = buildCurrentIdeProject(project); - myLastProjectState = state; - filterOutdatedChanges(project); - return state; - } - - /** - * This method is expected to be called every time manual project structure change is detected. It compares current project structure - * with the {@link #updateCurrentProjectState(Project) previous one} and considers all changes between them as user-made. - *

- * All are checked for validity and dropped if they are out of date. - * - * @param project - */ - public void updateChanges(@NotNull Project project) { - ProjectData lastProjectState = myLastProjectState; - if (lastProjectState == null) { - updateCurrentProjectState(project); - return; - } - - ProjectData currentProjectState = buildCurrentIdeProject(project); - if (currentProjectState == null) { - return; - } - - Context context = new Context(lastProjectState, currentProjectState); - - buildModulePresenceChanges(context); - buildDependencyPresenceChanges(context); - filterOutdatedChanges(project); - UserProjectChanges changes = UserProjectChanges.getInstance(project); - context.currentChanges.addAll(changes.getUserProjectChanges()); - changes.setUserProjectChanges(context.currentChanges); - myLastProjectState = currentProjectState; - } - - /** - * We of project structure changes explicitly made by a user. - * It's possible, however, that some change might become outdated. Example: - *

-   * 
    - *
  1. New module is added to a project;
  2. - *
  3. Corresponding change is created;
  4. - *
  5. The module is removed from the project;
  6. - *
  7. The change is out of date now;
  8. - *
- *
- * This method removes all such outdated changes. - * - * @param project target ide project - */ - public void filterOutdatedChanges(@NotNull Project project) { - UserProjectChanges changesHolder = UserProjectChanges.getInstance(project); - Set> changes = ContainerUtilRt.newHashSet(changesHolder.getUserProjectChanges()); - for (UserProjectChange change : changesHolder.getUserProjectChanges()) { - if (!isUpToDate(change, project)) { - changes.remove(change); - } - } - changesHolder.setUserProjectChanges(changes); - } - - private static void buildModulePresenceChanges(@NotNull final Context context) { - buildPresenceChanges(context.oldModules.keySet(), context.currentModules.keySet(), MODULE_ADDED, MODULE_REMOVED, context); - } - - private static void buildDependencyPresenceChanges(@NotNull Context context) { - Set commonModuleNames = ContainerUtilRt.newHashSet(context.currentModules.keySet()); - commonModuleNames.retainAll(context.oldModules.keySet()); - for (final String moduleName : commonModuleNames) { - final Map currentModuleDependencies = ContainerUtilRt.newHashMap(); - final Map oldModuleDependencies = ContainerUtilRt.newHashMap(); - final Map currentLibraryDependencies = ContainerUtilRt.newHashMap(); - final Map oldLibraryDependencies = ContainerUtilRt.newHashMap(); - - // TODO den implement -// ExternalEntityVisitor oldStateVisitor = new ExternalEntityVisitorAdapter() { -// @Override -// public void visit(@NotNull ModuleDependencyData dependency) { -// oldModuleDependencies.put(dependency.getTarget().getName(), dependency); -// } -// -// @Override -// public void visit(@NotNull LibraryDependencyData dependency) { -// oldLibraryDependencies.put(dependency.getTarget().getName(), dependency); -// } -// }; -// for (DependencyData dependency : context.oldModules.get(moduleName).getDependencies()) { -// dependency.invite(oldStateVisitor); -// } - -// ExternalEntityVisitor currentStateVisitor = new ExternalEntityVisitorAdapter() { -// @Override -// public void visit(@NotNull ModuleDependencyData dependency) { -// currentModuleDependencies.put(dependency.getTarget().getName(), dependency); -// } -// -// @Override -// public void visit(@NotNull LibraryDependencyData dependency) { -// currentLibraryDependencies.put(dependency.getTarget().getName(), dependency); -// } -// }; -// for (DependencyData dependency : context.currentModules.get(moduleName).getDependencies()) { -// dependency.invite(currentStateVisitor); -// } - - Function> addedModuleDependency = new Function>() { - @Override - public UserProjectChange fun(String s) { - return new AddModuleDependencyUserChange(moduleName, s); - } - }; - Function> removedModuleDependency = new Function>() { - @Override - public UserProjectChange fun(String s) { - return new RemoveModuleDependencyUserChange(moduleName, s); - } - }; - Function> addedLibraryDependency = new Function>() { - @Override - public UserProjectChange fun(String s) { - return new AddLibraryDependencyUserChange(moduleName, s); - } - }; - Function> removedLibraryDependency = new Function>() { - @Override - public UserProjectChange fun(String s) { - return new RemoveLibraryDependencyUserChange(moduleName, s); - } - }; - - buildPresenceChanges(oldModuleDependencies.keySet(), currentModuleDependencies.keySet(), - addedModuleDependency, removedModuleDependency, context); - buildPresenceChanges(oldLibraryDependencies.keySet(), currentLibraryDependencies.keySet(), - addedLibraryDependency, removedLibraryDependency, context); - - NullableFunction, UserProjectChange> exportedModuleDependencyBuilder - = new NullableFunction, UserProjectChange>() { - @Nullable - @Override - public UserProjectChange fun(Pair pair) { - if (pair.first.isExported() != pair.second.isExported()) { - return new ModuleDependencyExportedChange(moduleName, pair.second.getName(), pair.second.isExported()); - } - return null; - } - }; - NullableFunction, UserProjectChange> scopeModuleDependencyBuilder - = new NullableFunction, UserProjectChange>() { - @Nullable - @Override - public UserProjectChange fun(Pair pair) { - if (pair.first.getScope() != pair.second.getScope()) { - return new ModuleDependencyScopeUserChange(moduleName, pair.second.getName(), pair.second.getScope()); - } - return null; - } - }; - NullableFunction, UserProjectChange> exportedLibDependencyBuilder - = new NullableFunction, UserProjectChange>() { - @Nullable - @Override - public UserProjectChange fun(Pair pair) { - if (pair.first.isExported() != pair.second.isExported()) { - return new LibraryDependencyExportedChange(moduleName, pair.second.getName(), pair.second.isExported()); - } - return null; - } - }; - NullableFunction, UserProjectChange> scopeLibDependencyBuilder - = new NullableFunction, UserProjectChange>() { - @Nullable - @Override - public UserProjectChange fun(Pair pair) { - if (pair.first.getScope() != pair.second.getScope()) { - return new LibraryDependencyScopeUserChange(moduleName, pair.second.getName(), pair.second.getScope()); - } - return null; - } - }; - - buildSettingsChanges(oldModuleDependencies, currentModuleDependencies, exportedModuleDependencyBuilder, context); - buildSettingsChanges(oldModuleDependencies, currentModuleDependencies, scopeModuleDependencyBuilder, context); - buildSettingsChanges(oldLibraryDependencies, currentLibraryDependencies, exportedLibDependencyBuilder, context); - buildSettingsChanges(oldLibraryDependencies, currentLibraryDependencies, scopeLibDependencyBuilder, context); - } - } - - private static void buildPresenceChanges(@NotNull Set oldData, - @NotNull Set currentData, - @NotNull Function> addChangeBuilder, - @NotNull Function> removeChangeBuilder, - @NotNull Context context) - { - Set removed = ContainerUtilRt.newHashSet(oldData); - removed.removeAll(currentData); - if (!removed.isEmpty()) { - for (final T r : removed) { - context.currentChanges.add(removeChangeBuilder.fun(r)); - } - } - - Set added = ContainerUtilRt.newHashSet(currentData); - added.removeAll(oldData); - if (!added.isEmpty()) { - for (final T a : added) { - context.currentChanges.add(addChangeBuilder.fun(a)); - } - } - } - - private static void buildSettingsChanges(@NotNull Map oldData, - @NotNull Map currentData, - @NotNull NullableFunction, UserProjectChange> builder, - @NotNull Context context) - { - Set keys = ContainerUtilRt.newHashSet(oldData.keySet()); - keys.retainAll(currentData.keySet()); - for (String key : keys) { - UserProjectChange change = builder.fun(Pair.create(oldData.get(key), currentData.get(key))); - if (change != null) { - context.currentChanges.add(change); - } - } - } - - @Nullable - private ProjectData buildCurrentIdeProject(@NotNull Project project) { - String compileOutput = null; - CompilerProjectExtension compilerProjectExtension = CompilerProjectExtension.getInstance(project); - if (compilerProjectExtension != null) { - compileOutput = compilerProjectExtension.getCompilerOutputUrl(); - } - if (compileOutput == null) { - compileOutput = ""; - } - - return null; - - // TODO den implement -// ProjectData result = new ProjectData(ProjectSystemId.IDE, ".", compileOutput); -// final Map modules = ContainerUtilRt.newHashMap(); -// for (Module ideModule : myFacade.getModules(project)) { -// final ModuleData module = new ModuleData(ProjectSystemId.IDE, ideModule.getName(), ideModule.getModuleFilePath()); -// modules.put(module.getName(), module); -// } -// for (Module ideModule : myFacade.getModules(project)) { -// final ModuleData module = modules.get(ideModule.getName()); -// RootPolicy visitor = new RootPolicy() { -// @Override -// public Void visitLibraryOrderEntry(LibraryOrderEntry libraryOrderEntry, Void value) { -// Library library = libraryOrderEntry.getLibrary(); -// if (library != null) { -// LibraryDependencyData dependency = new LibraryDependencyData( -// module, -// new LibraryData(ProjectSystemId.IDE, ExternalSystemUtil.getLibraryName(library)) -// ); -// dependency.setScope(libraryOrderEntry.getScope()); -// dependency.setExported(libraryOrderEntry.isExported()); -// module.addDependency(dependency); -// } -// return value; -// } -// -// @Override -// public Void visitModuleOrderEntry(ModuleOrderEntry moduleOrderEntry, Void value) { -// ModuleData dependencyModule = modules.get(moduleOrderEntry.getModuleName()); -// if (dependencyModule != null) { -// ModuleDependencyData dependency = new ModuleDependencyData(module, dependencyModule); -// dependency.setScope(moduleOrderEntry.getScope()); -// dependency.setExported(moduleOrderEntry.isExported()); -// module.addDependency(dependency); -// } -// return value; -// } -// }; -// for (OrderEntry orderEntry : myFacade.getOrderEntries(ideModule)) { -// orderEntry.accept(visitor, null); -// } -// result.addModule(module); -// } -// -// return result; - } - - /** - * This method allows to answer if given change is up to date. - * - * @param change change to check - * @param project target ide project - * @return true if given change is up to date; false otherwise - * @see #filterOutdatedChanges(Project) - */ - private boolean isUpToDate(@NotNull UserProjectChange change, @NotNull final Project project) { - final Ref result = new Ref(); - change.invite(new UserProjectChangeVisitor() { - @Override - public void visit(@NotNull AddModuleUserChange change) { - String moduleName = change.getModuleName(); - assert moduleName != null; - result.set(myProjectStructureHelper.findIdeModule(moduleName, project) != null); - } - - @Override - public void visit(@NotNull RemoveModuleUserChange change) { - String moduleName = change.getModuleName(); - assert moduleName != null; - result.set(myProjectStructureHelper.findIdeModule(moduleName, project) == null); - } - - @Override - public void visit(@NotNull AddModuleDependencyUserChange change) { - String moduleName = change.getModuleName(); - assert moduleName != null; - String dependencyName = change.getDependencyName(); - assert dependencyName != null; - result.set(myProjectStructureHelper.findIdeModuleDependency(moduleName, dependencyName, project) != null); - } - - @Override - public void visit(@NotNull RemoveModuleDependencyUserChange change) { - String moduleName = change.getModuleName(); - assert moduleName != null; - String dependencyName = change.getDependencyName(); - assert dependencyName != null; - result.set(myProjectStructureHelper.findIdeModuleDependency(moduleName, dependencyName, project) == null); - } - - @Override - public void visit(@NotNull AddLibraryDependencyUserChange change) { - String moduleName = change.getModuleName(); - assert moduleName != null; - String dependencyName = change.getDependencyName(); - assert dependencyName != null; - result.set(myProjectStructureHelper.findIdeLibraryDependency(moduleName, dependencyName, project) != null); - } - - @Override - public void visit(@NotNull RemoveLibraryDependencyUserChange change) { - String moduleName = change.getModuleName(); - assert moduleName != null; - String dependencyName = change.getDependencyName(); - assert dependencyName != null; - result.set(myProjectStructureHelper.findIdeLibraryDependency(moduleName, dependencyName, project) == null); - } - - @Override - public void visit(@NotNull LibraryDependencyScopeUserChange change) { - String moduleName = change.getModuleName(); - assert moduleName != null; - String dependencyName = change.getDependencyName(); - assert dependencyName != null; - ExportableOrderEntry dependency = myProjectStructureHelper.findIdeLibraryDependency(moduleName, dependencyName, project); - result.set(dependency != null && dependency.getScope() == change.getScope()); - } - - @Override - public void visit(@NotNull ModuleDependencyScopeUserChange change) { - String moduleName = change.getModuleName(); - assert moduleName != null; - String dependencyName = change.getDependencyName(); - assert dependencyName != null; - ExportableOrderEntry dependency = myProjectStructureHelper.findIdeModuleDependency(moduleName, dependencyName, project); - result.set(dependency != null && dependency.getScope() == change.getScope()); - } - - @Override - public void visit(@NotNull LibraryDependencyExportedChange change) { - String moduleName = change.getModuleName(); - assert moduleName != null; - String dependencyName = change.getDependencyName(); - assert dependencyName != null; - ExportableOrderEntry dependency = myProjectStructureHelper.findIdeLibraryDependency(moduleName, dependencyName, project); - result.set(dependency != null && dependency.isExported() == change.isExported()); - } - - @Override - public void visit(@NotNull ModuleDependencyExportedChange change) { - String moduleName = change.getModuleName(); - assert moduleName != null; - String dependencyName = change.getDependencyName(); - assert dependencyName != null; - ExportableOrderEntry dependency = myProjectStructureHelper.findIdeModuleDependency(moduleName, dependencyName, project); - result.set(dependency != null && dependency.isExported() == change.isExported()); - } - }); - return result.get(); - } - - private static class Context { - - @NotNull public final Set> currentChanges = ContainerUtilRt.newHashSet(); - - @NotNull public final Map oldModules; - @NotNull public final Map currentModules; - - Context(@NotNull ProjectData oldProjectState, - @NotNull ProjectData currentProjectState) - { - Function> modulesByName - = new Function>() { - @Override - public Pair fun(ModuleData module) { - return Pair.create(module.getName(), module); - } - }; - - // TODO den remove - oldModules = ContainerUtil.newHashMap(); - currentModules = ContainerUtil.newHashMap(); - // TODO den uncomment -// oldModules = ContainerUtil.map2Map(oldProjectState.getModules(), modulesByName); -// currentModules = ContainerUtil.map2Map(currentProjectState.getModules(), modulesByName); - } - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/EntityManageHelper.java b/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/EntityManageHelper.java deleted file mode 100644 index 38fab6f6c188..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/EntityManageHelper.java +++ /dev/null @@ -1,479 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.service.project.manage; - -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.*; -import com.intellij.openapi.externalSystem.model.project.change.*; -import com.intellij.openapi.externalSystem.model.project.change.user.*; -import com.intellij.openapi.externalSystem.model.project.id.*; -import com.intellij.openapi.externalSystem.service.project.ModuleAwareContentRoot; -import com.intellij.openapi.externalSystem.service.project.ProjectStructureHelper; -import com.intellij.openapi.externalSystem.util.IdeEntityVisitor; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.ExportableOrderEntry; -import com.intellij.openapi.roots.LibraryOrderEntry; -import com.intellij.openapi.roots.ModuleOrderEntry; -import com.intellij.openapi.roots.libraries.Library; -import com.intellij.util.containers.ContainerUtilRt; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * @author Denis Zhdanov - * @since 2/20/13 3:14 PM - */ -public class EntityManageHelper { - - @NotNull private final ProjectStructureHelper myProjectStructureHelper; - @NotNull private final ProjectDataServiceImpl myProjectManager; - @NotNull private final ModuleDataService myModuleManager; - @NotNull private final LibraryDataService myLibraryManager; - @NotNull private final JarDataService myJarManager; - @NotNull private final LibraryDependencyDataService myLibraryDependencyManager; - @NotNull private final ModuleDependencyDataService myModuleDependencyManager; - @NotNull private final ContentRootDataService myContentRootManager; - - public EntityManageHelper(@NotNull ProjectStructureHelper helper, - @NotNull ProjectDataServiceImpl projectManager, - @NotNull ModuleDataService moduleManager, - @NotNull LibraryDataService libraryManager, - @NotNull JarDataService jarManager, - @NotNull LibraryDependencyDataService libraryDependencyManager, - @NotNull ModuleDependencyDataService moduleDependencyManager, - @NotNull ContentRootDataService contentRootManager) - { - myProjectStructureHelper = helper; - myProjectManager = projectManager; - myModuleManager = moduleManager; - myLibraryManager = libraryManager; - myJarManager = jarManager; - myLibraryDependencyManager = libraryDependencyManager; - myModuleDependencyManager = moduleDependencyManager; - myContentRootManager = contentRootManager; - } - - public void importEntities(@NotNull Project project, @NotNull Collection entities, boolean synchronous) { - final Set modules = ContainerUtilRt.newHashSet(); - final Map> contentRoots = ContainerUtilRt.newHashMap(); - final Set libraries = ContainerUtilRt.newHashSet(); - final Set jars = ContainerUtilRt.newHashSet(); - final Map> dependencies = ContainerUtilRt.newHashMap(); - // TODO den implement -// ExternalEntityVisitor visitor = new ExternalEntityVisitor() { -// @Override -// public void visit(@NotNull ProjectData project) { } -// -// @Override -// public void visit(@NotNull ModuleData module) { modules.add(module); } -// -// @Override -// public void visit(@NotNull LibraryData library) { libraries.add(library); } -// -// @Override -// public void visit(@NotNull JarData jar) { jars.add(jar); } -// -// @Override -// public void visit(@NotNull ModuleDependencyData dependency) { addDependency(dependency); } -// -// @Override -// public void visit(@NotNull LibraryDependencyData dependency) { addDependency(dependency); } -// -// @Override -// public void visit(@NotNull CompositeLibraryDependencyData dependency) { } -// -// @Override -// public void visit(@NotNull ContentRootData contentRoot) { -// Collection roots = contentRoots.get(contentRoot.getOwnerModule()); -// if (roots == null) { -// contentRoots.put(contentRoot.getOwnerModule(), roots = ContainerUtilRt.newHashSet()); -// } -// roots.add(contentRoot); -// } -// -// private void addDependency(@NotNull DependencyData dependency) { -// Collection d = dependencies.get(dependency.getOwnerModule()); -// if (d == null) { -// dependencies.put(dependency.getOwnerModule(), d = ContainerUtilRt.newHashSet()); -// } -// d.add(dependency); -// } -// }; - - // Sort entities. - // TODO den implement -// for (ProjectEntityData entity : entities) { -// entity.invite(visitor); -// } -// myModuleManager.importData(modules, project, false, synchronous); -// for (Map.Entry> entry : contentRoots.entrySet()) { -// Module module = myProjectStructureHelper.findIdeModule(entry.getKey(), project); -// if (module != null) { -// myContentRootManager.importContentRoots(entry.getValue(), module, synchronous); -// } -// } -// myLibraryManager.importLibraries(libraries, project, synchronous); -// myJarManager.importJars(jars, project, synchronous); -// for (Map.Entry> entry : dependencies.entrySet()) { -// Module module = myProjectStructureHelper.findIdeModule(entry.getKey(), project); -// if (module != null) { -// myLibraryDependencyManager.importDependencies(entry.getValue(), module, synchronous); -// } -// } - } - - public void removeEntities(@NotNull Project project, @NotNull Collection entities, boolean synchronous) { - final List modules = ContainerUtilRt.newArrayList(); - final List contentRoots = ContainerUtilRt.newArrayList(); - final List dependencies = ContainerUtilRt.newArrayList(); - final List jars = ContainerUtilRt.newArrayList(); - IdeEntityVisitor ideVisitor = new IdeEntityVisitor() { - @Override public void visit(@NotNull Project project) { } - @Override public void visit(@NotNull Module module) { modules.add(module); } - @Override public void visit(@NotNull ModuleAwareContentRoot contentRoot) { contentRoots.add(contentRoot); } - @Override public void visit(@NotNull LibraryOrderEntry libraryDependency) { dependencies.add(libraryDependency); } - @Override public void visit(@NotNull ModuleOrderEntry moduleDependency) { dependencies.add(moduleDependency); } - @Override public void visit(@NotNull Library library) { } - }; - // TODO den implement -// ExternalEntityVisitor gradleVisitor = new ExternalEntityVisitorAdapter() { -// @Override -// public void visit(@NotNull JarData jar) { -// jars.add(jar); -// } -// }; -// for (Object entity : entities) { -// ExternalSystemUtil.dispatch(entity, gradleVisitor, ideVisitor); -// } -// -// myJarManager.removeJars(jars, project, synchronous); -// myContentRootManager.removeContentRoots(contentRoots, synchronous); -// myLibraryDependencyManager.removeDependencies(dependencies, synchronous); -// myModuleManager.removeData(modules, synchronous); - } - - /** - * Tries to eliminate all target changes (namely, all given except those which correspond 'changes to preserve') - * - * @param changesToEliminate changes to eliminate - * @param changesToPreserve changes to preserve - * @param synchronous defines if the processing should be synchronous - * @return non-processed changes - */ - public Set eliminateChange(@NotNull Project project, - @NotNull Collection changesToEliminate, - @NotNull final Set> changesToPreserve, - boolean synchronous) - { - return null; - // TODO den implement -// EliminateChangesContext context = new EliminateChangesContext( -// project, myProjectStructureHelper, changesToPreserve, myProjectManager, myLibraryDependencyManager, synchronous -// ); -// for (ExternalProjectStructureChange change : changesToEliminate) { -// change.invite(context.visitor); -// } -// -// removeEntities(project, context.entitiesToRemove, synchronous); -// importEntities(project, context.entitiesToImport, synchronous); -// return context.nonProcessedChanges; - } - - private static void processProjectRenameChange(@NotNull GradleProjectRenameChange change, @NotNull EliminateChangesContext context) { - context.projectManager.renameProject(change.getExternalValue(), context.project, context.synchronous); - } - - // Don't auto-apply language level change because we can't correctly process language level change manually made - // by a user - there is crazy processing related to project reloading after language level change and there is just - // no normal way to inject there. - -// private static void processLanguageLevelChange(@NotNull GradleLanguageLevelChange change, @NotNull EliminateChangesContext context) { -// context.projectManager.setLanguageLevel(change.getGradleValue(), context.projectStructureHelper.getProject(), context.synchronous); -// } - - private static void processModulePresenceChange(@NotNull ModulePresenceChange change, @NotNull EliminateChangesContext context) { - ModuleId id = change.getExternalEntity(); - if (id == null) { - // IDE-local change. - id = change.getIdeEntity(); - assert id != null; - Module module = context.projectStructureHelper.findIdeModule(id.getModuleName(), context.project); - if (module != null && !context.changesToPreserve.contains(new AddModuleUserChange(id.getModuleName()))) { - context.entitiesToRemove.add(module); - return; - } - } - else { - // TODO den implement -// ModuleData module = context.projectStructureHelper.findExternalModule(id.getModuleName(), id.getOwner(), context.project); -// if (module != null && !context.changesToPreserve.contains(new RemoveModuleUserChange(id.getModuleName()))) { -// context.entitiesToImport.add(module); -// return; -// } - } - context.nonProcessedChanges.add(change); - } - - private static void processContentRootPresenceChange(@NotNull ContentRootPresenceChange change, - @NotNull EliminateChangesContext context) - { - ContentRootId id = change.getExternalEntity(); - if (id == null) { - // IDE-local change. - id = change.getIdeEntity(); - assert id != null; - ModuleAwareContentRoot root = context.projectStructureHelper.findIdeContentRoot(id, context.project); - if (root != null) { - context.entitiesToRemove.add(root); - return; - } - } - else { - // TODO den implement -// ContentRootData root = context.projectStructureHelper.findExternalContentRoot(id, id.getOwner(), context.project); -// if (root != null) { -// context.entitiesToImport.add(root); -// return; -// } - } - context.nonProcessedChanges.add(change); - } - - private static void processLibraryDependencyPresenceChange(@NotNull LibraryDependencyPresenceChange change, - @NotNull EliminateChangesContext context) - { - LibraryDependencyId id = change.getExternalEntity(); - if (id == null) { - // IDE-local change. - id = change.getIdeEntity(); - assert id != null; - LibraryOrderEntry dependency = context.projectStructureHelper.findIdeLibraryDependency(id, context.project); - AddLibraryDependencyUserChange c = new AddLibraryDependencyUserChange(id.getOwnerModuleName(), id.getDependencyName()); - if (dependency != null && !context.changesToPreserve.contains(c)) { - context.entitiesToRemove.add(dependency); - return; - } - } - else { - ProjectSystemId owner = id.getOwner(); - // TODO den implement -// LibraryDependencyData dependency = context.projectStructureHelper.findExternalLibraryDependency(id, owner, context.project); -// RemoveLibraryDependencyUserChange c = new RemoveLibraryDependencyUserChange(id.getOwnerModuleName(), id.getDependencyName()); -// if (dependency != null && !context.changesToPreserve.contains(c)) { -// context.entitiesToImport.add(dependency); -// return; -// } - } - context.nonProcessedChanges.add(change); - } - - private static void processJarPresenceChange(@NotNull JarPresenceChange change, @NotNull EliminateChangesContext context) { - JarId id = change.getExternalEntity(); - if (id == null) { - // IDE-local change. - id = change.getIdeEntity(); - assert id != null; - JarData jar = context.projectStructureHelper.findIdeJar(id, context.project); - if (jar != null) { - context.entitiesToRemove.add(jar); - return; - } - } - else { - // TODO den implement -// LibraryData library = context.projectStructureHelper.findExternalLibrary(id.getLibraryId(), id.getOwner(), context.project); -// if (library != null) { -// context.entitiesToImport.add(new JarData(id.getPath(), id.getLibraryPathType(), null, library, id.getOwner())); -// return; -// } - } - context.nonProcessedChanges.add(change); - } - - private static void processModuleDependencyPresenceChange(@NotNull ModuleDependencyPresenceChange change, - @NotNull EliminateChangesContext context) - { - ModuleDependencyId id = change.getExternalEntity(); - if (id == null) { - // IDE-local change. - id = change.getIdeEntity(); - assert id != null; - ModuleOrderEntry dependency = context.projectStructureHelper.findIdeModuleDependency(id, context.project); - AddModuleDependencyUserChange c = new AddModuleDependencyUserChange(id.getOwnerModuleName(), id.getDependencyName()); - if (dependency != null && !context.changesToPreserve.contains(c)) { - context.entitiesToRemove.add(dependency); - return; - } - } - else { - // TODO den implement -// ModuleDependencyData dependency = context.projectStructureHelper.findExternalModuleDependency(id, id.getOwner(), context.project); -// RemoveModuleDependencyUserChange c = new RemoveModuleDependencyUserChange(id.getOwnerModuleName(), id.getDependencyName()); -// if (dependency != null && !context.changesToPreserve.contains(c)) { -// context.entitiesToImport.add(dependency); -// return; -// } - } - context.nonProcessedChanges.add(change); - } - - private static void processDependencyScopeChange(@NotNull DependencyScopeChange change, @NotNull EliminateChangesContext context) { - ExportableOrderEntry dependency = findDependency(change, context); - if (dependency == null) { - return; - } - AbstractExternalDependencyId id = change.getEntityId(); - UserProjectChange userChange; - if (dependency instanceof LibraryOrderEntry) { - userChange = new LibraryDependencyScopeUserChange(id.getOwnerModuleName(), id.getDependencyName(), change.getIdeValue()); - } - else { - userChange = new ModuleDependencyScopeUserChange(id.getOwnerModuleName(), id.getDependencyName(), change.getIdeValue()); - } - if (context.changesToPreserve.contains(userChange)) { - context.nonProcessedChanges.add(change); - } - else { - // TODO den implement -// context.dependencyManager.setScope(change.getExternalValue(), dependency, context.synchronous); - } - } - - private static void processDependencyExportedStatusChange(@NotNull DependencyExportedChange change, - @NotNull EliminateChangesContext context) - { - ExportableOrderEntry dependency = findDependency(change, context); - if (dependency == null) { - return; - } - AbstractExternalDependencyId id = change.getEntityId(); - UserProjectChange userChange; - if (dependency instanceof LibraryOrderEntry) { - userChange = new LibraryDependencyExportedChange(id.getOwnerModuleName(), id.getDependencyName(), change.getIdeValue()); - } - else { - userChange = new ModuleDependencyExportedChange(id.getOwnerModuleName(), id.getDependencyName(), change.getIdeValue()); - } - if (context.changesToPreserve.contains(userChange)) { - context.nonProcessedChanges.add(change); - } - else { - // TODO den implement -// context.dependencyManager.setExported(change.getExternalValue(), dependency, context.synchronous); - } - } - - @Nullable - private static ExportableOrderEntry findDependency(@NotNull AbstractConflictingPropertyChange change, - @NotNull EliminateChangesContext context) - { - ProjectEntityId id = change.getEntityId(); - ExportableOrderEntry dependency = null; - if (id instanceof LibraryDependencyId) { - dependency = context.projectStructureHelper.findIdeLibraryDependency((LibraryDependencyId)id, context.project); - } - else if (id instanceof ModuleDependencyId) { - dependency = context.projectStructureHelper.findIdeModuleDependency((ModuleDependencyId)id, context.project); - } - else { - context.nonProcessedChanges.add(change); - } - return dependency; - } - - private static class EliminateChangesContext { - @NotNull final Set entitiesToRemove = ContainerUtilRt.newHashSet(); - @NotNull final Set entitiesToImport = ContainerUtilRt.newHashSet(); - @NotNull final Set nonProcessedChanges = ContainerUtilRt.newHashSet(); - @NotNull final Set> changesToPreserve = ContainerUtilRt.newHashSet(); - - @NotNull final Project project; - @NotNull final ProjectStructureHelper projectStructureHelper; - @NotNull final ProjectDataServiceImpl projectManager; - - final boolean synchronous; - - @NotNull ExternalProjectStructureChangeVisitor visitor = new ExternalProjectStructureChangeVisitor() { - @Override - public void visit(@NotNull GradleProjectRenameChange change) { - processProjectRenameChange(change, EliminateChangesContext.this); - } - - @Override - public void visit(@NotNull LanguageLevelChange change) { -// processLanguageLevelChange(change, EliminateChangesContext.this); - } - - @Override - public void visit(@NotNull ModulePresenceChange change) { - processModulePresenceChange(change, EliminateChangesContext.this); - } - - @Override - public void visit(@NotNull ContentRootPresenceChange change) { - processContentRootPresenceChange(change, EliminateChangesContext.this); - } - - @Override - public void visit(@NotNull LibraryDependencyPresenceChange change) { - processLibraryDependencyPresenceChange(change, EliminateChangesContext.this); - } - - @Override - public void visit(@NotNull JarPresenceChange change) { - processJarPresenceChange(change, EliminateChangesContext.this); - } - - @Override - public void visit(@NotNull OutdatedLibraryVersionChange change) { - } - - @Override - public void visit(@NotNull ModuleDependencyPresenceChange change) { - processModuleDependencyPresenceChange(change, EliminateChangesContext.this); - } - - @Override - public void visit(@NotNull DependencyScopeChange change) { - processDependencyScopeChange(change, EliminateChangesContext.this); - } - - @Override - public void visit(@NotNull DependencyExportedChange change) { - processDependencyExportedStatusChange(change, EliminateChangesContext.this); - } - }; - - EliminateChangesContext(@NotNull Project project, - @NotNull ProjectStructureHelper projectStructureHelper, - @NotNull Set> changesToPreserve, - @NotNull ProjectDataServiceImpl projectManager, - boolean synchronous) - { - this.project = project; - this.projectStructureHelper = projectStructureHelper; - this.changesToPreserve.addAll(changesToPreserve); - this.projectManager = projectManager; - this.synchronous = synchronous; - } - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/GradleLocalNodeManageHelper.java b/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/GradleLocalNodeManageHelper.java deleted file mode 100644 index 5f4ae5d15a47..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/GradleLocalNodeManageHelper.java +++ /dev/null @@ -1,242 +0,0 @@ -package com.intellij.openapi.externalSystem.service.project.manage; - -import com.intellij.openapi.externalSystem.model.project.*; -import com.intellij.openapi.externalSystem.model.project.id.ContentRootId; -import com.intellij.openapi.externalSystem.model.project.id.EntityIdMapper; -import com.intellij.openapi.externalSystem.model.project.id.ProjectEntityId; -import com.intellij.openapi.externalSystem.settings.ExternalSystemTextAttributes; -import com.intellij.openapi.externalSystem.ui.ProjectStructureNode; -import com.intellij.openapi.externalSystem.ui.ProjectStructureNodeDescriptor; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.LibraryOrderEntry; -import com.intellij.openapi.roots.ModuleOrderEntry; -import com.intellij.openapi.roots.OrderRootType; -import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.util.containers.ContainerUtilRt; -import com.intellij.util.containers.Stack; -import org.jetbrains.annotations.NotNull; -import com.intellij.openapi.externalSystem.model.project.ProjectEntityType; -import com.intellij.openapi.externalSystem.service.project.ModuleAwareContentRoot; -import com.intellij.openapi.externalSystem.service.project.ProjectStructureHelper; - -import java.util.Collection; -import java.util.Set; - -/** - * Gradle integration shows a project structure tree which contain nodes for gradle-local entities (modules, libraries etc). - * End-user can select interested nodes and import them into the current intellij project. - *

- * This class helps during that at the following ways: - *

- * 
    - *
  • filters out non gradle-local nodes;
  • - *
  • - * collects all nodes that should be imported. For example, an user can mark 'module' node to import. We need to import not - * only that module but its (transitive) dependencies as well. I.e. basically the algorithm looks like 'import all entities up - * to the path to root and all sub-entities'; - *
  • - *
  • - * sorts entities to import in topological order. Example: let module1 depend on module2. We need to - * import module2 before module1 then; - *
  • - *
- *
- *

- * Thread-safe. - * - * @author Denis Zhdanov - * @since 2/10/12 11:51 AM - */ -public class GradleLocalNodeManageHelper { - - @NotNull private final ProjectStructureHelper myProjectStructureHelper; - @NotNull private final EntityIdMapper myIdMapper; - @NotNull private final EntityManageHelper myEntityManageHelper; - - public GradleLocalNodeManageHelper(@NotNull ProjectStructureHelper projectStructureHelper, - @NotNull EntityIdMapper idMapper, - @NotNull EntityManageHelper entityManageHelper) - { - myProjectStructureHelper = projectStructureHelper; - myIdMapper = idMapper; - myEntityManageHelper = entityManageHelper; - } - - /** - * {@link #deriveEntitiesToImport(Project, Iterable)} Derives} target entities from the given nodes - * and {@link EntityManageHelper#importEntities(Project, Collection, boolean) imports them}. - * - * @param project target ide project - * @param nodes 'anchor nodes' to import - */ - public void importNodes(@NotNull Project project, @NotNull Iterable> nodes) { - final Collection entities = deriveEntitiesToImport(project, nodes); - myEntityManageHelper.importEntities(project, entities, true); - } - - /** - * Collects all nodes that should be imported based on the given nodes and returns corresponding gradle entities - * sorted in topological order. - * - * @param nodes 'anchor nodes' to import - * @return collection of gradle entities that should be imported based on the given nodes - */ - @NotNull - public Collection deriveEntitiesToImport(@NotNull Project project, @NotNull Iterable> nodes) { - Context context = new Context(project); - for (ProjectStructureNode node : nodes) { - collectEntitiesToImport(node, context); - } - return context.entities; - } - - private void collectEntitiesToImport(@NotNull ProjectStructureNode node, @NotNull Context context) { - // Collect up. - for (ProjectStructureNode n = node.getParent(); n != null; n = n.getParent()) { - final ProjectStructureNodeDescriptor descriptor = n.getDescriptor(); - if (n.getDescriptor().getElement().getType() == ProjectEntityType.SYNTHETIC) { - continue; - } - if (descriptor.getAttributes() != ExternalSystemTextAttributes.EXTERNAL_SYSTEM_LOCAL_CHANGE) { - break; - } - Object id = descriptor.getElement(); - final Object entity = myIdMapper.mapIdToEntity((ProjectEntityId)id, context.project); - if (entity instanceof ProjectEntityData) { - // TODO den implement -// ((ProjectEntityData)entity).invite(context.visitor); - } - } - - // Collect down. - final Stack toProcess = new Stack(); - final Object id = node.getDescriptor().getElement(); - final Object entity = myIdMapper.mapIdToEntity((ProjectEntityId)id, context.project); - if (entity instanceof ProjectEntityData) { - toProcess.push((ProjectEntityData)entity); - } - - context.recursive = true; - while (!toProcess.isEmpty()) { - final ProjectEntityData e = toProcess.pop(); - // TODO den implement -// e.invite(context.visitor); - } - } - - private void collectModuleEntities(@NotNull ModuleData module, @NotNull Context context) { - final Module intellijModule = myProjectStructureHelper.findIdeModule(module.getName(), context.project); - if (intellijModule != null) { - // Already imported - return; - } - context.entities.add(module); - if (!context.recursive) { - return; - } - // TODO den implement -// for (ContentRootData contentRoot : module.getContentRoots()) { -// contentRoot.invite(context.visitor); -// } -// for (DependencyData dependency : module.getDependencies()) { -// dependency.invite(context.visitor); -// } - } - - private void collectContentRoots(@NotNull ContentRootData contentRoot, @NotNull Context context) { - final ContentRootId id = EntityIdMapper.mapEntityToId(contentRoot); - final ModuleAwareContentRoot intellijContentRoot = myProjectStructureHelper.findIdeContentRoot(id, context.project); - if (intellijContentRoot != null) { - // Already imported. - return; - } - context.entities.add(contentRoot); - } - - private void collectModuleDependencyEntities(@NotNull ModuleDependencyData dependency, @NotNull Context context) { - final ModuleOrderEntry intellijModuleDependency = myProjectStructureHelper.findIdeModuleDependency(dependency, context.project); - if (intellijModuleDependency != null) { - // Already imported. - return; - } - context.entities.add(dependency); - final ModuleData gradleModule = dependency.getTarget(); - final Module intellijModule = myProjectStructureHelper.findIdeModule(gradleModule, context.project); - if (intellijModule != null) { - return; - } - boolean r = context.recursive; - context.recursive = true; - try { - // TODO den implement -// gradleModule.invite(context.visitor); - } - finally { - context.recursive = r; - } - } - - private void collectLibraryDependencyEntities(@NotNull LibraryDependencyData dependency, @NotNull Context context) { - final LibraryOrderEntry intellijDependency - = myProjectStructureHelper.findIdeLibraryDependency(dependency.getOwnerModule().getName(), dependency.getName(), context.project); - Set intellijPaths = ContainerUtilRt.newHashSet(); - LibraryData gradleLibrary = dependency.getTarget(); - Library intellijLibrary = null; - if (intellijDependency == null) { - context.entities.add(dependency); - } - else { - intellijLibrary = intellijDependency.getLibrary(); - } - - if (intellijLibrary == null) { - intellijLibrary = myProjectStructureHelper.findIdeLibrary(gradleLibrary, context.project); - } - - if (intellijLibrary == null) { - context.entities.add(gradleLibrary); - } - else { - for (VirtualFile jarFile : intellijLibrary.getFiles(OrderRootType.CLASSES)) { - intellijPaths.add(ExternalSystemUtil.getLocalFileSystemPath(jarFile)); - } - } - - for (String gradleJarPath : gradleLibrary.getPaths(LibraryPathType.BINARY)) { - if (!intellijPaths.contains(gradleJarPath)) { - context.entities.add(new JarData(gradleJarPath, LibraryPathType.BINARY, null, gradleLibrary, dependency.getOwner())); - } - } - } - - public void removeNodes(@NotNull Project project, @NotNull Collection> nodes) { - Collection entities = ContainerUtilRt.newArrayList(); - for (ProjectStructureNode node : nodes) { - ProjectStructureNodeDescriptor descriptor = node.getDescriptor(); - if (descriptor.getAttributes() != ExternalSystemTextAttributes.IDE_LOCAL_CHANGE) { - continue; - } - Object entity = myIdMapper.mapIdToEntity(descriptor.getElement(), project); - if (entity != null) { - entities.add(entity); - } - } - myEntityManageHelper.removeEntities(project, entities, true); - } - - private class Context { - - @NotNull public final Set entities = ContainerUtilRt.newHashSet(); - - @NotNull public final Project project; - - public boolean recursive; - - Context(@NotNull Project project) { - this.project = project; - } - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/JarDataService.java b/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/JarDataService.java deleted file mode 100644 index dc9d261fd0de..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/JarDataService.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Copyright 2000-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.service.project.manage; - -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.externalSystem.model.DataNode; -import com.intellij.openapi.externalSystem.model.Key; -import com.intellij.openapi.externalSystem.model.ProjectKeys; -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.JarData; -import com.intellij.openapi.externalSystem.model.project.LibraryData; -import com.intellij.openapi.externalSystem.service.project.ExternalLibraryPathTypeMapper; -import com.intellij.openapi.externalSystem.service.project.ProjectStructureHelper; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.OrderRootType; -import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.roots.libraries.LibraryTable; -import com.intellij.openapi.vfs.JarFileSystem; -import com.intellij.openapi.vfs.LocalFileSystem; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.util.Function; -import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.containers.ContainerUtilRt; -import org.jetbrains.annotations.NotNull; -import com.intellij.openapi.externalSystem.service.project.PlatformFacade; -import com.intellij.openapi.externalSystem.model.project.LibraryPathType; -import com.intellij.openapi.externalSystem.model.project.id.LibraryId; - -import java.io.File; -import java.util.*; - -/** - * @author Denis Zhdanov - * @since 12/13/12 1:04 PM - */ -public class JarDataService implements ProjectDataService { - - private static final Logger LOG = Logger.getInstance("#" + JarDataService.class.getName()); - - @NotNull private final PlatformFacade myPlatformFacade; - @NotNull private final ProjectStructureHelper myProjectStructureHelper; - @NotNull private final ExternalLibraryPathTypeMapper myLibraryPathTypeMapper; - - public JarDataService(@NotNull PlatformFacade facade, - @NotNull ProjectStructureHelper helper, - @NotNull ExternalLibraryPathTypeMapper mapper) - { - myPlatformFacade = facade; - myProjectStructureHelper = helper; - myLibraryPathTypeMapper = mapper; - } - - @NotNull - @Override - public Key getTargetDataKey() { - return ProjectKeys.JAR; - } - - @Override - public void importData(@NotNull Collection> toImport, @NotNull Project project, boolean synchronous) { - if (toImport.isEmpty()) { - return; - } - - Map, Collection>> byLibrary = ExternalSystemUtil.groupBy(toImport, ProjectKeys.LIBRARY); - for (Map.Entry, Collection>> entry : byLibrary.entrySet()) { - Library library = myProjectStructureHelper.findIdeLibrary(entry.getKey().getData(), project); - if (library == null) { - LOG.warn(String.format( - "Can't import jars %s. Reason: target library (%s) is not configured at the ide and can't be imported", - entry.getValue(), entry.getKey().getData().getName() - )); - return; - } - importJars(entry.getValue(), library, entry.getKey().getData().getOwner(), project, synchronous); - } - } - - public void importJars(@NotNull final Collection> jars, - @NotNull final Library library, - @NotNull ProjectSystemId externalSystemId, - @NotNull final Project project, - boolean synchronous) - { - if (jars.isEmpty()) { - return; - } - - ExternalSystemUtil.executeProjectChangeAction(project, externalSystemId, jars, synchronous, new Runnable() { - @Override - public void run() { - LibraryTable table = myPlatformFacade.getProjectLibraryTable(project); - String libraryName = library.getName(); - if (libraryName == null) { - LOG.warn(String.format("Can't import jars %s. Reason: target library doesn't have a name", jars)); - return; - } - Library libraryToUse = table.getLibraryByName(libraryName); - if (libraryToUse == null) { - LOG.warn(String.format("Can't import jars %s. Reason: target library (%s) doesn't exist", jars, libraryName)); - return; - } - Library.ModifiableModel model = library.getModifiableModel(); - try { - LocalFileSystem fileSystem = LocalFileSystem.getInstance(); - for (DataNode jarNode : jars) { - JarData jarData = jarNode.getData(); - OrderRootType ideJarType = myLibraryPathTypeMapper.map(jarData.getPathType()); - for (VirtualFile file : model.getFiles(ideJarType)) { - if (jarData.getPath().equals(ExternalSystemUtil.getLocalFileSystemPath(file))) { - return; - } - } - - File jarFile = new File(jarData.getPath()); - VirtualFile virtualFile = fileSystem.refreshAndFindFileByIoFile(jarFile); - if (virtualFile == null) { - LOG.warn(String.format( - "Can't find a jar of the library '%s' at path '%s'", - jarData.getLibraryId().getLibraryName(), jarData.getPath() - )); - return; - } - if (virtualFile.isDirectory()) { - model.addRoot(virtualFile, ideJarType); - } - else { - VirtualFile jarRoot = JarFileSystem.getInstance().getJarRootForLocalFile(virtualFile); - if (jarRoot == null) { - LOG.warn(String.format( - "Can't parse contents of the jar file at path '%s' for the library '%s''", - jarData.getPath(), libraryName - )); - return; - } - model.addRoot(jarRoot, ideJarType); - } - } - } - finally { - model.commit(); - } - } - }); - } - - @Override - public void removeData(@NotNull Collection> toRemove, @NotNull Project project, boolean synchronous) { - if (toRemove.isEmpty()) { - return; - } - Map>> jarsByLibraries = ContainerUtilRt.newHashMap(); - for (DataNode jarNode : toRemove) { - LibraryId libraryId = jarNode.getData().getLibraryId(); - List> list = jarsByLibraries.get(libraryId); - if (list == null) { - jarsByLibraries.put(libraryId, list = ContainerUtilRt.newArrayList()); - } - list.add(jarNode); - } - - LibraryTable libraryTable = myPlatformFacade.getProjectLibraryTable(project); - for (Map.Entry>> entry : jarsByLibraries.entrySet()) { - Library library = libraryTable.getLibraryByName(entry.getKey().getLibraryName()); - if (library == null) { - continue; - } - Set> libraryJars = ContainerUtilRt.newHashSet(entry.getValue()); - for (DataNode jarNode : entry.getValue()) { - boolean valid = false; - JarData jarData = jarNode.getData(); - for (VirtualFile file : library.getFiles(myLibraryPathTypeMapper.map(jarData.getPathType()))) { - if (jarData.getPath().equals(ExternalSystemUtil.getLocalFileSystemPath(file))) { - valid = true; - break; - } - } - if (!valid) { - libraryJars.remove(jarNode); - } - } - - if (!libraryJars.isEmpty()) { - removeLibraryJars(libraryJars, entry.getKey(), project, synchronous); - } - } - } - - /** - * Removes given jars from IDE project structure assuming that they belong to the same library. - * - * @param toRemove jars to remove - * @param project current project - */ - private void removeLibraryJars(@NotNull final Set> toRemove, - @NotNull final LibraryId libraryId, - @NotNull final Project project, - boolean synchronous) - { - ExternalSystemUtil.executeProjectChangeAction(project, ProjectSystemId.IDE, toRemove, synchronous, new Runnable() { - @Override - public void run() { - LibraryTable libraryTable = myPlatformFacade.getProjectLibraryTable(project); - Library library = libraryTable.getLibraryByName(libraryId.getLibraryName()); - if (library == null) { - return; - } - Set pathsToRemove = ContainerUtil.map2Set(toRemove, new Function, String>() { - @Override - public String fun(DataNode node) { - return node.getData().getPath(); - } - }); - Library.ModifiableModel model = library.getModifiableModel(); - try { - for (LibraryPathType gradlePathType : LibraryPathType.values()) { - OrderRootType idePathType = myLibraryPathTypeMapper.map(gradlePathType); - for (VirtualFile file : model.getFiles(idePathType)) { - if (pathsToRemove.contains(ExternalSystemUtil.getLocalFileSystemPath(file))) { - model.removeRoot(file.getUrl(), idePathType); - } - } - } - } - finally { - model.commit(); - } - } - }); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/OutdatedLibraryService.java b/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/OutdatedLibraryService.java deleted file mode 100644 index 297dbfe3834e..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/manage/OutdatedLibraryService.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.service.project.manage; - -import com.intellij.openapi.externalSystem.model.DataNode; -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.CompositeLibraryDependencyData; -import com.intellij.openapi.externalSystem.model.project.LibraryData; -import com.intellij.openapi.externalSystem.model.project.LibraryDependencyData; -import com.intellij.openapi.externalSystem.model.project.ModuleData; -import com.intellij.openapi.externalSystem.service.project.ProjectStructureServices; -import com.intellij.openapi.externalSystem.ui.ProjectStructureNode; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.LibraryOrderEntry; -import com.intellij.openapi.roots.OrderEntry; -import com.intellij.openapi.roots.RootPolicy; -import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.util.Pair; -import com.intellij.util.containers.ContainerUtilRt; -import org.jetbrains.annotations.NotNull; -import com.intellij.openapi.externalSystem.service.project.PlatformFacade; -import com.intellij.openapi.externalSystem.service.project.ProjectStructureHelper; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * @author Denis Zhdanov - * @since 1/23/13 11:35 AM - */ -public class OutdatedLibraryService { - - @NotNull private final LibraryDataService myLibraryManager; - @NotNull private final LibraryDependencyDataService myLibraryDependencyManager; - @NotNull private final ProjectStructureServices myContext; - @NotNull private final Project myProject; - - public OutdatedLibraryService(@NotNull LibraryDataService libraryManager, - @NotNull LibraryDependencyDataService libraryDependencyManager, - @NotNull ProjectStructureServices context, - @NotNull Project project) - { - myLibraryManager = libraryManager; - myLibraryDependencyManager = libraryDependencyManager; - myContext = context; - myProject = project; - } - - public void sync(@NotNull Project project, - @NotNull ProjectSystemId externalSystemId, - @NotNull Collection> nodes) - { - List> libraryDependenciesToImport = ContainerUtilRt.newArrayList(); - Map ideLibsToRemove = ContainerUtilRt.newHashMap(); - Map ide2externalLibs = ContainerUtilRt.newHashMap(); - Collection ideLibraryDependenciesToRemove = ContainerUtilRt.newArrayList(); - ProjectStructureHelper projectStructureHelper = myContext.getProjectStructureHelper(); - PlatformFacade facade = myContext.getPlatformFacade(); - - // The general idea is to remove all ide-local entities references by the 'outdated libraries' and import - // all corresponding external-local entities. - - //region Parse information to use for further processing. - for (ProjectStructureNode node : nodes) { - Object entity = node.getDescriptor().getElement().mapToEntity(myContext, project); - if (!(entity instanceof CompositeLibraryDependencyData)) { - continue; - } - CompositeLibraryDependencyData e = (CompositeLibraryDependencyData)entity; - String ideLibraryName = e.getIdeEntity().getLibraryName(); - Library ideLibraryToRemove = null; - if (ideLibraryName != null) { - - ideLibraryToRemove = projectStructureHelper.findIdeLibrary(ideLibraryName, project); - } - - if (ideLibraryToRemove != null) { - // We use map here because Library.hashCode()/equals() contract is not clear. That's why we consider two currently - // configured libraries with the same name to be the same. - ideLibsToRemove.put(ideLibraryName, ideLibraryToRemove); - ide2externalLibs.put(ideLibraryName, e.getExternalEntity().getTarget()); - } - } - //endregion - - //region Do actual sync - RootPolicy visitor = new RootPolicy() { - @Override - public LibraryOrderEntry visitLibraryOrderEntry(LibraryOrderEntry libraryOrderEntry, LibraryOrderEntry value) { - return libraryOrderEntry; - } - }; - for (Module ideModule : facade.getModules(myProject)) { - DataNode externalModule = projectStructureHelper.findExternalModule(ideModule.getName(), externalSystemId, project); - if (externalModule == null) { - continue; - } - - for (OrderEntry entry : facade.getOrderEntries(ideModule)) { - LibraryOrderEntry ideLibraryDependency = entry.accept(visitor, null); - if (ideLibraryDependency == null) { - continue; - } - String libraryName = ideLibraryDependency.getLibraryName(); - if (libraryName == null) { - continue; - } - if (!ideLibsToRemove.containsKey(libraryName)) { - continue; - } - ideLibraryDependenciesToRemove.add(ideLibraryDependency); - // TODO den implement -// LibraryDependencyData externalLibraryDependency = new LibraryDependencyData(externalModule, ide2externalLibs.get(libraryName)); -// externalLibraryDependency.setExported(ideLibraryDependency.isExported()); -// externalLibraryDependency.setScope(ideLibraryDependency.getScope()); -// libraryDependenciesToImport.add(Pair.create(externalLibraryDependency, ideModule)); - } - } - // TODO den implement -// myLibraryDependencyManager.removeData(ideLibraryDependenciesToRemove, true); -// myLibraryManager.removeLibraries(ideLibsToRemove.values(), myProject); -// for (Pair pair : libraryDependenciesToImport) { -// // Assuming that dependency manager is smart enough to import library for a given library dependency if it hasn't been -// // imported yet. -// myLibraryDependencyManager.importData(pair.first, externalSystemId, pair.second, true); -// } - //endregion - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/wizard/AdjustExternalProjectImportSettingsStep.java b/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/wizard/AdjustExternalProjectImportSettingsStep.java deleted file mode 100644 index b749671265d5..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/service/project/wizard/AdjustExternalProjectImportSettingsStep.java +++ /dev/null @@ -1,346 +0,0 @@ -package com.intellij.openapi.externalSystem.service.project.wizard; - -import com.intellij.ide.util.projectWizard.WizardContext; -import com.intellij.openapi.externalSystem.model.DataNode; -import com.intellij.openapi.externalSystem.model.project.*; -import com.intellij.openapi.externalSystem.model.project.id.ProjectEntityId; -import com.intellij.openapi.externalSystem.ui.ProjectStructureNode; -import com.intellij.openapi.options.ConfigurationException; -import com.intellij.openapi.util.Pair; -import com.intellij.ui.components.JBScrollPane; -import com.intellij.ui.treeStructure.Tree; -import com.intellij.util.containers.ContainerUtilRt; -import com.intellij.util.containers.HashMap; -import org.jetbrains.annotations.NotNull; - -import javax.swing.*; -import javax.swing.event.TreeSelectionEvent; -import javax.swing.event.TreeSelectionListener; -import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.DefaultTreeModel; -import javax.swing.tree.MutableTreeNode; -import javax.swing.tree.TreePath; -import java.awt.*; -import java.util.*; -import java.util.List; - -/** - * Is assumed to address the following concerns: - *
- * 
    - *
  • shows target project structure retrieved from gradle (project and modules);
  • - *
  • allow to adjust settings of the project and modules prior to importing;
  • - *
- *
- * - * @author Denis Zhdanov - * @since 8/2/11 12:31 PM - */ -public class AdjustExternalProjectImportSettingsStep extends AbstractImportFromExternalSystemWizardStep { - - private static final String EMPTY_CARD_NAME = "EMPTY"; - - // TODO den uncomment - //private final GradleProjectStructureFactory myFactory = GradleProjectStructureFactory.INSTANCE; - private final JPanel myComponent = new JPanel(new GridLayout(1, 2)); - private final DefaultTreeModel myTreeModel = new DefaultTreeModel(new DefaultMutableTreeNode("unnamed")); - private final Tree myTree = new Tree(myTreeModel); - private final CardLayout mySettingsCardLayout = new CardLayout(); - private final JPanel mySettingsPanel = new JPanel(mySettingsCardLayout); - - // TODO den uncomment - //private final Map> myCards = - // new HashMap>(); - - private boolean myOnValidateAttempt; - - public AdjustExternalProjectImportSettingsStep(WizardContext context) { - super(context); - - // Init. - myTree.setShowsRootHandles(true); - - myTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { - private boolean myIgnore; - - @SuppressWarnings("SuspiciousMethodCalls") - @Override - public void valueChanged(TreeSelectionEvent e) { - if (myIgnore) { - return; - } - - TreePath oldPath = e.getOldLeadSelectionPath(); - if (oldPath == null) { - onNodeChange(); - return; - } - Object oldNode = oldPath.getLastPathComponent(); - if (oldNode == null) { - onNodeChange(); - return; - } - - // TODO den uncomment - //Pair pair = myCards.get(oldNode); - //if (pair == null || pair.second.validate()) { - // onNodeChange(); - // return; - //} - - myIgnore = true; - try { - myTree.getSelectionModel().setSelectionPath(oldPath); - } - finally { - myIgnore = false; - } - } - - @SuppressWarnings("SuspiciousMethodCalls") - private void onNodeChange() { - Object node = myTree.getLastSelectedPathComponent(); - // TODO den uncomment - //Pair pair = myCards.get(node); - //String cardName = EMPTY_CARD_NAME; - //if (pair != null) { - // cardName = pair.first; - // pair.second.refresh(); - //} - //mySettingsCardLayout.show(mySettingsPanel, cardName); - } - }); - - // Setup GUI. - JPanel leftPanel = new JPanel(new GridBagLayout()); - JPanel rightPanel = new JPanel(new GridBagLayout()); - - GridBagConstraints constraints = new GridBagConstraints(); - constraints.weightx = 1; - constraints.anchor = GridBagConstraints.NORTHWEST; - constraints.fill = GridBagConstraints.HORIZONTAL; - constraints.insets = new Insets(5, 5, 5, 5); - constraints.gridwidth = GridBagConstraints.REMAINDER; - // TODO den implement -// leftPanel.add(new JLabel(ExternalSystemBundle.message("gradle.import.label.project.structure")), constraints); - - constraints = new GridBagConstraints(); - constraints.weightx = constraints.weighty = 1; - constraints.fill = GridBagConstraints.BOTH; - constraints.anchor = GridBagConstraints.NORTHWEST; - constraints.gridwidth = GridBagConstraints.REMAINDER; - leftPanel.add(new JBScrollPane(myTree), constraints); - - myComponent.add(leftPanel); - - constraints = new GridBagConstraints(); - constraints.anchor = GridBagConstraints.NORTHWEST; - constraints.fill = GridBagConstraints.HORIZONTAL; - constraints.insets = new Insets(5, 10, 5, 5); - constraints.gridwidth = GridBagConstraints.REMAINDER; - // TODO den implement -// rightPanel.add(new JLabel(ExternalSystemBundle.message("gradle.import.label.details")), constraints); - - constraints = new GridBagConstraints(); - constraints.weightx = constraints.weighty = 1; - constraints.fill = GridBagConstraints.BOTH; - constraints.anchor = GridBagConstraints.NORTHWEST; - constraints.gridwidth = GridBagConstraints.REMAINDER; - constraints.insets.left = 10; - rightPanel.add(mySettingsPanel, constraints); - - myComponent.add(rightPanel); - } - - @Override - public JComponent getComponent() { - return myComponent; - } - @Override - public String getHelpId() { - return null; - // TODO den uncomment - //return GradleConstants.HELP_TOPIC_ADJUST_SETTINGS_STEP; - } - - @Override - public void updateStep() { - if (myOnValidateAttempt) { - // We assume that this method is called when project validation triggered by end-user fails (he or she pressed 'Next'/'Finish' - // button at the wizard and current state is invalid). So, there is no need to rebuild the model then. - myOnValidateAttempt = false; - return; - } - - clear(); - - AbstractExternalProjectImportBuilder builder = getBuilder(); - if (builder == null) { - return; - } - DataNode project = builder.getExternalProjectNode(); - if (project == null) { - throw new IllegalStateException(String.format( - "Can't init 'adjust importing settings' step. Reason: no project is defined. Context: '%s', builder: '%s'", - getWizardContext(), getBuilder() - )); - } - - Map>> entity2nodes - = new HashMap>>(); - int counter = 0; - // TODO den uncomment - //ProjectStructureNode root = buildNode(project, entity2nodes, counter++); - - List modules = ContainerUtilRt.newArrayList(); -// List modules = new ArrayList(project.getModules()); - Collections.sort(modules, Named.COMPARATOR); - List moduleNodes = new ArrayList(); - - // TODO den implement -// for (ModuleData module : modules) { -// ProjectStructureNode moduleNode = buildNode(module, entity2nodes, counter++); -// moduleNodes.add(moduleNode); -// for (ContentRootData contentRoot : module.getContentRoots()) { -// moduleNode.add(buildNode(contentRoot, entity2nodes, counter++)); -// } -// Collection dependencies = module.getDependencies(); -// if (!dependencies.isEmpty()) { -// ProjectStructureNode dependenciesNode -// = new ProjectStructureNode(GradleConstants.DEPENDENCIES_NODE_DESCRIPTOR); -// final List moduleDependencies = new ArrayList(); -// final List libraryDependencies = new ArrayList(); -// ExternalEntityVisitor visitor = new ExternalEntityVisitorAdapter() { -// @Override -// public void visit(@NotNull ModuleDependencyData dependency) { -// moduleDependencies.add(dependency); -// } -// -// @Override -// public void visit(@NotNull LibraryDependencyData dependency) { -// libraryDependencies.add(dependency); -// } -// }; -// for (DependencyData dependency : dependencies) { -// dependency.invite(visitor); -// } -// Collections.sort(moduleDependencies, ModuleDependencyData.COMPARATOR); -// Collections.sort(libraryDependencies, Named.COMPARATOR); -// for (ModuleDependencyData dependency : moduleDependencies) { -// dependenciesNode.add(buildNode(dependency, entity2nodes, counter++)); -// } -// for (LibraryDependencyData dependency : libraryDependencies) { -// dependenciesNode.add(buildNode(dependency, entity2nodes, counter++)); -// } -// moduleNode.add(dependenciesNode); -// } -// } - - // TODO den uncomment - //myTreeModel.setRoot(root); - //myTree.setSelectionPath(new TreePath(root)); - - // TODO den implement -// Collection libraries = project.getLibraries(); -// if (libraries.isEmpty()) { -// for (MutableTreeNode node : moduleNodes) { -// root.add(node); -// } -// } -// else { -// // Insert intermediate 'modules' and 'libraries' nodes if the project has both libraries and nodes. -// ProjectStructureNode modulesNode -// = new ProjectStructureNode(GradleConstants.MODULES_NODE_DESCRIPTOR); -// for (MutableTreeNode node : moduleNodes) { -// modulesNode.add(node); -// } -// root.add(modulesNode); -// -// List sortedLibraries = new ArrayList(libraries); -// Collections.sort(sortedLibraries, Named.COMPARATOR); -// ProjectStructureNode librariesNode -// = new ProjectStructureNode(GradleConstants.LIBRARIES_NODE_DESCRIPTOR); -// for (LibraryData library : sortedLibraries) { -// librariesNode.add(buildNode(library, entity2nodes, counter++)); -// } -// root.add(librariesNode); -// -// myTree.expandPath(new TreePath(modulesNode.getPath())); -// myTree.expandPath(new TreePath(librariesNode.getPath())); -// } - - //myTree.expandPath(new TreePath(root.getPath())); - } - - private ProjectStructureNode buildNode( - @NotNull ProjectEntityData entity, @NotNull Map>> processed, int counter) - { - return null; - // We build tree node, its settings control and map them altogether. The only trick here is that nodes can reuse the same - // settings control (e.g. more than one node may have the same library as a dependency, so, library dependency node for - // every control will use the same settings control). - // TODO den uncomment - //ProjectStructureNode result = new ProjectStructureNode(myFactory.buildDescriptor(entity)); - //Pair> pair = processed.get(entity); - //if (pair == null) { - // String cardName = String.valueOf(counter); - // List nodes = new ArrayList(); - // nodes.add(result); - // processed.put(entity, new Pair>(cardName, nodes)); - // GradleProjectStructureNodeSettings settings = myFactory.buildSettings(entity, myTreeModel, nodes); - // myCards.put(result, new Pair(cardName, settings)); - // mySettingsPanel.add(settings.getComponent(), cardName); - //} - //else { - // pair.second.add(result); - // for (ProjectStructureNode node : pair.second) { - // Pair settingsPair = myCards.get(node); - // if (settingsPair != null) { - // myCards.put(result, settingsPair); - // break; - // } - // } - //} - //return result; - } - - @SuppressWarnings("SuspiciousMethodCalls") - @Override - public boolean validate() throws ConfigurationException { - AbstractExternalProjectImportBuilder builder = getBuilder(); - if (builder == null) { - return false; - } - - // Validate current card. - Object node = myTree.getLastSelectedPathComponent(); - // TODO den uncomment - //Pair pair = myCards.get(node); - //if (pair != null && !pair.second.validate()) { - // myOnValidateAttempt = true; - // return false; - //} - // - //for (Map.Entry> entry : myCards.entrySet()) { - // if (!entry.getValue().second.validate()) { - // myTree.getSelectionModel().setSelectionPath(new TreePath(entry.getKey().getPath())); - // myOnValidateAttempt = true; - // return false; - // } - //} - - builder.applyProjectSettings(getWizardContext()); - return true; - } - - @Override - public void updateDataModel() { - } - - private void clear() { - // TODO den uncomment - //myCards.clear(); - mySettingsPanel.removeAll(); - mySettingsPanel.add(new JPanel(), EMPTY_CARD_NAME); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/settings/ExternalSystemTextAttributes.java b/platform/external-system/src/com/intellij/openapi/externalSystem/settings/ExternalSystemTextAttributes.java deleted file mode 100644 index b4a238a7222a..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/settings/ExternalSystemTextAttributes.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.intellij.openapi.externalSystem.settings; - -import com.intellij.openapi.editor.DefaultLanguageHighlighterColors; -import com.intellij.openapi.editor.HighlighterColors; -import com.intellij.openapi.editor.colors.CodeInsightColors; -import com.intellij.openapi.editor.colors.TextAttributesKey; - -/** - * Holds keys to the colors used at external system-specific processing. - *

- * Thread-safe. - * - * @author Denis Zhdanov - * @since 1/18/12 4:19 PM - */ -public class ExternalSystemTextAttributes { - - /** - * References color to use for indication of particular change that exists only at the external system side. - *

- * Example: particular dependency is added at the external system side but not at the ide. - */ - public static final TextAttributesKey EXTERNAL_SYSTEM_LOCAL_CHANGE = TextAttributesKey.createTextAttributesKey( - "EXTERNAL_SYSTEM_LOCAL_CHANGE", - DefaultLanguageHighlighterColors.STRING - ); - - /** - * References color to use for indication of particular change that exists only at the ide side. - *

- * Example: particular dependency is added at the ide side but not at the external system. - */ - public static final TextAttributesKey IDE_LOCAL_CHANGE = TextAttributesKey.createTextAttributesKey( - "IDE_LOCAL_CHANGE", - DefaultLanguageHighlighterColors.KEYWORD - ); - - /** - * References color to use for indication that particular setting has different values at the gradle and intellij. - *

- * Example: particular module is renamed at the intellij, i.e. 'module.name' property has different (conflicting) - * values at the gradle and the intellij. - */ - public static final TextAttributesKey CHANGE_CONFLICT = TextAttributesKey.createTextAttributesKey( - "EXTERNAL_SYSTEM_CHANGE_CONFLICT", - CodeInsightColors.ERRORS_ATTRIBUTES - ); - - public static final TextAttributesKey OUTDATED_ENTITY = TextAttributesKey.createTextAttributesKey( - "GRADLE_OUTDATED_ENTITY", - DefaultLanguageHighlighterColors.STATIC_FIELD - ); - - /** - * References color to use for indication that particular setting has the same values at the gradle and intellij. - */ - public static final TextAttributesKey NO_CHANGE = TextAttributesKey.createTextAttributesKey( - "EXTERNAL_SYSTEM_NO_CHANGE", - HighlighterColors.TEXT - ); - - private ExternalSystemTextAttributes() { - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/settings/UserProjectChanges.java b/platform/external-system/src/com/intellij/openapi/externalSystem/settings/UserProjectChanges.java deleted file mode 100644 index 5884190a6e06..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/settings/UserProjectChanges.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.settings; - -import com.intellij.openapi.components.PersistentStateComponent; -import com.intellij.openapi.components.ServiceManager; -import com.intellij.openapi.externalSystem.model.project.change.user.*; -import com.intellij.openapi.project.Project; -import com.intellij.util.xmlb.XmlSerializerUtil; -import com.intellij.util.xmlb.annotations.AbstractCollection; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.atomic.AtomicReference; - -/** - * Holds {@link UserProjectChange} per-project. - *

- * Thread-safe. - * - * @author Denis Zhdanov - * @since 4/8/13 4:52 PM - */ -public class UserProjectChanges implements PersistentStateComponent { - - private final AtomicReference>> myUserChanges - = new AtomicReference>>(new HashSet>()); - - @NotNull - public static UserProjectChanges getInstance(@NotNull Project project) { - return ServiceManager.getService(project, UserProjectChanges.class); - } - - @Nullable - @Override - public UserProjectChanges getState() { - return this; - } - - @Override - public void loadState(UserProjectChanges state) { - XmlSerializerUtil.copyBean(state, this); - } - - @AbstractCollection( - surroundWithTag = false, - elementTypes = { - AddModuleUserChange.class, RemoveModuleUserChange.class, - AddModuleDependencyUserChange.class, RemoveModuleDependencyUserChange.class, - AddLibraryDependencyUserChange.class, RemoveLibraryDependencyUserChange.class, - ModuleDependencyExportedChange.class, ModuleDependencyScopeUserChange.class, - LibraryDependencyExportedChange.class, LibraryDependencyScopeUserChange.class - } - ) - @NotNull - public Set> getUserProjectChanges() { - return myUserChanges.get(); - } - - public void setUserProjectChanges(@Nullable Set> changes) { - myUserChanges.set(changes); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/ui/ExternalProjectStructureNodeComparator.java b/platform/external-system/src/com/intellij/openapi/externalSystem/ui/ExternalProjectStructureNodeComparator.java deleted file mode 100644 index 6127dfb28c0a..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/ui/ExternalProjectStructureNodeComparator.java +++ /dev/null @@ -1,188 +0,0 @@ -package com.intellij.openapi.externalSystem.ui; - -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.*; -import com.intellij.openapi.externalSystem.model.project.id.ProjectEntityId; -import com.intellij.openapi.externalSystem.service.project.ModuleAwareContentRoot; -import com.intellij.openapi.externalSystem.service.project.ProjectStructureServices; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; -import com.intellij.openapi.externalSystem.util.IdeEntityVisitor; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.LibraryOrderEntry; -import com.intellij.openapi.roots.ModuleOrderEntry; -import com.intellij.openapi.roots.ModuleSourceOrderEntry; -import com.intellij.openapi.roots.OrderEntry; -import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.util.Ref; -import org.jetbrains.annotations.NotNull; - -import java.util.Comparator; - -/** - * Encapsulates logic of comparing 'sync project structures' tree nodes. - *

- * Thread-safe. - * - * @author Denis Zhdanov - * @since 2/21/12 2:44 PM - */ -public class ExternalProjectStructureNodeComparator implements Comparator> { - - private static final int PROJECT_WEIGHT = 0; - private static final int MODULE_WEIGHT = 1; - private static final int CONTENT_ROOT_WEIGHT = 2; - private static final int SYNTHETIC_WEIGHT = 3; - private static final int MODULE_DEPENDENCY_WEIGHT = 4; - private static final int LIBRARY_DEPENDENCY_WEIGHT = 5; - private static final int LIBRARY_WEIGHT = 6; - private static final int JAR_WEIGHT = 7; - private static final int UNKNOWN_WEIGHT = 20; - - @NotNull private final ProjectStructureServices myContext; - @NotNull private final Project myProject; - - public ExternalProjectStructureNodeComparator(@NotNull ProjectStructureServices context, @NotNull Project project) { - myContext = context; - myProject = project; - } - - @Override - public int compare(ProjectStructureNode n1, ProjectStructureNode n2) { - final ProjectStructureNodeDescriptor d1 = n1.getDescriptor(); - final ProjectEntityId id1 = d1.getElement(); - - final ProjectStructureNodeDescriptor d2 = n2.getDescriptor(); - final ProjectEntityId id2 = d2.getElement(); - - // Put 'gradle-local' nodes at the top. - if (!ProjectSystemId.IDE.equals(id1.getOwner())&& ProjectSystemId.IDE.equals(id2.getOwner())) { - return -1; - } - else if (ProjectSystemId.IDE.equals(id1.getOwner()) && !ProjectSystemId.IDE.equals(id2.getOwner())) { - return 1; - } - - // Compare by weight. - int weight1 = getWeight(id1); - int weight2 = getWeight(id2); - if (weight1 != weight2) { - return weight1 - weight2; - } - - // Compare by name. - return d1.getName().compareTo(d2.getName()); - } - - private int getWeight(@NotNull ProjectEntityId id) { - if (id.getType() == ProjectEntityType.SYNTHETIC) { - return SYNTHETIC_WEIGHT; - } - else if (id.getType() == ProjectEntityType.JAR) { - return JAR_WEIGHT; - } - Object entity = id.mapToEntity(myContext, myProject); - if (entity instanceof AbstractCompositeData) { - entity = ((AbstractCompositeData)entity).getIdeEntity(); - } - final Ref result = new Ref(); - if (entity instanceof ProjectEntityData) { - // TODO den implement -// ((ProjectEntityData)entity).invite(new ExternalEntityVisitor() { -// @Override -// public void visit(@NotNull ProjectData project) { -// result.set(PROJECT_WEIGHT); -// } -// -// @Override -// public void visit(@NotNull ModuleData module) { -// result.set(MODULE_WEIGHT); -// } -// -// @Override -// public void visit(@NotNull ContentRootData contentRoot) { -// result.set(CONTENT_ROOT_WEIGHT); -// } -// -// @Override -// public void visit(@NotNull LibraryData library) { -// result.set(LIBRARY_WEIGHT); -// } -// -// @Override -// public void visit(@NotNull JarData jar) { -// result.set(JAR_WEIGHT); -// } -// -// @Override -// public void visit(@NotNull ModuleDependencyData dependency) { -// result.set(MODULE_DEPENDENCY_WEIGHT); -// } -// -// @Override -// public void visit(@NotNull LibraryDependencyData dependency) { -// result.set(LIBRARY_DEPENDENCY_WEIGHT); -// } -// -// @Override -// public void visit(@NotNull CompositeLibraryDependencyData dependency) { -// result.set(LIBRARY_DEPENDENCY_WEIGHT); -// } -// }); - } - else { - ExternalSystemUtil.dispatch(entity, new IdeEntityVisitor() { - @Override - public void visit(@NotNull Project project) { - result.set(PROJECT_WEIGHT); - } - - @Override - public void visit(@NotNull Module module) { - result.set(MODULE_WEIGHT); - } - - @Override - public void visit(@NotNull ModuleAwareContentRoot contentRoot) { - int i = 0; - for (OrderEntry entry : myContext.getPlatformFacade().getOrderEntries(contentRoot.getModule())) { - if (entry instanceof ModuleSourceOrderEntry) { - result.set(i); - return; - } - i++; - } - result.set(CONTENT_ROOT_WEIGHT); - } - - @Override - public void visit(@NotNull LibraryOrderEntry libraryDependency) { - result.set(getWeight(libraryDependency.getOwnerModule(), libraryDependency)); - } - - @Override - public void visit(@NotNull ModuleOrderEntry moduleDependency) { - result.set(getWeight(moduleDependency.getOwnerModule(), moduleDependency)); - } - - @Override - public void visit(@NotNull Library library) { - result.set(LIBRARY_WEIGHT); - } - }); - } - final Integer i = result.get(); - return i == null ? UNKNOWN_WEIGHT : i; - } - - private int getWeight(@NotNull Module module, @NotNull Object entry) { - int i = 0; - for (OrderEntry orderEntry : myContext.getPlatformFacade().getOrderEntries(module)) { - if (orderEntry.equals(entry)) { - return i; - } - i++; - } - return UNKNOWN_WEIGHT; - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/ui/ExternalProjectStructureNodeFilter.java b/platform/external-system/src/com/intellij/openapi/externalSystem/ui/ExternalProjectStructureNodeFilter.java deleted file mode 100644 index f31437dedfe4..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/ui/ExternalProjectStructureNodeFilter.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.intellij.openapi.externalSystem.ui; - -import org.jetbrains.annotations.NotNull; - -/** - * @author Denis Zhdanov - * @since 3/11/12 11:40 AM - */ -public interface ExternalProjectStructureNodeFilter { - - boolean isVisible(@NotNull ProjectStructureNode node); -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/ui/ExternalProjectStructureTreeModel.java b/platform/external-system/src/com/intellij/openapi/externalSystem/ui/ExternalProjectStructureTreeModel.java deleted file mode 100644 index 4faac8e30c9e..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/ui/ExternalProjectStructureTreeModel.java +++ /dev/null @@ -1,1013 +0,0 @@ -package com.intellij.openapi.externalSystem.ui; - -import com.intellij.openapi.editor.colors.TextAttributesKey; -import com.intellij.openapi.externalSystem.model.project.*; -import com.intellij.openapi.externalSystem.model.project.change.*; -import com.intellij.openapi.externalSystem.model.project.id.*; -import com.intellij.openapi.externalSystem.service.project.*; -import com.intellij.openapi.externalSystem.service.project.change.ExternalProjectChangesCalculationContext; -import com.intellij.openapi.externalSystem.service.project.change.ExternalProjectStructureChangeListener; -import com.intellij.openapi.externalSystem.service.project.change.ProjectStructureChangesModel; -import com.intellij.openapi.externalSystem.settings.ExternalSystemTextAttributes; -import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; -import com.intellij.openapi.externalSystem.util.ExternalSystemUiUtil; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.*; -import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.util.Pair; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.util.Function; -import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.containers.ContainerUtilRt; -import com.intellij.util.containers.hash.HashMap; -import com.intellij.util.ui.UIUtil; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.TestOnly; -import com.intellij.openapi.externalSystem.model.project.change.ContentRootPresenceChange; -import com.intellij.openapi.externalSystem.model.project.change.DependencyExportedChange; -import com.intellij.openapi.externalSystem.model.project.change.DependencyScopeChange; -import com.intellij.openapi.externalSystem.model.project.change.LibraryDependencyPresenceChange; -import com.intellij.openapi.externalSystem.model.project.change.ModuleDependencyPresenceChange; -import com.intellij.openapi.externalSystem.model.project.change.OutdatedLibraryVersionChange; -import com.intellij.openapi.externalSystem.model.project.change.JarPresenceChange; -import com.intellij.openapi.externalSystem.model.project.change.ModulePresenceChange; -import com.intellij.openapi.externalSystem.model.project.change.LanguageLevelChange; -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.service.project.ProjectStructureServices; - -import javax.swing.tree.DefaultTreeModel; -import javax.swing.tree.TreeNode; -import java.util.*; - -/** - * Model for the target project structure tree used by the gradle integration. - *

- * Not thread-safe. - * - * @author Denis Zhdanov - * @since 1/30/12 4:20 PM - */ -public class ExternalProjectStructureTreeModel extends DefaultTreeModel { - - private static final Function SELF_MAPPER = new Function.Self(); - - /** - *

-   *     ...
-   *      |_module     <- module's name is a key
-   *          |_...
-   *          |_dependencies   <- dependencies holder node is a value
-   *                  |_dependency1
-   *                  |_dependency2
-   * 
- */ - private final Map> myModuleDependencies - = new HashMap>(); - private final Map> myModules - = new HashMap>(); - - private final Set myFilters = new HashSet(); - private final TreeNode[] myNodeHolder = new TreeNode[1]; - private final int[] myIndexHolder = new int[1]; - private final NodeListener myNodeListener = new NodeListener(); - private final ObsoleteChangesDispatcher myObsoleteChangesDispatcher = new ObsoleteChangesDispatcher(); - private final NewChangesDispatcher myNewChangesDispatcher = new NewChangesDispatcher(); - - @NotNull private final Project myProject; - @NotNull private final ProjectSystemId myExternalSystemId; - @NotNull private final PlatformFacade myPlatformFacade; - @NotNull private final ProjectStructureHelper myProjectStructureHelper; - @NotNull private final Comparator> myNodeComparator; - @NotNull private final ProjectStructureChangesModel myChangesModel; - - @Nullable private Comparator myChangesComparator; - - private boolean myProcessChangesAtTheSameThread; - - @SuppressWarnings("UnusedDeclaration") // Used implicitly by IoC - public ExternalProjectStructureTreeModel(@NotNull ProjectSystemId externalSystemId, - @NotNull Project project, - @NotNull ProjectStructureServices context) - { - this(externalSystemId, project, context, true); - } - - ExternalProjectStructureTreeModel(@NotNull ProjectSystemId externalSystemId, - @NotNull Project project, - @NotNull ProjectStructureServices context, - boolean rebuild) - { - super(null); - myExternalSystemId = externalSystemId; - myProject = project; - myPlatformFacade = context.getPlatformFacade(); - myProjectStructureHelper = context.getProjectStructureHelper(); - myChangesModel = context.getChangesModel(); - myNodeComparator = new ExternalProjectStructureNodeComparator(context, project); - - context.getChangesModel().addListener(new ExternalProjectStructureChangeListener() { - @Override - public void onChanges(@NotNull Project ideProject, - @NotNull ProjectSystemId externalSystemId, - @NotNull Collection oldChanges, - @NotNull Collection currentChanges) { - if (externalSystemId.equals(myExternalSystemId)) { - processChanges(oldChanges, currentChanges); - } - } - }); - - if (rebuild) { - rebuild(); - } - } - - private void processChanges(@NotNull final Collection oldChanges, - @NotNull final Collection currentChanges) - { - final Runnable task = new Runnable() { - @Override - public void run() { - Collection obsoleteChangesToUse = ContainerUtil.subtract(oldChanges, currentChanges); - Collection currentChangesToUse = ContainerUtil.subtract(currentChanges, oldChanges); - if (myChangesComparator != null) { - obsoleteChangesToUse = sort(obsoleteChangesToUse, myChangesComparator); - currentChangesToUse = sort(currentChangesToUse, myChangesComparator); - } - processObsoleteChanges(obsoleteChangesToUse); - processCurrentChanges(currentChangesToUse); - } - }; - if (myProcessChangesAtTheSameThread) { - task.run(); - } - else { - UIUtil.invokeLaterIfNeeded(task); - } - } - - @NotNull - private static Collection sort(@NotNull Collection changes, - @NotNull Comparator myChangesComparator) - { - List toSort = ContainerUtilRt.newArrayList(changes); - Collections.sort(toSort, myChangesComparator); - return toSort; - } - - @SuppressWarnings("unchecked") - @Override - public ProjectStructureNode getRoot() { - return (ProjectStructureNode)super.getRoot(); - } - - public void rebuild() { - rebuild(false); - } - - public void rebuild(boolean onIdeProjectStructureChange) { - myModuleDependencies.clear(); - myModules.clear(); - - ProjectId projectId = EntityIdMapper.mapEntityToId(getProject()); - ProjectStructureNode root = buildNode(projectId, getProject().getName()); - setRoot(root); - final Collection modules = myPlatformFacade.getModules(getProject()); - final List> dependencies = ContainerUtilRt.newArrayList(); - final List, Library>> libraryDependencies = ContainerUtilRt.newArrayList(); - RootPolicy visitor = new RootPolicy() { - @Override - public Object visitModuleOrderEntry(ModuleOrderEntry moduleOrderEntry, Object value) { - ModuleDependencyId id = EntityIdMapper.mapEntityToId(moduleOrderEntry); - dependencies.add(buildNode(id, moduleOrderEntry.getModuleName())); - return value; - } - - @Override - public Object visitLibraryOrderEntry(LibraryOrderEntry libraryOrderEntry, Object value) { - if (libraryOrderEntry.getLibraryName() == null) { - return value; - } - LibraryDependencyId id = EntityIdMapper.mapEntityToId(libraryOrderEntry); - ProjectStructureNode dependencyNode = buildNode(id, id.getDependencyName()); - Library library = libraryOrderEntry.getLibrary(); - if (library != null) { - libraryDependencies.add(Pair.create(dependencyNode, library)); - dependencies.add(dependencyNode); - } - return value; - } - }; - for (Module module : modules) { - dependencies.clear(); - libraryDependencies.clear(); - final ModuleId moduleId = EntityIdMapper.mapEntityToId(module); - final ProjectStructureNode moduleNode = buildNode(moduleId, moduleId.getModuleName()); - myModules.put(module.getName(), moduleNode); // Assuming that module names are unique. - root.add(moduleNode); - - // Content roots - final Collection contentRoots = myPlatformFacade.getContentRoots(module); - for (ContentEntry entry : contentRoots) { - ContentRootId contentRootId = EntityIdMapper.mapEntityToId(entry); - moduleNode.add(buildContentRootNode(contentRootId, contentRoots.size() <= 1)); - } - - // Dependencies - for (OrderEntry orderEntry : myPlatformFacade.getOrderEntries(module)) { - orderEntry.accept(visitor, null); - } - if (dependencies.isEmpty()) { - continue; - } - ProjectStructureNode dependenciesNode = getDependenciesNode(moduleId); - for (ProjectStructureNode dependency : dependencies) { - dependenciesNode.add(dependency); - } - - // The general idea is to add jar nodes when all tree nodes above have already been initialized. - if (!libraryDependencies.isEmpty()) { - for (Pair, Library> p : libraryDependencies) { - populateLibraryDependencyNode(p.first, p.second); - } - } - } - - // TODO den implement -// ProjectData externalProject = myChangesModel.getExternalProject(myExternalSystemId, myProject); -// if (externalProject != null) { -// ExternalProjectChangesCalculationContext context -// = myChangesModel.getCurrentChangesContext(externalProject, myProject, onIdeProjectStructureChange); -// processChanges(Collections.emptyList(), -// ContainerUtil.union(context.getKnownChanges(), context.getCurrentChanges())); -// filterNodes(root); -// } - } - - private void populateLibraryDependencyNode(@NotNull ProjectStructureNode node, - @Nullable Library library) - { - if (library == null) { - return; - } - - LibraryId libraryId = node.getDescriptor().getElement().getLibraryId(); - for (VirtualFile file : library.getFiles(OrderRootType.CLASSES)) { - JarId jarId = new JarId(ExternalSystemUtil.getLocalFileSystemPath(file), LibraryPathType.BINARY, libraryId); - ProjectStructureNode jarNode = buildNode(jarId, ExternalSystemUtil.extractNameFromPath(jarId.getPath())); - jarNode.getDescriptor().setToolTip(jarId.getPath()); - node.add(jarNode); - } - } - - @TestOnly - public void setProcessChangesAtTheSameThread(boolean processChangesAtTheSameThread) { - myProcessChangesAtTheSameThread = processChangesAtTheSameThread; - } - - @TestOnly - public void setChangesComparator(@Nullable Comparator changesComparator) { - myChangesComparator = changesComparator; - } - - private void filterNodes(@NotNull ProjectStructureNode root) { - if (myFilters.isEmpty()) { - return; - } - Deque> toRemove = new ArrayDeque>(); - Stack> toProcess = new Stack>(); - toProcess.push(root); - while (!toProcess.isEmpty()) { - final ProjectStructureNode current = toProcess.pop(); - toRemove.add(current); - if (passFilters(current)) { - toRemove.remove(current); - // Keep all nodes up to the hierarchy. - for (ProjectStructureNode parent = current.getParent(); parent != null; parent = parent.getParent()) { - if (!toRemove.remove(parent)) { - break; - } - } - } - for (ProjectStructureNode child : current) { - toProcess.push(child); - } - } - for (ProjectStructureNode node = toRemove.pollLast(); node != null; node = toRemove.pollLast()) { - final ProjectStructureNode parent = node.getParent(); - if (parent == null) { - continue; - } - parent.remove(node); - - // Clear caches. - final ProjectEntityId id = node.getDescriptor().getElement(); - if (id instanceof ModuleId) { - String moduleName = ((ModuleId)id).getModuleName(); - myModules.remove(moduleName); - myModuleDependencies.remove(moduleName); - } - } - } - - public void addFilter(@NotNull ExternalProjectStructureNodeFilter filter) { - myFilters.add(filter); - rebuild(); - } - - public boolean hasFilter(@NotNull ExternalProjectStructureNodeFilter filter) { - return myFilters.contains(filter); - } - - public boolean hasAnyFilter() { - return !myFilters.isEmpty(); - } - - public void removeFilter(@NotNull ExternalProjectStructureNodeFilter filter) { - myFilters.remove(filter); - rebuild(); - } - - public void removeAllFilters() { - myFilters.clear(); - rebuild(); - } - - /** - * @param node node to check - * @return true if active filters allow to show given node; false otherwise - */ - private boolean passFilters(@NotNull ProjectStructureNode node) { - if (myFilters.isEmpty()) { - return true; - } - for (ExternalProjectStructureNodeFilter filter : myFilters) { - if (filter.isVisible(node)) { - return true; - } - } - return false; - } - - @NotNull - private static String getContentRootNodeName(@NotNull ContentRootId id, boolean singleRoot) { - final String name = ExternalSystemBundle.message("entity.type.content.root"); - if (singleRoot) { - return name; - } - final String path = id.getRootPath(); - final int i = path.lastIndexOf('/'); - if (i < 0) { - return name; - } - return name + ":" + path.substring(i + 1); - } - - @NotNull - public Project getProject() { - return myProject; - } - - @NotNull - private ProjectStructureNode buildContentRootNode(@NotNull ContentRootId id) { - return null; - // TODO den implement -// final boolean singleRoot; -// if (myExternalSystemId.equals(id.getOwner())) { -// final ModuleData module = myProjectStructureHelper.findExternalModule(id.getModuleName(), myExternalSystemId, myProject); -// singleRoot = module == null || module.getContentRoots().size() <= 1; -// } -// else { -// final Module module = myProjectStructureHelper.findIdeModule(id.getModuleName(), myProject); -// singleRoot = module == null || myPlatformFacade.getContentRoots(module).size() <= 1; -// } -// return buildContentRootNode(id, singleRoot); - } - - @NotNull - private ProjectStructureNode buildContentRootNode(@NotNull ContentRootId id, boolean singleRoot) { - ProjectStructureNode result = buildNode(id, getContentRootNodeName(id, singleRoot)); - result.getDescriptor().setToolTip(id.getRootPath()); - return result; - } - - @NotNull - private ProjectStructureNode buildNode(@NotNull T id, @NotNull String name) { - final ProjectStructureNode result = new ProjectStructureNode(ExternalSystemUiUtil.buildDescriptor(id, name), myNodeComparator); - result.addListener(myNodeListener); - return result; - } - - @NotNull - private ProjectStructureNode getDependenciesNode(@NotNull ModuleId id) { - final ProjectStructureNode cached = myModuleDependencies.get(id.getModuleName()); - if (cached != null) { - return cached; - } - ProjectStructureNode moduleNode = getModuleNode(id); - ProjectStructureNode result - = new ProjectStructureNode(ExternalSystemUiUtil.DEPENDENCIES_NODE_DESCRIPTOR, myNodeComparator); - result.addListener(myNodeListener); - moduleNode.add(result); - myModuleDependencies.put(id.getModuleName(), result); - - return result; - } - - @NotNull - private ProjectStructureNode getModuleNode(@NotNull ModuleId id) { - ProjectStructureNode moduleNode = myModules.get(id.getModuleName()); - if (moduleNode == null) { - moduleNode = buildNode(id, id.getModuleName()); - myModules.put(id.getModuleName(), moduleNode); - ((ProjectStructureNode)root).add(moduleNode); - } - return moduleNode; - } - - /** - * Notifies current model that particular module roots change just has happened. - *

- * The model is expected to update itself if necessary. - */ - public void onModuleRootsChange() { - for (ProjectStructureNode node : myModuleDependencies.values()) { - node.sortChildren(); - } - } - - private void removeModuleNodeIfEmpty(@NotNull ProjectStructureNode node) { - if (node.getChildCount() != 0) { - return; - } - node.removeFromParent(); - myModules.remove(node.getDescriptor().getElement().getModuleName()); - } - - private void removeModuleDependencyNodeIfEmpty(@NotNull ProjectStructureNode node, - @NotNull ModuleId moduleId) - { - if (node.getChildCount() != 0) { - return; - } - node.removeFromParent(); - myModuleDependencies.remove(moduleId.getModuleName()); - } - - /** - * Asks current model to update its state in accordance with the given changes. - * - * @param changes collections that contains all changes between the current gradle and intellij project structures - */ - public void processCurrentChanges(@NotNull Collection changes) { - for (ExternalProjectStructureChange change : changes) { - change.invite(myNewChangesDispatcher); - } - } - - /** - * Asks current model to process given changes assuming that they are obsolete. - *

- * Example: - *

-   * 
    - *
  1. There is a particular intellij-local library (change from the gradle project structure);
  2. - *
  3. Corresponding node is shown at the current UI;
  4. - *
  5. The library is removed, i.e. corresponding change has become obsolete;
  6. - *
  7. This method is notified within the obsolete change and is expected to remove the corresponding node;
  8. - *
- *
- */ - public void processObsoleteChanges(Collection changes) { - for (ExternalProjectStructureChange change : changes) { - change.invite(myObsoleteChangesDispatcher); - } - } - - private void processNewProjectRenameChange(@NotNull GradleProjectRenameChange change) { - getRoot().addConflictChange(change); - } - - private void processNewLanguageLevelChange(@NotNull LanguageLevelChange change) { - getRoot().addConflictChange(change); - } - - private void processNewDependencyScopeChange(@NotNull DependencyScopeChange change) { - processDependencyConflictChange(change, SELF_MAPPER, false); - } - - private void processNewDependencyExportedChange(@NotNull DependencyExportedChange change) { - processDependencyConflictChange(change, SELF_MAPPER, false); - } - - private void processNewLibraryDependencyPresenceChange(@NotNull LibraryDependencyPresenceChange change) { - ProjectStructureNode dependencyNode = processNewDependencyPresenceChange(change); - LibraryDependencyId id = change.getExternalEntity(); - if (dependencyNode == null || id == null) { - return; - } - LibraryData gradleLibrary = null; - // TODO den implement -// LibraryData gradleLibrary = myProjectStructureHelper.findExternalLibrary(id.getLibraryId(), myExternalSystemId, myProject); - if (gradleLibrary == null) { - return; - } - - Map> existingJarNodes = ContainerUtilRt.newHashMap(); - for (ProjectStructureNode jarNode : dependencyNode.getChildren(JarId.class)) { - existingJarNodes.put(jarNode.getDescriptor().getElement(), jarNode); - } - - Map> gradleJarIds = ContainerUtilRt.newHashMap(); - LibraryId libraryId = dependencyNode.getDescriptor().getElement().getLibraryId(); - for (String path : gradleLibrary.getPaths(LibraryPathType.BINARY)) { - JarId jarId = new JarId(path, LibraryPathType.BINARY, libraryId); - ProjectStructureNode jarNode = existingJarNodes.get(jarId); - if (jarNode == null) { - jarNode = buildNode(jarId, ExternalSystemUtil.extractNameFromPath(jarId.getPath())); - jarNode.setAttributes(ExternalSystemTextAttributes.NO_CHANGE); - jarNode.getDescriptor().setToolTip(jarId.getPath()); - dependencyNode.add(jarNode); - } - gradleJarIds.put(jarId, jarNode); - } - - Library intellijLibrary = myProjectStructureHelper.findIdeLibrary(gradleLibrary, myProject); - if (intellijLibrary == null) { - for (ProjectStructureNode jarNode : dependencyNode) { - jarNode.setAttributes(ExternalSystemTextAttributes.EXTERNAL_SYSTEM_LOCAL_CHANGE); - } - } - else { - Set intellijJarIds = ContainerUtilRt.newHashSet(); - for (VirtualFile jarFile : intellijLibrary.getFiles(OrderRootType.CLASSES)) { - JarId jarId = new JarId(ExternalSystemUtil.getLocalFileSystemPath(jarFile), LibraryPathType.BINARY, libraryId); - if (gradleJarIds.remove(jarId) == null) { - intellijJarIds.add(jarId); - } - } - for (ProjectStructureNode jarNode : gradleJarIds.values()) { - jarNode.setAttributes(ExternalSystemTextAttributes.EXTERNAL_SYSTEM_LOCAL_CHANGE); - } - for (JarId jarId : intellijJarIds) { - ProjectStructureNode jarNode = buildNode(jarId, ExternalSystemUtil.extractNameFromPath(jarId.getPath())); - jarNode.setAttributes(ExternalSystemTextAttributes.IDE_LOCAL_CHANGE); - jarNode.getDescriptor().setToolTip(jarId.getPath()); - dependencyNode.add(jarNode); - } - } - } - - private void processJarPresenceChange(@NotNull JarPresenceChange change, boolean obsolete) { - JarId jarId = change.getExternalEntity(); - TextAttributesKey attributes = ExternalSystemTextAttributes.EXTERNAL_SYSTEM_LOCAL_CHANGE; - if (jarId == null) { - jarId = change.getIdeEntity(); - attributes = ExternalSystemTextAttributes.IDE_LOCAL_CHANGE; - assert jarId != null; - } - if (jarId.getLibraryPathType() != LibraryPathType.BINARY) { - // Ignore non-binary paths (docs, sources) as they are not shown at the JetGradle tool window's project structure view. - return; - } - if (obsolete) { - attributes = ExternalSystemTextAttributes.NO_CHANGE; - } - - for (Map.Entry> entry : myModuleDependencies.entrySet()) { - Collection> libraryDependencies - = entry.getValue().getChildren(LibraryDependencyId.class); - - insideModule: - for (ProjectStructureNode libraryDependencyNode : libraryDependencies) { - if (!libraryDependencyNode.getDescriptor().getElement().getLibraryId().equals(jarId.getLibraryId())) { - continue; - } - - for (ProjectStructureNode jarNode : libraryDependencyNode.getChildren(JarId.class)) { - if (jarNode.getDescriptor().getElement().equals(jarId)) { - if (obsolete && myProjectStructureHelper.findIdeJar(jarId, myProject) == null) { - // It was a gradle-local change which is now obsolete. Remove the jar node then. - jarNode.removeFromParent(); - } - else { - jarNode.setAttributes(attributes); - } - break insideModule; - } - } - - if (obsolete) { - continue; - } - - // There is a possible case that both gradle and intellij have a library with the same name but different jar sets. - // We don't want to show intellij-local jars for the gradle-local module which uses that library then. - if (jarId.getOwner() == ProjectSystemId.IDE - && myModules.get(entry.getKey()).getDescriptor().getAttributes() == ExternalSystemTextAttributes.EXTERNAL_SYSTEM_LOCAL_CHANGE) - { - continue; - } - - // When control flow reaches this place that means that this is a new jar attached to a library. Hence, we need to add a node. - ProjectStructureNode newNode = buildNode(jarId, ExternalSystemUtil.extractNameFromPath(jarId.getPath())); - newNode.setAttributes(attributes); - newNode.getDescriptor().setToolTip(jarId.getPath()); - if (passFilters(newNode)) { - libraryDependencyNode.add(newNode); - } - } - } - } - - private void processNewChangedLibraryVersionChange(@NotNull OutdatedLibraryVersionChange change) { - for (Module module : myPlatformFacade.getModules(myProject)) { - String moduleName = module.getName(); - LibraryOrderEntry dependency = - myProjectStructureHelper.findIdeLibraryDependency(moduleName, change.getIdeLibraryId().getLibraryName(), myProject); - if (dependency == null) { - continue; - } - ProjectStructureNode dependenciesNode = - getDependenciesNode(new ModuleId(ProjectSystemId.IDE, moduleName)); - - // Remove local dependency nodes (if any). - Collection> dependencyNodes = - dependenciesNode.getChildren(LibraryDependencyId.class); - for (ProjectStructureNode dependencyNode : dependencyNodes) { - LibraryDependencyId id = dependencyNode.getDescriptor().getElement(); - if (id.getLibraryId().equals(change.getLibraryId()) || id.getLibraryId().equals(change.getIdeLibraryId())) { - dependenciesNode.remove(dependencyNode); - } - } - - // Add 'changed version' nodes. - CompositeLibraryDependencyId libraryDependencyId = new CompositeLibraryDependencyId( - new LibraryDependencyId(myExternalSystemId, moduleName, change.getLibraryId().getLibraryName()), - new LibraryDependencyId(ProjectSystemId.IDE, moduleName, change.getIdeLibraryId().getLibraryName()) - ); - String libraryDependencyNodeName = ExternalSystemUtil.getOutdatedEntityName( - change.getBaseLibraryName(), - change.getExternalLibraryVersion(), - change.getIdeLibraryVersion() - ); - ProjectStructureNode libraryDependencyNode = - buildNode(libraryDependencyId, libraryDependencyNodeName); - libraryDependencyNode.setAttributes(ExternalSystemTextAttributes.OUTDATED_ENTITY); - if (passFilters(libraryDependencyNode)) { - dependenciesNode.add(libraryDependencyNode); - } - } - } - - private void processNewModuleDependencyPresenceChange(@NotNull ModuleDependencyPresenceChange change) { - processNewDependencyPresenceChange(change); - } - - @SuppressWarnings("unchecked") - @Nullable - private ProjectStructureNode processNewDependencyPresenceChange( - @NotNull AbstractProjectEntityPresenceChange change) - { - I id = change.getExternalEntity(); - TextAttributesKey attributes = ExternalSystemTextAttributes.EXTERNAL_SYSTEM_LOCAL_CHANGE; - if (id == null) { - id = change.getIdeEntity(); - attributes = ExternalSystemTextAttributes.IDE_LOCAL_CHANGE; - } - assert id != null; - final ProjectStructureNode dependenciesNode = getDependenciesNode(id.getOwnerModuleId()); - Class clazz = (Class)id.getClass(); - for (ProjectStructureNode node : dependenciesNode.getChildren(clazz)) { - if (id.equals(node.getDescriptor().getElement())) { - node.setAttributes(attributes); - return node; - } - } - ProjectStructureNode newNode = buildNode(id, id.getDependencyName()); - dependenciesNode.add(newNode); - newNode.setAttributes(attributes); - - if (passFilters(newNode)) { - return newNode; - } - - newNode.removeFromParent(); - removeModuleDependencyNodeIfEmpty(dependenciesNode, id.getOwnerModuleId()); - removeModuleNodeIfEmpty(getModuleNode(id.getOwnerModuleId())); - return null; - } - - private void processNewModulePresenceChange(@NotNull ModulePresenceChange change) { - final ModuleId id; - final TextAttributesKey key; - if (change.getExternalEntity() == null) { - id = change.getIdeEntity(); - key = ExternalSystemTextAttributes.IDE_LOCAL_CHANGE; - } - else { - id = change.getExternalEntity(); - key = ExternalSystemTextAttributes.EXTERNAL_SYSTEM_LOCAL_CHANGE; - } - assert id != null; - final ProjectStructureNode moduleNode = getModuleNode(id); - moduleNode.setAttributes(key); - - if (!passFilters(moduleNode)) { - removeModuleNodeIfEmpty(moduleNode); - } - } - - private void processNewContentRootPresenceChange(@NotNull ContentRootPresenceChange change) { - ContentRootId id = change.getExternalEntity(); - TextAttributesKey key = ExternalSystemTextAttributes.EXTERNAL_SYSTEM_LOCAL_CHANGE; - if (id == null) { - id = change.getIdeEntity(); - key = ExternalSystemTextAttributes.IDE_LOCAL_CHANGE; - } - assert id != null; - final ProjectStructureNode moduleNode = getModuleNode(id.getModuleId()); - for (ProjectStructureNode contentRoot : moduleNode.getChildren(ContentRootId.class)) { - if (id.equals(contentRoot.getDescriptor().getElement())) { - contentRoot.setAttributes(key); - return; - } - } - ProjectStructureNode contentRootNode = buildContentRootNode(id); - moduleNode.add(contentRootNode); - contentRootNode.setAttributes(key); - - if (!passFilters(contentRootNode)) { - contentRootNode.removeFromParent(); - removeModuleNodeIfEmpty(moduleNode); - } - } - - private void processObsoleteProjectRenameChange(@NotNull GradleProjectRenameChange change) { - getRoot().removeConflictChange(change); - } - - private void processObsoleteLanguageLevelChange(@NotNull LanguageLevelChange change) { - getRoot().removeConflictChange(change); - } - - private void processObsoleteDependencyScopeChange(@NotNull DependencyScopeChange change) { - processDependencyConflictChange(change, SELF_MAPPER, true); - } - - private void processObsoleteDependencyExportedChange(@NotNull DependencyExportedChange change) { - processDependencyConflictChange(change, SELF_MAPPER, true); - } - - private void processObsoleteLibraryDependencyPresenceChange(@NotNull LibraryDependencyPresenceChange change) { - // We need to remove the corresponding node then. - LibraryDependencyId id = change.getExternalEntity(); - boolean removeNode; - if (id == null) { - id = change.getIdeEntity(); - assert id != null; - removeNode = !myProjectStructureHelper.isIdeLibraryDependencyExist(id, myProject); - } - else { - removeNode = !myProjectStructureHelper.isExternalLibraryDependencyExist(id, myExternalSystemId, myProject); - } - processObsoleteDependencyPresenceChange(id, removeNode); - } - - private void processObsoleteChangedLibraryVersionChange(@NotNull OutdatedLibraryVersionChange change) { - Library library = myProjectStructureHelper.findIdeLibraryByBaseName(change.getBaseLibraryName(), myProject); - if (library == null) { - return; - } - for (Map.Entry> entry : myModuleDependencies.entrySet()) { - String moduleName = entry.getKey(); - CompositeLibraryDependencyId outdatedEntityId = new CompositeLibraryDependencyId( - new LibraryDependencyId(myExternalSystemId, moduleName, change.getLibraryId().getLibraryName()), - new LibraryDependencyId(ProjectSystemId.IDE, moduleName, change.getIdeLibraryId().getLibraryName()) - ); - ProjectStructureNode dependenciesNode = entry.getValue(); - Collection> dependencyNodes = - dependenciesNode.getChildren(CompositeLibraryDependencyId.class); - for (ProjectStructureNode oldDependencyNode : dependencyNodes) { - if (!outdatedEntityId.equals(oldDependencyNode.getDescriptor().getElement())) { - continue; - } - dependenciesNode.remove(oldDependencyNode); - LibraryOrderEntry libraryDependency = - myProjectStructureHelper.findIdeLibraryDependency(moduleName, ExternalSystemUtil.getLibraryName(library), myProject); - if (libraryDependency != null) { - LibraryDependencyId newDependencyId = EntityIdMapper.mapEntityToId(libraryDependency); - ProjectStructureNode newDependencyNode = - buildNode(newDependencyId, newDependencyId.getDependencyName()); - populateLibraryDependencyNode(newDependencyNode, libraryDependency.getLibrary()); - dependenciesNode.add(newDependencyNode); - } - } - } - } - - private void processObsoleteModuleDependencyPresenceChange(@NotNull ModuleDependencyPresenceChange change) { - ModuleDependencyId id = change.getExternalEntity(); - boolean removeNode; - if (id == null) { - id = change.getIdeEntity(); - assert id != null; - removeNode = !myProjectStructureHelper.isIdeModuleDependencyExist(id, myProject); - } - else { - removeNode = !myProjectStructureHelper.isExternalModuleDependencyExist(id, myProject); - } - processObsoleteDependencyPresenceChange(id, removeNode); - } - - private void processObsoleteDependencyPresenceChange(@NotNull AbstractExternalDependencyId id, boolean removeNode) { - final ProjectStructureNode holder = myModuleDependencies.get(id.getOwnerModuleName()); - if (holder == null) { - return; - } - - // There are two possible cases why 'local library dependency' change is obsolete: - // 1. Corresponding dependency has been added at the counterparty; - // 2. The 'local dependency' has been removed; - // We should distinguish between those situations because we need to mark the node as 'synced' at one case and - // completely removed at another one. - - for (ProjectStructureNode node : holder.getChildren(id.getClass())) { - ProjectStructureNodeDescriptor descriptor = node.getDescriptor(); - if (!id.equals(descriptor.getElement())) { - continue; - } - if (removeNode) { - holder.remove(node); - } - else { - descriptor.setAttributes(ExternalSystemTextAttributes.NO_CHANGE); - holder.correctChildPositionIfNecessary(node); - if (!passFilters(node)) { - node.removeFromParent(); - removeModuleDependencyNodeIfEmpty(holder, id.getOwnerModuleId()); - removeModuleNodeIfEmpty(myModules.get(id.getOwnerModuleName())); - } - } - return; - } - } - - private void processObsoleteModulePresenceChange(@NotNull ModulePresenceChange change) { - ModuleId id = change.getExternalEntity(); - boolean removeNode; - if (id == null) { - id = change.getIdeEntity(); - assert id != null; - removeNode = myProjectStructureHelper.findIdeModule(id.getModuleName(), myProject) == null; - } - else { - removeNode = myProjectStructureHelper.findExternalModule(id.getModuleName(), myExternalSystemId, myProject) == null; - } - - - // There are two possible cases why 'module presence' change is obsolete: - // 1. Corresponding module has been added at the counterparty; - // 2. The 'local module' has been removed; - // We should distinguish between those situations because we need to mark the node as 'synced' at one case and - // completely removed at another one. - - final ProjectStructureNode moduleNode = myModules.get(id.getModuleName()); - if (moduleNode == null) { - return; - } - if (removeNode) { - moduleNode.removeFromParent(); - } - else { - moduleNode.setAttributes(ExternalSystemTextAttributes.NO_CHANGE); - if (!passFilters(moduleNode)) { - removeModuleNodeIfEmpty(moduleNode); - } - } - } - - private void processObsoleteContentRootPresenceChange(@NotNull ContentRootPresenceChange change) { - ContentRootId id = change.getExternalEntity(); - final boolean removeNode; - if (id == null) { - id = change.getIdeEntity(); - assert id != null; - removeNode = myProjectStructureHelper.findIdeContentRoot(id, myProject) == null; - } - else { - removeNode = myProjectStructureHelper.findExternalContentRoot(id, myExternalSystemId, myProject) == null; - } - final ProjectStructureNode moduleNode = myModules.get(id.getModuleName()); - if (moduleNode == null) { - return; - } - for (ProjectStructureNode contentRootNode : moduleNode.getChildren(ContentRootId.class)) { - if (!id.equals(contentRootNode.getDescriptor().getElement())) { - continue; - } - if (removeNode) { - contentRootNode.removeFromParent(); - } - else { - contentRootNode.setAttributes(ExternalSystemTextAttributes.NO_CHANGE); - if (!passFilters(contentRootNode)) { - contentRootNode.removeFromParent(); - removeModuleNodeIfEmpty(moduleNode); - } - } - return; - } - } - - private void processDependencyConflictChange(@NotNull AbstractConflictingPropertyChange change, - @NotNull Function nodeIdMapper, - boolean obsolete) - { - for (Map.Entry> entry : myModuleDependencies.entrySet()) { - for (ProjectStructureNode dependencyNode : entry.getValue()) { - if (!change.getEntityId().equals(nodeIdMapper.fun(dependencyNode.getDescriptor().getElement()))) { - continue; - } - if (obsolete) { - dependencyNode.removeConflictChange(change); - } - else { - dependencyNode.addConflictChange(change); - } - if (!passFilters(dependencyNode)) { - dependencyNode.removeFromParent(); - final ProjectStructureNode moduleNode = myModules.get(entry.getKey()); - final ModuleId moduleId = moduleNode.getDescriptor().getElement(); - removeModuleDependencyNodeIfEmpty(entry.getValue(), moduleId); - removeModuleNodeIfEmpty(moduleNode); - } - break; - } - } - } - - private class NodeListener implements ProjectStructureNode.Listener { - - @Override - public void onNodeAdded(@NotNull ProjectStructureNode node, int index) { - myIndexHolder[0] = index; - nodesWereInserted(node.getParent(), myIndexHolder); - } - - @Override - public void onNodeRemoved(@NotNull ProjectStructureNode parent, - @NotNull ProjectStructureNode removedChild, - int removedChildIndex) - { - myIndexHolder[0] = removedChildIndex; - myNodeHolder[0] = removedChild; - nodesWereRemoved(parent, myIndexHolder, myNodeHolder); - } - - @Override - public void onNodeChanged(@NotNull ProjectStructureNode node) { - nodeChanged(node); - } - - @Override - public void onNodeChildrenChanged(@NotNull ProjectStructureNode parent, int[] childIndices) { - nodesChanged(parent, childIndices); - } - } - - private class NewChangesDispatcher implements ExternalProjectStructureChangeVisitor { - @Override public void visit(@NotNull GradleProjectRenameChange change) { processNewProjectRenameChange(change); } - @Override public void visit(@NotNull LanguageLevelChange change) { processNewLanguageLevelChange(change); } - @Override public void visit(@NotNull ModulePresenceChange change) { processNewModulePresenceChange(change); } - @Override public void visit(@NotNull ContentRootPresenceChange change) { processNewContentRootPresenceChange(change); } - @Override public void visit(@NotNull LibraryDependencyPresenceChange change) { processNewLibraryDependencyPresenceChange(change); } - @Override public void visit(@NotNull JarPresenceChange change) { processJarPresenceChange(change, false); } - @Override public void visit(@NotNull OutdatedLibraryVersionChange change) { processNewChangedLibraryVersionChange(change); } - @Override public void visit(@NotNull ModuleDependencyPresenceChange change) { processNewModuleDependencyPresenceChange(change); } - @Override public void visit(@NotNull DependencyScopeChange change) { processNewDependencyScopeChange(change); } - @Override public void visit(@NotNull DependencyExportedChange change) { processNewDependencyExportedChange(change); - } - } - - private class ObsoleteChangesDispatcher implements ExternalProjectStructureChangeVisitor { - @Override public void visit(@NotNull GradleProjectRenameChange change) { processObsoleteProjectRenameChange(change); } - @Override public void visit(@NotNull LanguageLevelChange change) { processObsoleteLanguageLevelChange(change); } - @Override public void visit(@NotNull ModulePresenceChange change) { processObsoleteModulePresenceChange(change); } - @Override public void visit(@NotNull ContentRootPresenceChange change) { processObsoleteContentRootPresenceChange(change); } - @Override public void visit(@NotNull LibraryDependencyPresenceChange change) { - processObsoleteLibraryDependencyPresenceChange(change); - } - @Override public void visit(@NotNull JarPresenceChange change) { processJarPresenceChange(change, true); } - @Override public void visit(@NotNull OutdatedLibraryVersionChange change) { processObsoleteChangedLibraryVersionChange(change); } - - @Override public void visit(@NotNull ModuleDependencyPresenceChange change) { - processObsoleteModuleDependencyPresenceChange(change); - } - @Override public void visit(@NotNull DependencyScopeChange change) { processObsoleteDependencyScopeChange(change); } - @Override public void visit(@NotNull DependencyExportedChange change) { processObsoleteDependencyExportedChange(change); } - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/ui/ProjectStructureNode.java b/platform/external-system/src/com/intellij/openapi/externalSystem/ui/ProjectStructureNode.java deleted file mode 100644 index 5c94e8aa9b51..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/ui/ProjectStructureNode.java +++ /dev/null @@ -1,349 +0,0 @@ -package com.intellij.openapi.externalSystem.ui; - -import com.intellij.openapi.editor.colors.TextAttributesKey; -import com.intellij.openapi.externalSystem.model.project.change.ExternalProjectStructureChange; -import com.intellij.openapi.externalSystem.model.project.id.ProjectEntityId; -import com.intellij.openapi.externalSystem.settings.ExternalSystemTextAttributes; -import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.containers.ContainerUtilRt; -import org.jetbrains.annotations.NotNull; - -import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.MutableTreeNode; -import java.util.*; - -/** - * Not thread-safe. - * - * @param type of the target entity {@link ProjectStructureNodeDescriptor#getElement() associated} with the current node - * @author Denis Zhdanov - * @since 8/23/11 3:50 PM - */ -public class ProjectStructureNode extends DefaultMutableTreeNode - implements Iterable> { - - private final Set myConflictChanges = ContainerUtilRt.newHashSet(); - private final List myListeners = ContainerUtil.createLockFreeCopyOnWriteList(); - - @NotNull private final Comparator> myComparator; - @NotNull private final ProjectStructureNodeDescriptor myDescriptor; - - private boolean mySkipNotification; - - /** - * Creates new ProjectStructureNode object with the given descriptor and 'compare-by-name' comparator. - * - * @param descriptor target node descriptor to use within the current node - */ - public ProjectStructureNode(@NotNull ProjectStructureNodeDescriptor descriptor) { - this(descriptor, new Comparator>() { - @Override - public int compare(ProjectStructureNode o1, ProjectStructureNode o2) { - return o1.getDescriptor().getName().compareTo(o2.getDescriptor().getName()); - } - }); - } - - /** - * Creates new ProjectStructureNode object with the given descriptor and comparator to use for organising child nodes. - * - * @param descriptor target node descriptor to use within the current node - * @param comparator comparator to use for organising child nodes of the current node - */ - public ProjectStructureNode(@NotNull ProjectStructureNodeDescriptor descriptor, - @NotNull Comparator> comparator) - { - super(descriptor); - myDescriptor = descriptor; - myComparator = comparator; - } - - @NotNull - public ProjectStructureNodeDescriptor getDescriptor() { - return myDescriptor; - } - - @Override - public ProjectStructureNode getChildAt(int index) { - return (ProjectStructureNode)super.getChildAt(index); - } - - @Override - public ProjectStructureNode getParent() { - return (ProjectStructureNode)super.getParent(); - } - - @Override - public void add(MutableTreeNode newChild) { - for (int i = 0; i < getChildCount(); i++) { - ProjectStructureNode node = getChildAt(i); - if (myComparator.compare((ProjectStructureNode)newChild, node) <= 0) { - insert(newChild, i); // Assuming that the node listeners are notified during the nested call. - return; - } - } - super.add(newChild); // Assuming that the node listeners are notified during the nested call to 'insert()'. - } - - @Override - public void insert(MutableTreeNode newChild, int childIndex) { - super.insert(newChild, childIndex); - onNodeAdded((ProjectStructureNode)newChild, childIndex); - } - - @Override - public void remove(int childIndex) { - final ProjectStructureNode child = getChildAt(childIndex); - super.remove(childIndex); - onNodeRemoved(child, childIndex); - } - - @Override - public void remove(MutableTreeNode aChild) { - boolean b = mySkipNotification; - mySkipNotification = true; - final int index = getIndex(aChild); - try { - super.remove(aChild); - } - finally { - mySkipNotification = b; - } - onNodeRemoved((ProjectStructureNode)aChild, index); - } - - /** - * Asks current node to ensure that given child node is at the 'right position' (according to the {@link #myComparator}. - *

- * Does nothing if given node is not a child of the current node. - * - * @param child target child node - * @return true if child position was changed; false otherwise - */ - public boolean correctChildPositionIfNecessary(@NotNull ProjectStructureNode child) { - int currentPosition = -1; - int desiredPosition = -1; - for (int i = 0; i < getChildCount(); i++) { - ProjectStructureNode node = getChildAt(i); - if (node == child) { - currentPosition = i; - continue; - } - if (desiredPosition < 0 && myComparator.compare(child, node) <= 0) { - desiredPosition = i; - if (currentPosition >= 0) { - break; - } - } - } - if (currentPosition < 0) { - // Given node is not a child of the current node. - return false; - } - if (desiredPosition < 0) { - desiredPosition = getChildCount(); - } - if (currentPosition < desiredPosition) { - desiredPosition--; - } - if (currentPosition == desiredPosition) { - return false; - } - remove(currentPosition); - insert(child, desiredPosition); - return true; - } - - /** - * Asks current module to ensure that its children are ordered in accordance with the {@link #myComparator pre-configured comparator}. - */ - @SuppressWarnings("unchecked") - public void sortChildren() { - List> nodes = new ArrayList>(children); - Collections.sort(nodes, myComparator); - if (nodes.equals(children)) { - return; - } - - mySkipNotification = true; - try { - removeAllChildren(); - for (ProjectStructureNode node : nodes) { - add(node); - } - } - finally { - mySkipNotification = false; - } - int[] indices = new int[nodes.size()]; - for (int i = 0; i < indices.length; i++) { - indices[i] = i; - } - onChildrenChange(indices); - } - - /** - * Registers given change within the given node assuming that it is - * {@link ExternalSystemTextAttributes#CHANGE_CONFLICT 'conflict change'}. We need to track number of such changes per-node because - * of the following possible situation: - *

-   * 
    - *
  1. There are two 'conflict changes' for particular node;
  2. - *
  3. - * One of those changes is resolved but the node still should be marked as 'conflict' because there is still one conflict change; - *
  4. - *
  5. The second conflict change is removed. The node should be marked as 'no change' now;
  6. - *
- *
- * - * @param change conflict change to register for the current node - */ - public void addConflictChange(@NotNull ExternalProjectStructureChange change) { - myConflictChanges.add(change); - if (myConflictChanges.size() != 1) { - return; - } - final TextAttributesKey key = myDescriptor.getAttributes(); - boolean localNode = key == ExternalSystemTextAttributes.EXTERNAL_SYSTEM_LOCAL_CHANGE || key == ExternalSystemTextAttributes.IDE_LOCAL_CHANGE; - if (!localNode) { - myDescriptor.setAttributes(ExternalSystemTextAttributes.CHANGE_CONFLICT); - onNodeChanged(this); - } - } - - @NotNull - public Set getConflictChanges() { - return myConflictChanges; - } - - /** - * Performs reverse operation to {@link #addConflictChange(ExternalProjectStructureChange)}. - * - * @param change conflict change to de-register from the current node - */ - public void removeConflictChange(@NotNull ExternalProjectStructureChange change) { - myConflictChanges.remove(change); - if (myConflictChanges.isEmpty()) { - myDescriptor.setAttributes(ExternalSystemTextAttributes.NO_CHANGE); - onNodeChanged(this); - } - } - - /** - * Allows to query current node for all children that are associated with the entity of the given type. - * - * @param clazz target entity type - * @param target entity type - * @return all children nodes that are associated with the entity of the given type if any; - * empty collection otherwise - */ - @SuppressWarnings("unchecked") - @NotNull - public Collection> getChildren(@NotNull Class clazz) { - List> result = null; - for (int i = 0; i < getChildCount(); i++) { - final ProjectStructureNode child = getChildAt(i); - final Object element = child.getDescriptor().getElement(); - if (!clazz.isInstance(element)) { - continue; - } - if (result == null) { - result = new ArrayList>(); - } - result.add((ProjectStructureNode)child); - } - if (result == null) { - result = Collections.emptyList(); - } - return result; - } - - @NotNull - @Override - public Iterator> iterator() { - return new Iterator>() { - - private int i; - - @Override - public boolean hasNext() { - return i < getChildCount(); - } - - @Override - public ProjectStructureNode next() { - return getChildAt(i++); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - }; - } - - public void setAttributes(@NotNull TextAttributesKey key) { - myDescriptor.setAttributes(key); - final ProjectStructureNode parent = getParent(); - if (parent == null) { - onNodeChanged(this); - return; - } - boolean positionChanged = parent.correctChildPositionIfNecessary(this); - if (!positionChanged) { - onNodeChanged(this); - } - } - - public void addListener(@NotNull Listener listener) { - myListeners.add(listener); - } - - private void onNodeAdded(@NotNull ProjectStructureNode node, int index) { - if (mySkipNotification) { - return; - } - for (Listener listener : myListeners) { - listener.onNodeAdded(node, index); - } - } - - private void onNodeRemoved(@NotNull ProjectStructureNode node, int removedChildIndex) { - if (mySkipNotification) { - return; - } - for (Listener listener : myListeners) { - listener.onNodeRemoved(this, node, removedChildIndex); - } - } - - private void onNodeChanged(@NotNull ProjectStructureNode node) { - if (mySkipNotification) { - return; - } - for (Listener listener : myListeners) { - listener.onNodeChanged(node); - } - } - - private void onChildrenChange(@NotNull int[] indices) { - if (mySkipNotification) { - return; - } - for (Listener listener : myListeners) { - listener.onNodeChildrenChanged(this, indices); - } - } - - public interface Listener { - void onNodeAdded(@NotNull ProjectStructureNode node, int index); - - void onNodeRemoved(@NotNull ProjectStructureNode parent, - @NotNull ProjectStructureNode removedChild, - int removedChildIndex); - - void onNodeChanged(@NotNull ProjectStructureNode node); - - void onNodeChildrenChanged(@NotNull ProjectStructureNode parent, int[] childIndices); - } -} diff --git a/platform/external-system/src/com/intellij/openapi/externalSystem/ui/ProjectStructureNodeDescriptor.java b/platform/external-system/src/com/intellij/openapi/externalSystem/ui/ProjectStructureNodeDescriptor.java deleted file mode 100644 index f7758bfd5f7c..000000000000 --- a/platform/external-system/src/com/intellij/openapi/externalSystem/ui/ProjectStructureNodeDescriptor.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.intellij.openapi.externalSystem.ui; - -import com.intellij.ide.projectView.PresentationData; -import com.intellij.ide.util.treeView.PresentableNodeDescriptor; -import com.intellij.openapi.editor.colors.TextAttributesKey; -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.id.ProjectEntityId; -import com.intellij.openapi.externalSystem.settings.ExternalSystemTextAttributes; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import javax.swing.*; - -/** - * Descriptor for the node of 'project structure view' derived from gradle. - *

- * Not thread-safe. - * - * @author Denis Zhdanov - * @since 8/12/11 2:47 PM - * @param target element type - */ -public class ProjectStructureNodeDescriptor extends PresentableNodeDescriptor { - - private TextAttributesKey myAttributes = ExternalSystemTextAttributes.NO_CHANGE; - - private final T myId; - - @SuppressWarnings("NullableProblems") - public ProjectStructureNodeDescriptor(@NotNull T id, @NotNull String text, @Nullable Icon icon) { - super(null, null); - myId = id; - setIcon(icon); - myName = text; - } - - @Override - protected void update(@NotNull PresentationData presentation) { - presentation.setAttributesKey(myAttributes); - presentation.setPresentableText(myName); - presentation.setIcon(getIcon()); - } - - @NotNull - @Override - public T getElement() { - return myId; - } - - public void setName(@NotNull String name) { - myName = name; - } - - @NotNull - public TextAttributesKey getAttributes() { - return myAttributes; - } - - public void setAttributes(@NotNull TextAttributesKey attributes) { - myAttributes = attributes; - if (attributes == ExternalSystemTextAttributes.NO_CHANGE || attributes == ExternalSystemTextAttributes.IDE_LOCAL_CHANGE) { - myId.setOwner(ProjectSystemId.IDE); - } - update(); - } - - public void setToolTip(@NotNull String text) { - getTemplatePresentation().setTooltip(text); - update(); - } -} diff --git a/platform/platform-resources/src/META-INF/ExternalSystemExtensions.xml b/platform/platform-resources/src/META-INF/ExternalSystemExtensions.xml index b9fc50b6b8c9..fab5a6a62530 100644 --- a/platform/platform-resources/src/META-INF/ExternalSystemExtensions.xml +++ b/platform/platform-resources/src/META-INF/ExternalSystemExtensions.xml @@ -17,9 +17,7 @@ - - diff --git a/plugins/gradle/gradle.iml b/plugins/gradle/gradle.iml index daa6aa3e8091..a7b46ec7c4d6 100644 --- a/plugins/gradle/gradle.iml +++ b/plugins/gradle/gradle.iml @@ -279,7 +279,8 @@ - + + diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/GradleManager.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/GradleManager.java index a920ed8858e1..7aa890fe81fc 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/GradleManager.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/GradleManager.java @@ -17,17 +17,20 @@ package org.jetbrains.plugins.gradle; import com.intellij.execution.ExecutionException; import com.intellij.execution.configurations.SimpleJavaParameters; +import com.intellij.externalSystem.JavaProjectData; import com.intellij.openapi.application.PathManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.externalSystem.ExternalSystemManager; import com.intellij.openapi.externalSystem.build.ExternalSystemBuildManager; import com.intellij.openapi.externalSystem.model.ProjectSystemId; import com.intellij.openapi.externalSystem.service.project.ExternalSystemProjectResolver; +import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil; import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.NotNullLazyValue; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.Function; +import com.intellij.util.PathUtil; import com.intellij.util.containers.ContainerUtilRt; import org.gradle.tooling.ProjectConnection; import org.jetbrains.annotations.NotNull; @@ -68,7 +71,7 @@ public class GradleManager protected List compute() { List result = ContainerUtilRt.newArrayList(); Collections.addAll(result, GradleProjectResolverExtension.EP_NAME.getExtensions()); - ExternalSystemUtil.orderAwareSort(result); + ExternalSystemApiUtil.orderAwareSort(result); return result; } }; @@ -173,6 +176,11 @@ public class GradleManager parameters.getClassPath().add(new File(gradleJarsDir, jar).getAbsolutePath()); } + String path = PathUtil.getJarPathForClass(JavaProjectData.class); + if (!StringUtil.isEmpty(path)) { + parameters.getClassPath().add(path); + } + for (GradleProjectResolverExtension extension : RESOLVER_EXTENSIONS.getValue()) { extension.enhanceParameters(parameters); } diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/action/AbstractGradleSyncTreeFilterAction.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/action/AbstractGradleSyncTreeFilterAction.java deleted file mode 100644 index bd558c8f5c0b..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/action/AbstractGradleSyncTreeFilterAction.java +++ /dev/null @@ -1,122 +0,0 @@ -package org.jetbrains.plugins.gradle.action; - -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.PlatformDataKeys; -import com.intellij.openapi.actionSystem.ToggleAction; -import com.intellij.openapi.editor.colors.EditorColorsListener; -import com.intellij.openapi.editor.colors.EditorColorsManager; -import com.intellij.openapi.editor.colors.EditorColorsScheme; -import com.intellij.openapi.editor.colors.TextAttributesKey; -import com.intellij.openapi.externalSystem.ui.ExternalProjectStructureNodeFilter; -import com.intellij.openapi.options.colors.AttributesDescriptor; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.util.ui.ColorIcon; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.plugins.gradle.settings.GradleSettings; -import com.intellij.openapi.externalSystem.ui.ExternalProjectStructureTreeModel; -import com.intellij.openapi.externalSystem.ui.ProjectStructureNode; -import org.jetbrains.plugins.gradle.util.GradleUtil; - -import javax.swing.*; -import java.awt.*; - -/** - * @author Denis Zhdanov - * @since 3/7/12 3:48 PM - */ -public abstract class AbstractGradleSyncTreeFilterAction extends ToggleAction { - - @NotNull private final ExternalProjectStructureNodeFilter myFilter; - @NotNull private final TextAttributesKey myAttributesKey; - - private Color myColor; - private boolean myIconChanged; - - protected AbstractGradleSyncTreeFilterAction(@NotNull AttributesDescriptor descriptor) { - myFilter = createFilter(descriptor.getKey()); - myAttributesKey = descriptor.getKey(); - getTemplatePresentation().setText(descriptor.getDisplayName()); - updateIcon(EditorColorsManager.getInstance().getGlobalScheme()); - EditorColorsManager.getInstance().addEditorColorsListener(new EditorColorsListener() { - @Override - public void globalSchemeChange(EditorColorsScheme scheme) { - updateIcon(scheme); - } - }); - } - - @Override - public boolean isSelected(AnActionEvent e) { - final ExternalProjectStructureTreeModel model = GradleUtil.getProjectStructureTreeModel(e.getDataContext()); - if (model == null) { - return false; - } - - return model.hasFilter(myFilter); - } - - @Override - public void setSelected(AnActionEvent e, boolean state) { - final ExternalProjectStructureTreeModel treeModel = GradleUtil.getProjectStructureTreeModel(e.getDataContext()); - if (treeModel == null) { - return; - } - if (state) { - treeModel.addFilter(myFilter); - } - else { - treeModel.removeFilter(myFilter); - } - } - - @Override - public void update(AnActionEvent e) { - super.update(e); - - final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext()); - if (project == null || StringUtil.isEmpty(GradleSettings.getInstance(project).getLinkedExternalProjectPath())) { - e.getPresentation().setEnabled(false); - return; - } - else { - e.getPresentation().setEnabled(true); - } - - if (myIconChanged) { - e.getPresentation().setIcon(getTemplatePresentation().getIcon()); - myIconChanged = false; - } - } - - public static ExternalProjectStructureNodeFilter createFilter(@NotNull TextAttributesKey key) { - return new MyFilter(key); - } - - private void updateIcon(@Nullable EditorColorsScheme scheme) { - if (scheme == null) { - return; - } - final Color color = scheme.getAttributes(myAttributesKey).getForegroundColor(); - if (color != null && !color.equals(myColor)) { - getTemplatePresentation().setIcon(new ColorIcon(new JLabel("").getFont().getSize(), color)); - myColor = color; - myIconChanged = true; - } - } - - private static class MyFilter implements ExternalProjectStructureNodeFilter { - - @NotNull private final TextAttributesKey myKey; - - MyFilter(@NotNull TextAttributesKey key) { - myKey = key; - } - - @Override - public boolean isVisible(@NotNull ProjectStructureNode node) { - return myKey.equals(node.getDescriptor().getAttributes()); - } - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/action/AbstractGradleSyncTreeNodeAction.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/action/AbstractGradleSyncTreeNodeAction.java deleted file mode 100644 index 04746230c28b..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/action/AbstractGradleSyncTreeNodeAction.java +++ /dev/null @@ -1,119 +0,0 @@ -package org.jetbrains.plugins.gradle.action; - -import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.PlatformDataKeys; -import com.intellij.openapi.actionSystem.Presentation; -import com.intellij.openapi.components.ServiceManager; -import com.intellij.openapi.editor.colors.TextAttributesKey; -import com.intellij.openapi.externalSystem.model.ExternalSystemDataKeys; -import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskType; -import com.intellij.openapi.externalSystem.ui.ProjectStructureNode; -import com.intellij.openapi.project.Project; -import com.intellij.ui.treeStructure.Tree; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import com.intellij.openapi.externalSystem.service.task.ExternalSystemTaskManager; -import org.jetbrains.plugins.gradle.util.GradleConstants; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -/** - * Common super class for actions that are invoked on 'sync project structures' tree nodes. - *

- * Not thread-safe. - * - * @author Denis Zhdanov - * @since 2/29/12 4:15 PM - */ -public abstract class AbstractGradleSyncTreeNodeAction extends AnAction { - - private static final Map HELPERS = new HashMap(); - static { - HELPERS.put(GradleConstants.SYNC_TREE_CONTEXT_MENU_PLACE, new ContextMenuHelper()); - } - - @SuppressWarnings("unchecked") - @Override - public void update(AnActionEvent e) { - final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext()); - final Helper helper = HELPERS.get(e.getPlace()); - if (project == null || helper == null) { - e.getPresentation().setEnabled(false); - e.getPresentation().setVisible(false); - return; - } - Collection> nodes = helper.getTargetNodes(e); - if (nodes != null) { - filterNodes(nodes); - } - helper.updatePresentation(nodes, e.getPresentation()); - if (e.getPresentation().isEnabled()) { - final ExternalSystemTaskManager taskManager = ServiceManager.getService(ExternalSystemTaskManager.class); - if (taskManager != null && taskManager.hasTaskOfTypeInProgress(ExternalSystemTaskType.RESOLVE_PROJECT)) { - e.getPresentation().setEnabled(false); - } - } - } - - @Override - public void actionPerformed(AnActionEvent e) { - final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext()); - final Helper helper = HELPERS.get(e.getPlace()); - if (project == null || helper == null) { - return; - } - final Collection> nodes = helper.getTargetNodes(e); - if (nodes != null) { - filterNodes(nodes); - } - if (nodes == null || nodes.isEmpty()) { - return; - } - final Tree tree = ExternalSystemDataKeys.PROJECT_TREE.getData(e.getDataContext()); - if (tree != null) { - doActionPerformed(nodes, project, tree); - } - } - - protected abstract void doActionPerformed(@NotNull Collection> nodes, - @NotNull Project project, - @NotNull Tree tree); - - protected void filterNodes(@NotNull Collection> nodes) { - } - - protected static void filterNodesByAttributes(@NotNull Collection> nodes, @NotNull TextAttributesKey key) { - for (Iterator> iterator = nodes.iterator(); iterator.hasNext(); ) { - ProjectStructureNode node = iterator.next(); - if (!key.equals(node.getDescriptor().getAttributes())) { - iterator.remove(); - } - } - } - - private interface Helper { - - @Nullable - Collection> getTargetNodes(@NotNull AnActionEvent e); - - void updatePresentation(@Nullable Collection> nodes, @NotNull Presentation presentation); - } - - private static class ContextMenuHelper implements Helper { - @Nullable - @Override - public Collection> getTargetNodes(@NotNull AnActionEvent e) { - return ExternalSystemDataKeys.PROJECT_TREE_SELECTED_NODE.getData(e.getDataContext()); - } - - @Override - public void updatePresentation(@Nullable Collection> nodes, @NotNull Presentation presentation) { - presentation.setVisible(true); - presentation.setEnabled(nodes != null && !nodes.isEmpty()); - } - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleConflictSyncTreeFilterAction.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleConflictSyncTreeFilterAction.java deleted file mode 100644 index 49c1f906c43b..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleConflictSyncTreeFilterAction.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.jetbrains.plugins.gradle.action; - -import org.jetbrains.plugins.gradle.config.GradleColorAndFontDescriptorsProvider; - -/** - * @author Denis Zhdanov - * @since 3/7/12 6:08 PM - */ -public class GradleConflictSyncTreeFilterAction extends AbstractGradleSyncTreeFilterAction { - - public GradleConflictSyncTreeFilterAction() { - super(GradleColorAndFontDescriptorsProvider.CONFLICT); - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleImportEntityAction.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleImportEntityAction.java deleted file mode 100644 index dd4c4cd3de0e..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleImportEntityAction.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.jetbrains.plugins.gradle.action; - -import com.intellij.openapi.components.ServiceManager; -import com.intellij.openapi.externalSystem.settings.ExternalSystemTextAttributes; -import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; -import com.intellij.openapi.project.Project; -import com.intellij.ui.treeStructure.Tree; -import org.jetbrains.annotations.NotNull; -import com.intellij.openapi.externalSystem.service.project.manage.GradleLocalNodeManageHelper; -import com.intellij.openapi.externalSystem.ui.ProjectStructureNode; - -import java.util.Collection; - -/** - * Imports target {@link ExternalSystemTextAttributes#EXTERNAL_SYSTEM_LOCAL_CHANGE 'gradle local'} entity to the current intellij project. - *

- * Not thread-safe. - * - * @author Denis Zhdanov - * @since 2/7/12 10:32 AM - */ -public class GradleImportEntityAction extends AbstractGradleSyncTreeNodeAction { - - public GradleImportEntityAction() { - // TODO den implement -// getTemplatePresentation().setText(ExternalSystemBundle.message("gradle.action.import.entity.text")); -// getTemplatePresentation().setDescription(ExternalSystemBundle.message("gradle.action.import.entity.description")); - } - - @Override - protected void filterNodes(@NotNull Collection> nodes) { - filterNodesByAttributes(nodes, ExternalSystemTextAttributes.EXTERNAL_SYSTEM_LOCAL_CHANGE); - } - - @Override - protected void doActionPerformed(@NotNull Collection> nodes, @NotNull Project project, @NotNull Tree tree) { - final GradleLocalNodeManageHelper helper = ServiceManager.getService(project, GradleLocalNodeManageHelper.class); - // TODO den implement -// helper.importNodes(nodes); - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleLinkToProjectAction.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleLinkToProjectAction.java deleted file mode 100644 index 5ae550c1a807..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleLinkToProjectAction.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.jetbrains.plugins.gradle.action; - -import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.PlatformDataKeys; -import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; -import com.intellij.openapi.fileChooser.FileChooser; -import com.intellij.openapi.project.DumbAware; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.vfs.VirtualFile; -import org.jetbrains.plugins.gradle.settings.GradleSettings; -import org.jetbrains.plugins.gradle.util.GradleUtil; - -/** - * Allows to link gradle project to the current IntelliJ IDEA project. - *

- * Not thread-safe. - * - * @author Denis Zhdanov - * @since 12/26/11 5:09 PM - */ -public class GradleLinkToProjectAction extends AnAction implements DumbAware { - - public GradleLinkToProjectAction() { - // TODO den implement -// getTemplatePresentation().setText(ExternalSystemBundle.message("gradle.action.link.project.text")); -// getTemplatePresentation().setDescription(ExternalSystemBundle.message("gradle.action.link.project.description")); -// getTemplatePresentation().setText(ExternalSystemBundle.message("gradle.toolwindow.linked.action.text")); - } - - @Override - public void actionPerformed(AnActionEvent e) { - final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext()); - if (project == null) { - return; - } - final VirtualFile file = FileChooser.chooseFile(GradleUtil.getGradleProjectFileChooserDescriptor(), project, null); - if (file == null) { - return; - } - // TODO den implement -// GradleSettings.applyLinkedProjectPath(file.getPath(), project); - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleLocalSyncTreeFilterAction.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleLocalSyncTreeFilterAction.java deleted file mode 100644 index 3ff4ff6cfdb6..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleLocalSyncTreeFilterAction.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.jetbrains.plugins.gradle.action; - -import org.jetbrains.plugins.gradle.config.GradleColorAndFontDescriptorsProvider; - -/** - * @author Denis Zhdanov - * @since 3/7/12 3:54 PM - */ -public class GradleLocalSyncTreeFilterAction extends AbstractGradleSyncTreeFilterAction { - - public GradleLocalSyncTreeFilterAction() { - super(GradleColorAndFontDescriptorsProvider.GRADLE_LOCAL); - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleOutdatedSyncTreeFilterAction.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleOutdatedSyncTreeFilterAction.java deleted file mode 100644 index cc41ab073df9..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleOutdatedSyncTreeFilterAction.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.plugins.gradle.action; - -import org.jetbrains.plugins.gradle.config.GradleColorAndFontDescriptorsProvider; - -/** - * @author Denis Zhdanov - * @since 1/23/13 9:47 AM - */ -public class GradleOutdatedSyncTreeFilterAction extends AbstractGradleSyncTreeFilterAction { - - public GradleOutdatedSyncTreeFilterAction() { - super(GradleColorAndFontDescriptorsProvider.OUTDATED_ENTITY); - } -} \ No newline at end of file diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleRebuildStructureChangesTreeAction.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleRebuildStructureChangesTreeAction.java deleted file mode 100644 index 2e6d647a0f14..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleRebuildStructureChangesTreeAction.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.jetbrains.plugins.gradle.action; - -import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; -import com.intellij.openapi.externalSystem.ui.ExternalProjectStructureTreeModel; -import org.jetbrains.plugins.gradle.util.GradleUtil; - -/** - * @author Denis Zhdanov - * @since 3/15/12 11:23 AM - */ -public class GradleRebuildStructureChangesTreeAction extends AnAction { - - public GradleRebuildStructureChangesTreeAction() { - getTemplatePresentation().setText(ExternalSystemBundle.message("gradle.action.rebuild.sync.tree.text")); - getTemplatePresentation().setDescription(ExternalSystemBundle.message("gradle.action.rebuild.sync.tree.description")); - } - - @Override - public void actionPerformed(AnActionEvent e) { - final ExternalProjectStructureTreeModel model = GradleUtil.getProjectStructureTreeModel(e.getDataContext()); - if (model != null) { - model.rebuild(); - } - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleRefreshProjectAction.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleRefreshProjectAction.java index 4d297d135d25..f92ca083fd87 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleRefreshProjectAction.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleRefreshProjectAction.java @@ -14,7 +14,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.plugins.gradle.settings.GradleSettings; import com.intellij.openapi.externalSystem.service.task.ExternalSystemTaskManager; import org.jetbrains.plugins.gradle.notification.GradleConfigNotificationManager; -import com.intellij.openapi.externalSystem.ui.ExternalProjectStructureTreeModel; import org.jetbrains.plugins.gradle.util.GradleConstants; import org.jetbrains.plugins.gradle.util.GradleUtil; @@ -40,10 +39,11 @@ public class GradleRefreshProjectAction extends AbstractGradleLinkedProjectActio protected void doUpdate(@NotNull AnActionEvent event, @NotNull Project project, @NotNull String linkedProjectPath) { String message = myErrorMessage.get(); if (message != null) { - ExternalProjectStructureTreeModel model = GradleUtil.getProjectStructureTreeModel(event.getDataContext()); - if (model != null) { - model.rebuild(); - } + // TODO den implement +// ExternalProjectStructureTreeModel model = GradleUtil.getProjectStructureTreeModel(event.getDataContext()); +// if (model != null) { +// model.rebuild(); +// } GradleConfigNotificationManager notificationManager = ServiceManager.getService(project, GradleConfigNotificationManager.class); notificationManager.processRefreshError(message); myErrorMessage.set(null); diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleRemoveIdeEntityAction.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleRemoveIdeEntityAction.java deleted file mode 100644 index 6ec10e3e28ad..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleRemoveIdeEntityAction.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.jetbrains.plugins.gradle.action; - -import com.intellij.openapi.components.ServiceManager; -import com.intellij.openapi.externalSystem.settings.ExternalSystemTextAttributes; -import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; -import com.intellij.openapi.project.Project; -import com.intellij.ui.treeStructure.Tree; -import org.jetbrains.annotations.NotNull; -import com.intellij.openapi.externalSystem.service.project.manage.GradleLocalNodeManageHelper; -import com.intellij.openapi.externalSystem.ui.ProjectStructureNode; - -import java.util.Collection; - -/** - * Allows to remove IDE entity (module, dependency, content root etc). Convenient to use when project structure tree is configured - * to show only IDE-local changes and we want to remove them all. - * - * @author Denis Zhdanov - * @since 11/17/12 3:01 PM - */ -public class GradleRemoveIdeEntityAction extends AbstractGradleSyncTreeNodeAction { - - public GradleRemoveIdeEntityAction() { - // TODO den implement -// getTemplatePresentation().setText(ExternalSystemBundle.message("gradle.action.remove.entity.text")); -// getTemplatePresentation().setDescription(ExternalSystemBundle.message("gradle.action.remove.entity.description")); - } - - @Override - protected void filterNodes(@NotNull Collection> nodes) { - filterNodesByAttributes(nodes, ExternalSystemTextAttributes.IDE_LOCAL_CHANGE); - } - - @Override - protected void doActionPerformed(@NotNull Collection> nodes, @NotNull Project project, @NotNull Tree tree) { - final GradleLocalNodeManageHelper helper = ServiceManager.getService(project, GradleLocalNodeManageHelper.class); - // TODO den implement -// helper.removeNodes(nodes); - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleResetTreeFiltersAction.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleResetTreeFiltersAction.java deleted file mode 100644 index c51b67407a13..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleResetTreeFiltersAction.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.jetbrains.plugins.gradle.action; - -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.ToggleAction; -import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; -import com.intellij.openapi.externalSystem.ui.ExternalProjectStructureTreeModel; -import org.jetbrains.plugins.gradle.util.GradleUtil; -import org.jetbrains.plugins.gradle.util.TextIcon; - -/** - * @author Denis Zhdanov - * @since 11/22/12 7:27 PM - */ -public class GradleResetTreeFiltersAction extends ToggleAction { - - public GradleResetTreeFiltersAction() { - getTemplatePresentation().setText(ExternalSystemBundle.message("gradle.action.reset.tree.filters.text")); - getTemplatePresentation().setDescription(ExternalSystemBundle.message("gradle.action.reset.tree.filters.description")); - getTemplatePresentation().setIcon(new TextIcon(ExternalSystemBundle.message("gradle.action.reset.tree.filters.icon"))); - } - - @Override - public boolean isSelected(AnActionEvent e) { - final ExternalProjectStructureTreeModel model = GradleUtil.getProjectStructureTreeModel(e.getDataContext()); - return model == null || !model.hasAnyFilter(); - } - - @Override - public void setSelected(AnActionEvent e, boolean state) { - final ExternalProjectStructureTreeModel treeModel = GradleUtil.getProjectStructureTreeModel(e.getDataContext()); - if (treeModel != null) { - treeModel.removeAllFilters(); - } - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleShowConflictDetailsAction.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleShowConflictDetailsAction.java deleted file mode 100644 index a83ee30023e3..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleShowConflictDetailsAction.java +++ /dev/null @@ -1,93 +0,0 @@ -package org.jetbrains.plugins.gradle.action; - -import com.intellij.codeInsight.hint.HintManager; -import com.intellij.openapi.components.ServiceManager; -import com.intellij.openapi.externalSystem.service.project.ProjectStructureServices; -import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.popup.Balloon; -import com.intellij.openapi.ui.popup.JBPopupAdapter; -import com.intellij.openapi.ui.popup.JBPopupFactory; -import com.intellij.openapi.ui.popup.LightweightWindowEvent; -import com.intellij.ui.awt.RelativePoint; -import com.intellij.ui.treeStructure.Tree; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.plugins.gradle.sync.conflict.GradleConflictControlFactory; -import com.intellij.openapi.externalSystem.ui.ProjectStructureNode; -import org.jetbrains.plugins.gradle.ui.GradleUiListener; -import org.jetbrains.plugins.gradle.util.GradleUtil; - -import javax.swing.*; -import java.awt.*; -import java.util.Collection; - -/** - * There is a possible case that particular project structure entity has conflicting setup at the gradle and intellij - * (e.g. particular library contains one set of binaries at the gradle and another one at the intellij). We want to - * show the conflict and allow to resolve it then. This action is a trigger mechanism for that. - *

- * Not thread-safe. - * - * @author Denis Zhdanov - * @since 3/2/12 2:43 PM - */ -public class GradleShowConflictDetailsAction extends AbstractGradleSyncTreeNodeAction { - - public GradleShowConflictDetailsAction() { - // TODO den implement -// getTemplatePresentation().setText(ExternalSystemBundle.message("gradle.action.show.conflict.text")); -// getTemplatePresentation().setDescription(ExternalSystemBundle.message("gradle.action.show.conflict.description")); - } - - @Override - protected void filterNodes(@NotNull Collection> nodes) { - if (nodes.size() != 1) { - // Don't provide details if more than one node is selected - nodes.clear(); - return; - } - final ProjectStructureNode node = nodes.iterator().next(); - if (node.getConflictChanges().isEmpty()) { - nodes.clear(); - } - } - - @Override - protected void doActionPerformed(@NotNull Collection> nodes, @NotNull final Project project, @NotNull Tree tree) { - assert nodes.size() == 1; - final ProjectStructureNode node = nodes.iterator().next(); - final ProjectStructureServices context = ServiceManager.getService(project, ProjectStructureServices.class); - // TODO den implement - final Object entity = null; -// final Object entity = node.getDescriptor().getElement().mapToEntity(context); - if (entity == null) { - return; - } - - final HintManager hintManager = HintManager.getInstance(); - hintManager.hideAllHints(); - - final GradleConflictControlFactory factory = ServiceManager.getService(GradleConflictControlFactory.class); - JComponent control = factory.getDiffControl(entity, node.getConflictChanges()); - if (control == null) { - return; - } - final Point hintPosition = GradleUtil.getHintPosition(node, tree); - if (hintPosition == null) { - return; - } - final Balloon balloon = JBPopupFactory.getInstance().createBalloonBuilder(control).setDisposable(project) - .setFillColor(tree.getBackground()).createBalloon(); - final GradleUiListener publisher = project.getMessageBus().syncPublisher(GradleUiListener.TOPIC); - publisher.beforeConflictUiShown(); - balloon.addListener(new JBPopupAdapter() { - @Override - public void onClosed(LightweightWindowEvent event) { - if (!project.isDisposed()) { - publisher.afterConflictUiShown(); - } - } - }); - balloon.show(new RelativePoint(tree, hintPosition), Balloon.Position.below); - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleSyncAction.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleSyncAction.java deleted file mode 100644 index 45ca79a72e60..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleSyncAction.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.plugins.gradle.action; - -import com.intellij.openapi.components.ServiceManager; -import com.intellij.openapi.editor.colors.TextAttributesKey; -import com.intellij.openapi.externalSystem.model.project.change.ExternalProjectStructureChange; -import com.intellij.openapi.externalSystem.service.project.manage.EntityManageHelper; -import com.intellij.openapi.externalSystem.service.project.manage.OutdatedLibraryService; -import com.intellij.openapi.externalSystem.settings.ExternalSystemTextAttributes; -import com.intellij.openapi.externalSystem.ui.ProjectStructureNode; -import com.intellij.openapi.project.Project; -import com.intellij.ui.treeStructure.Tree; -import com.intellij.util.containers.ContainerUtilRt; -import org.jetbrains.annotations.NotNull; - -import java.util.*; - -/** - * @author Denis Zhdanov - * @since 1/23/13 11:13 AM - */ -public class GradleSyncAction extends AbstractGradleSyncTreeNodeAction { - - public GradleSyncAction() { - // TODO den implement -// getTemplatePresentation().setText(ExternalSystemBundle.message("gradle.action.sync.text")); -// getTemplatePresentation().setDescription(ExternalSystemBundle.message("gradle.action.sync.description")); - } - - @Override - protected void filterNodes(@NotNull Collection> nodes) { - for (Iterator> iterator = nodes.iterator(); iterator.hasNext(); ) { - ProjectStructureNode node = iterator.next(); - TextAttributesKey attributes = node.getDescriptor().getAttributes(); - if (!ExternalSystemTextAttributes.OUTDATED_ENTITY.equals(attributes) && node.getConflictChanges().isEmpty()) { - iterator.remove(); - } - } - } - - @Override - protected void doActionPerformed(@NotNull Collection> nodes, @NotNull Project project, @NotNull Tree tree) { - OutdatedLibraryService manager = ServiceManager.getService(project, OutdatedLibraryService.class); - EntityManageHelper helper = ServiceManager.getService(project, EntityManageHelper.class); - - List> outdatedLibraryNodes = ContainerUtilRt.newArrayList(); - Set conflictChanges = ContainerUtilRt.newHashSet(); - for (ProjectStructureNode node : nodes) { - if (ExternalSystemTextAttributes.OUTDATED_ENTITY.equals(node.getDescriptor().getAttributes())) { - outdatedLibraryNodes.add(node); - } - conflictChanges.addAll(node.getConflictChanges()); - } - - // TODO den implement -// if (!outdatedLibraryNodes.isEmpty()) { -// manager.sync(nodes); -// } -// if (!conflictChanges.isEmpty()) { -// helper.eliminateChange(conflictChanges, Collections.emptySet(), true); -// } - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/action/IntellijLocalSyncTreeFilterAction.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/action/IntellijLocalSyncTreeFilterAction.java deleted file mode 100644 index 4a95797a88c1..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/action/IntellijLocalSyncTreeFilterAction.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.jetbrains.plugins.gradle.action; - -import org.jetbrains.plugins.gradle.config.GradleColorAndFontDescriptorsProvider; - -/** - * @author Denis Zhdanov - * @since 3/7/12 3:59 PM - */ -public class IntellijLocalSyncTreeFilterAction extends AbstractGradleSyncTreeFilterAction { - - public IntellijLocalSyncTreeFilterAction() { - super(GradleColorAndFontDescriptorsProvider.INTELLIJ_LOCAL); - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorAndFontDescriptorsProvider.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorAndFontDescriptorsProvider.java deleted file mode 100644 index b425607e8dd0..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorAndFontDescriptorsProvider.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.jetbrains.plugins.gradle.config; - -import com.intellij.openapi.externalSystem.settings.ExternalSystemTextAttributes; -import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; -import com.intellij.openapi.options.colors.AttributesDescriptor; -import com.intellij.openapi.options.colors.ColorAndFontDescriptorsProvider; -import com.intellij.openapi.options.colors.ColorDescriptor; -import org.jetbrains.annotations.NotNull; - -/** - * Provides support for defining gradle-specific color settings. - *

- * Not thread-safe. - * - * @author Denis Zhdanov - * @since 1/18/12 4:15 PM - */ -public class GradleColorAndFontDescriptorsProvider implements ColorAndFontDescriptorsProvider { - - public static final AttributesDescriptor CONFLICT = new AttributesDescriptor( - ExternalSystemBundle.message("gradle.sync.change.type.conflict"), - ExternalSystemTextAttributes.CHANGE_CONFLICT - ); - - public static final AttributesDescriptor GRADLE_LOCAL = new AttributesDescriptor( - ExternalSystemBundle.message("gradle.sync.change.type.gradle"), - ExternalSystemTextAttributes.EXTERNAL_SYSTEM_LOCAL_CHANGE - ); - - public static final AttributesDescriptor INTELLIJ_LOCAL = new AttributesDescriptor( - ExternalSystemBundle.message("gradle.sync.change.type.intellij"), - //GradleBundle.message("gradle.sync.change.type.intellij", ApplicationNamesInfo.getInstance().getProductName()), - ExternalSystemTextAttributes.IDE_LOCAL_CHANGE - ); - - public static final AttributesDescriptor OUTDATED_ENTITY = new AttributesDescriptor( - ExternalSystemBundle.message("gradle.sync.change.type.changed.library.version"), - //GradleBundle.message("gradle.sync.change.type.intellij", ApplicationNamesInfo.getInstance().getProductName()), - ExternalSystemTextAttributes.OUTDATED_ENTITY - ); - - public static final AttributesDescriptor NO_CHANGE = new AttributesDescriptor( - ExternalSystemBundle.message("gradle.sync.change.type.unchanged"), - ExternalSystemTextAttributes.NO_CHANGE - ); - - public static final AttributesDescriptor[] DESCRIPTORS = { - CONFLICT, GRADLE_LOCAL, INTELLIJ_LOCAL, OUTDATED_ENTITY, NO_CHANGE - }; - - @NotNull - @Override - public String getDisplayName() { - return ExternalSystemBundle.message("gradle.name"); - } - - @NotNull - @Override - public AttributesDescriptor[] getAttributeDescriptors() { - return DESCRIPTORS; - } - - @NotNull - @Override - public ColorDescriptor[] getColorDescriptors() { - return new ColorDescriptor[0]; - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorAndFontPanelFactory.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorAndFontPanelFactory.java deleted file mode 100644 index f53892c5aa81..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorAndFontPanelFactory.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.jetbrains.plugins.gradle.config; - -import com.intellij.application.options.colors.*; -import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; -import com.intellij.psi.codeStyle.DisplayPriority; -import org.jetbrains.annotations.NotNull; - -/** - * @author Denis Zhdanov - * @since 1/19/12 11:32 AM - */ -public class GradleColorAndFontPanelFactory implements ColorAndFontPanelFactoryEx { - - @NotNull - @Override - public NewColorAndFontPanel createPanel(@NotNull ColorAndFontOptions options) { - SchemesPanel schemesPanel = new SchemesPanel(options); - final ColorAndFontDescriptionPanel descriptionPanel = new ColorAndFontDescriptionPanel(); - final OptionsPanel optionsPanel = new OptionsPanelImpl(descriptionPanel, options, schemesPanel, ExternalSystemBundle - .message("gradle.name")); - GradleColorAndFontPreviewPanel previewPanel = new GradleColorAndFontPreviewPanel(options); - return new NewColorAndFontPanel(schemesPanel, optionsPanel, previewPanel, ExternalSystemBundle.message("gradle.name"), null, null); - } - - @NotNull - @Override - public String getPanelDisplayName() { - return ExternalSystemBundle.message("gradle.name"); - } - - @Override - public DisplayPriority getPriority() { - return DisplayPriority.LANGUAGE_SETTINGS; - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorAndFontPreviewPanel.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorAndFontPreviewPanel.java deleted file mode 100644 index d827672248ec..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorAndFontPreviewPanel.java +++ /dev/null @@ -1,329 +0,0 @@ -package org.jetbrains.plugins.gradle.config; - -import com.intellij.application.options.colors.ColorAndFontOptions; -import com.intellij.application.options.colors.ColorAndFontSettingsListener; -import com.intellij.application.options.colors.EditorSchemeAttributeDescriptor; -import com.intellij.application.options.colors.PreviewPanel; -import com.intellij.ide.projectView.PresentationData; -import com.intellij.ide.util.treeView.NodeRenderer; -import com.intellij.openapi.editor.colors.EditorColorsScheme; -import com.intellij.openapi.editor.colors.TextAttributesKey; -import com.intellij.openapi.externalSystem.model.project.ProjectEntityType; -import com.intellij.openapi.externalSystem.settings.ExternalSystemTextAttributes; -import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; -import com.intellij.openapi.util.Pair; -import com.intellij.openapi.util.Ref; -import com.intellij.ui.JBColor; -import com.intellij.ui.components.JBScrollPane; -import com.intellij.ui.treeStructure.Tree; -import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.containers.hash.HashMap; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import com.intellij.openapi.externalSystem.model.project.id.GradleSyntheticId; -import com.intellij.openapi.externalSystem.ui.ProjectStructureNodeDescriptor; - -import javax.swing.*; -import javax.swing.event.TreeSelectionEvent; -import javax.swing.event.TreeSelectionListener; -import javax.swing.tree.*; -import java.awt.*; -import java.util.List; -import java.util.Map; - -/** - * @author Denis Zhdanov - * @since 1/19/12 11:59 AM - */ -public class GradleColorAndFontPreviewPanel implements PreviewPanel { - - private final Map myNodes = new HashMap(); - - // TODO den switch to ContainerUtil.createLockFreeCopyOnWriteList() as soon as v.12.1 is released. - // TODO den (we need to preserve binary compatibility with v.12.0 at the moment) - private final List myListeners = ContainerUtil.createEmptyCOWList(); - private final JPanel myContent = new JPanel(new GridBagLayout()); - private final JPanel myNodeRenderPanel = new JPanel(new GridBagLayout()); - private final Ref myAllowTreeExpansion = new Ref(true); - private final ArrowPanel mySelectedElementSignPanel = new ArrowPanel(); - - private final Tree myTree; - private final DefaultTreeModel myTreeModel; - - private ColorAndFontOptions myOptions; - private TreeNode mySelectedNode; - - public GradleColorAndFontPreviewPanel(@NotNull ColorAndFontOptions options) { - myOptions = options; - final Pair pair = init(); - myTree = pair.first; - myTreeModel = pair.second; - } - - private Pair init() { - myContent.removeAll(); - String projectName = ExternalSystemBundle.message("gradle.settings.color.text.sample.conflict.node.name"); - DefaultMutableTreeNode root = createNode( - projectName, - ProjectEntityType.PROJECT, - ExternalSystemTextAttributes.CHANGE_CONFLICT - ); - - String moduleName = ExternalSystemBundle.message("gradle.settings.color.text.sample.node.sync.name"); - DefaultMutableTreeNode module = createNode(moduleName, ProjectEntityType.MODULE, ExternalSystemTextAttributes.NO_CHANGE); - - String gradleLibraryName = ExternalSystemBundle.message("gradle.settings.color.text.sample.node.gradle.name"); - DefaultMutableTreeNode gradleLibrary = createNode( - gradleLibraryName, ProjectEntityType.LIBRARY_DEPENDENCY, ExternalSystemTextAttributes.EXTERNAL_SYSTEM_LOCAL_CHANGE - ); - - String intellijLibraryName = ExternalSystemBundle.message("gradle.settings.color.text.sample.node.intellij.name"); - DefaultMutableTreeNode intellijLibrary = createNode( - intellijLibraryName, ProjectEntityType.LIBRARY_DEPENDENCY, ExternalSystemTextAttributes.IDE_LOCAL_CHANGE - ); - - String libraryWithChangedVersionName = ExternalSystemBundle.message("gradle.settings.color.text.sample.node.outdated.name"); - DefaultMutableTreeNode libraryWithChangedVersion = createNode( - libraryWithChangedVersionName, ProjectEntityType.LIBRARY_DEPENDENCY, ExternalSystemTextAttributes.OUTDATED_ENTITY); - - module.add(gradleLibrary); - module.add(intellijLibrary); - module.add(libraryWithChangedVersion); - root.add(module); - - mySelectedNode = root; - - DefaultTreeModel treeModel = new DefaultTreeModel(root); - Tree tree = buildTree(treeModel, module); - - GridBagConstraints constraints = new GridBagConstraints(); - constraints.fill = GridBagConstraints.BOTH; - constraints.weightx = constraints.weighty = 1; - myContent.add(new JBScrollPane(tree), constraints); - return new Pair(tree, treeModel); - } - - private Tree buildTree(@NotNull TreeModel model, DefaultMutableTreeNode... nodesToExpand) { - final Tree tree = new Tree(model) { - @Override - protected void setExpandedState(TreePath path, boolean state) { - if (myAllowTreeExpansion.get()) { - super.setExpandedState(path, state); - } - // Ignore the expansion change events otherwise - } - }; - - // Configure expansion - for (DefaultMutableTreeNode node : nodesToExpand) { - tree.expandPath(new TreePath(node.getPath())); - } - myAllowTreeExpansion.set(false); - - // Configure selection. - tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); - tree.addTreeSelectionListener(new TreeSelectionListener() { - - private boolean myIgnore; - - @Override - public void valueChanged(TreeSelectionEvent e) { - if (myIgnore) { - return; - } - final TreePath path = e.getNewLeadSelectionPath(); - if (path == null) { - clearSelection(); - return; - } - final Object component = path.getLastPathComponent(); - for (Map.Entry entry : myNodes.entrySet()) { - if (entry.getValue().equals(component)) { - pointTo(entry.getValue()); - for (ColorAndFontSettingsListener listener : myListeners) { - listener.selectionInPreviewChanged(entry.getKey().getExternalName()); - clearSelection(); - } - return; - } - } - clearSelection(); - } - - private void clearSelection() { - // Don't show selection at the 'preview' node. - myIgnore = true; - try { - tree.getSelectionModel().clearSelection(); - } - finally { - myIgnore = false; - } - } - }); - - // Bind rendering to the target colors scheme. - final NodeRenderer delegate = new NodeRenderer() { - @NotNull - @Override - protected EditorColorsScheme getColorsScheme() { - return myOptions.getSelectedScheme(); - } - }; - myNodeRenderPanel.setBackground(tree.getBackground()); - tree.setCellRenderer(new TreeCellRenderer() { - @Override - public Component getTreeCellRendererComponent(JTree tree, - Object value, - boolean selected, - boolean expanded, - boolean leaf, - int row, - boolean hasFocus) { - final Component component = delegate.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); - if (myNodeRenderPanel.getComponentCount() <= 0) { - GridBagConstraints constraints = new GridBagConstraints(); - myNodeRenderPanel.add(component, constraints); - constraints.weightx = 1; - constraints.anchor = GridBagConstraints.CENTER; - myNodeRenderPanel.add(mySelectedElementSignPanel, constraints); - } - - mySelectedElementSignPanel.setPaint(value == mySelectedNode); - - // The same component is used for rendering all nodes, that's there is a possible situation when the renderer was used - // for narrow node component painting at first and then we want to paint a wider node. The problem is that preferred renderer - // size value calculated for the narrow node component might be cached at the renderer. That's why we explicitly drop - // that cached value (if any). - myNodeRenderPanel.setPreferredSize(null); - return myNodeRenderPanel; - } - }); - return tree; - } - - @Override - public void blinkSelectedHighlightType(Object selected) { - if (!(selected instanceof EditorSchemeAttributeDescriptor)) { - return; - } - final String type = ((EditorSchemeAttributeDescriptor)selected).getType(); - for (Map.Entry entry : myNodes.entrySet()) { - if (entry.getKey().getExternalName().equals(type)) { - pointTo(entry.getValue()); - return; - } - } - } - - /** - * Instructs the panel to show given node as selected. - * - * @param node node to show as 'selected' - */ - private void pointTo(@NotNull TreeNode node) { - TreeNode oldSelectedNode = mySelectedNode; - mySelectedNode = node; - myTreeModel.nodeChanged(oldSelectedNode); - myTreeModel.nodeChanged(mySelectedNode); - } - - @Override - public void disposeUIResources() { - myListeners.clear(); - myNodes.clear(); - myContent.removeAll(); - myNodeRenderPanel.removeAll(); - } - - @Override - public Component getPanel() { - return myContent; - } - - @Override - public void updateView() { - repaintTree(); - } - - private void repaintTree() { - myTreeModel.reload(); - myAllowTreeExpansion.set(true); - try { - for (DefaultMutableTreeNode node : myNodes.values()) { - myTree.expandPath(new TreePath(node.getPath())); - } - } - finally { - myAllowTreeExpansion.set(false); - } - } - - @Override - public void addListener(@NotNull ColorAndFontSettingsListener listener) { - myListeners.add(listener); - } - - private DefaultMutableTreeNode createNode(@NotNull String text, @NotNull ProjectEntityType type, @Nullable TextAttributesKey textAttributesKey) { - final ProjectStructureNodeDescriptor descriptor - = new ProjectStructureNodeDescriptor(new GradleSyntheticId(text), text, type.getIcon()); - DefaultMutableTreeNode result = new DefaultMutableTreeNode(descriptor); - if (textAttributesKey != null) { - final PresentationData presentation = descriptor.getPresentation(); - presentation.setAttributesKey(textAttributesKey); - myNodes.put(textAttributesKey, result); - } - return result; - } - - /** - * Encapsulates logic of drawing 'selected element' sign. - */ - private static class ArrowPanel extends JPanel { - - private boolean myPaint; - - ArrowPanel() { - super(new BorderLayout()); - // Reserve enough horizontal space. - add(new JLabel("intelli")); - } - - public void setPaint(boolean paint) { - myPaint = paint; - } - - @Override - public void paint(Graphics g) { - if (!myPaint) { - return; - } - Graphics2D g2 = (Graphics2D)g; - g.setColor(JBColor.RED); - RenderingHints renderHints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - renderHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); - g2.setRenderingHints(renderHints); - - FontMetrics fontMetrics = getFontMetrics(getFont()); - int unit = fontMetrics.charWidth('a') * 2 / 3; - int yShift = 0; - final Dimension size = getSize(); - if (size != null) { - yShift = size.height / 2 - unit; - if (size.height % 2 != 0) { - // Prefer 'draw below the center' to 'draw above the center'. - yShift++; - } - } - int q = unit / 4; - int[] x = {0, unit * 3, unit * 2, unit * 4, unit * 4, unit * 2, unit * 3, 0 }; - int[] y = {unit, 0, unit - q, unit - q, unit + q, unit + q, unit * 2, unit}; - if (yShift != 0) { - for (int i = 0; i < y.length; i++) { - y[i] += yShift; - } - } - g2.fillPolygon(x, y, x.length); - } - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleToolWindowPanel.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleToolWindowPanel.java index 72f689d6fcb2..91da39a93522 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleToolWindowPanel.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleToolWindowPanel.java @@ -3,8 +3,6 @@ package org.jetbrains.plugins.gradle.config; import com.intellij.openapi.actionSystem.ActionGroup; import com.intellij.openapi.actionSystem.ActionManager; import com.intellij.openapi.actionSystem.ActionToolbar; -import com.intellij.openapi.components.ServiceManager; -import com.intellij.openapi.externalSystem.service.project.ProjectStructureChangesDetector; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.SimpleToolWindowPanel; import com.intellij.openapi.util.text.StringUtil; @@ -126,12 +124,6 @@ public abstract class GradleToolWindowPanel extends SimpleToolWindowPanel { for (JComponent component : getToolbarControls()) { component.setVisible(showToolbar); } - - if (!NON_LINKED_CARD_NAME.equals(cardToShow)) { - updateContent(); - // Ensure that changes detector service is loaded. - ServiceManager.getService(myProject, ProjectStructureChangesDetector.class); - } } @NotNull diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/GradleDiffUtil.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/GradleDiffUtil.java deleted file mode 100644 index 189d07339bf4..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/GradleDiffUtil.java +++ /dev/null @@ -1,207 +0,0 @@ -package org.jetbrains.plugins.gradle.diff; - -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.externalSystem.model.project.*; -import com.intellij.openapi.externalSystem.model.project.change.*; -import com.intellij.openapi.externalSystem.model.project.id.JarId; -import com.intellij.openapi.externalSystem.service.project.change.ExternalProjectChangesCalculationContext; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.LibraryOrderEntry; -import com.intellij.openapi.roots.ModuleOrderEntry; -import com.intellij.openapi.roots.OrderEntry; -import com.intellij.openapi.roots.OrderRootType; -import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.vfs.VirtualFile; -import org.jetbrains.annotations.NotNull; -import com.intellij.openapi.externalSystem.model.project.change.ModulePresenceChange; -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.id.LibraryId; -import com.intellij.openapi.externalSystem.util.IdeEntityVisitor; -import com.intellij.openapi.externalSystem.service.project.ModuleAwareContentRoot; -import org.jetbrains.plugins.gradle.util.GradleUtil; - -import java.util.HashMap; -import java.util.Map; - -/** - * Contains various utility methods for building changes between the gradle and intellij project structures. - * - * @author Denis Zhdanov - * @since 1/24/12 11:20 AM - */ -public class GradleDiffUtil { - - private static final Logger LOG = Logger.getInstance("#" + GradleDiffUtil.class.getName()); - - private GradleDiffUtil() { - } - - /** - * Build changes objects assuming that all entities starting from the given (i.e. given and all of its interested sub-entities) - * exist only at the gradle side. - *

- * Example: particular module has been added at the gradle side. We want to mark that module, its content root(s), dependencies etc - * as gradle-local changes. - * - * @param entity target gradle-local entity - * @param context changes calculation context to use - */ - public static void buildLocalChanges(@NotNull ProjectEntityData entity, @NotNull final ExternalProjectChangesCalculationContext context) { - // TODO den implement -// entity.invite(new ExternalEntityVisitor() { -// @Override -// public void visit(@NotNull ProjectData project) { -// assert false; -// } -// -// @Override -// public void visit(@NotNull ModuleData module) { -// context.register(new ModulePresenceChange(module, null)); -// for (ContentRootData root : module.getContentRoots()) { -// root.invite(this); -// } -// for (DependencyData dependency : module.getDependencies()) { -// dependency.invite(this); -// } -// } -// -// @Override -// public void visit(@NotNull ContentRootData contentRoot) { -// context.register(new ContentRootPresenceChange(contentRoot, null)); -// } -// -// @Override -// public void visit(@NotNull LibraryData library) { -// for (LibraryPathType pathType : LibraryPathType.values()) { -// for (String path : library.getPaths(pathType)) { -// JarId jarId = new JarId(path, pathType, new LibraryId(ProjectSystemId.GRADLE, library.getName())); -// context.register(new JarPresenceChange(jarId, null)); -// } -// } -// } -// -// @Override -// public void visit(@NotNull JarData jar) { -// context.register(new JarPresenceChange(jar.getId(), null)); -// } -// -// @Override -// public void visit(@NotNull ModuleDependencyData dependency) { -// context.register(new ModuleDependencyPresenceChange(dependency, null)); -// } -// -// @Override -// public void visit(@NotNull LibraryDependencyData dependency) { -// context.register(new LibraryDependencyPresenceChange(dependency, null)); -// } -// -// @Override -// public void visit(@NotNull CompositeLibraryDependencyData dependency) { -// // We expect such composite entities for outdated libraries to appear as 'low-level' project structure changes processing -// // result. -// assert false; -// } -// }); - } - - /** - * Performs argument type-based dispatch and delegates to one of strongly typed 'buildLocalChanges()' methods. - * - * @param entity target ide-local entity that doesn't present at the gradle side - * @param context changes calculation context to use - */ - public static void buildLocalChanges(@NotNull Object entity, @NotNull final ExternalProjectChangesCalculationContext context) { - if (entity instanceof ProjectEntityData) { - buildLocalChanges((ProjectEntityData)entity, context); - } - else { - // TODO den implement -// GradleUtil.dispatch(entity, new IdeEntityVisitor() { -// @Override -// public void visit(@NotNull Project project) { -// } -// -// @Override -// public void visit(@NotNull Module module) { -// context.register(new ModulePresenceChange(null, module)); -// for (ModuleAwareContentRoot contentRoot : context.getPlatformFacade().getContentRoots(module)) { -// visit(contentRoot); -// } -// for (OrderEntry entry : context.getPlatformFacade().getOrderEntries(module)) { -// GradleUtil.dispatch(entry, this); -// } -// } -// -// @Override -// public void visit(@NotNull ModuleAwareContentRoot contentRoot) { -// context.register(new ContentRootPresenceChange(null, contentRoot)); -// } -// -// @Override -// public void visit(@NotNull LibraryOrderEntry libraryDependency) { -// context.register(new LibraryDependencyPresenceChange(null, libraryDependency)); -// } -// -// @Override -// public void visit(@NotNull ModuleOrderEntry moduleDependency) { -// final Module module = moduleDependency.getModule(); -// if (module != null) { -// context.register(new ModuleDependencyPresenceChange(null, moduleDependency)); -// } -// } -// -// @Override -// public void visit(@NotNull Library library) { -// for (VirtualFile file : library.getFiles(OrderRootType.CLASSES)) { -// JarId jarId = new JarId(context.getPlatformFacade().getLocalFileSystemPath(file), -// LibraryPathType.BINARY, -// new LibraryId(ProjectSystemId.IDE, GradleUtil.getLibraryName(library))); -// context.register(new JarPresenceChange(null, jarId)); -// } -// } -// }); - } - } - - /** - * Utility method for comparing entity collections. For example, it may be provided with the collection of gradle modules and - * collection of ide modules. Matched entities are found and the comparison is delegated to the given 'calculator'. - * Corresponding changes are generated for the non-matched (local) changes (e.g. particular library dependency presents - * at the ide side but not at the gradle). - * - * @param calculator comparison strategy that works with the single entities (not collection of entities) - * @param gradleEntities entities available at the gradle side - * @param ideEntities entities available at the ide side - * @param context changes calculation context - * @param target ide entity type - * @param target gradle entity type - */ - public static void calculate( - @NotNull ExternalProjectStructureChangesCalculator calculator, - @NotNull Iterable gradleEntities, - @NotNull Iterable ideEntities, - @NotNull ExternalProjectChangesCalculationContext context) - { - // TODO den implement -// Map ideEntitiesByKeys = new HashMap(); -// for (I entity : ideEntities) { -// Object key = calculator.getIdeKey(entity); -// final I previous = ideEntitiesByKeys.put(key, entity); -// assert previous == null : key; -// } -// for (G gradleEntity: gradleEntities) { -// I ideEntity = ideEntitiesByKeys.remove(calculator.getGradleKey(gradleEntity, context)); -// if (ideEntity == null) { -// buildLocalChanges(gradleEntity, context); -// } -// else { -// calculator.calculate(gradleEntity, ideEntity, context); -// } -// } -// -// for (I entity : ideEntitiesByKeys.values()) { -// buildLocalChanges(entity, context); -// } - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/contentroot/GradleContentRootStructureChangesCalculator.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/contentroot/GradleContentRootStructureChangesCalculator.java deleted file mode 100644 index a3d3bf5a386f..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/contentroot/GradleContentRootStructureChangesCalculator.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.jetbrains.plugins.gradle.diff.contentroot; - -import com.intellij.openapi.externalSystem.model.project.ContentRootData; -import com.intellij.openapi.externalSystem.model.project.change.ExternalProjectStructureChangesCalculator; -import com.intellij.openapi.externalSystem.model.project.id.EntityIdMapper; -import com.intellij.openapi.externalSystem.service.project.change.ExternalProjectChangesCalculationContext; -import org.jetbrains.annotations.NotNull; -import com.intellij.openapi.externalSystem.service.project.ModuleAwareContentRoot; - -/** - * @author Denis Zhdanov - * @since 2/27/12 7:00 PM - */ -public class GradleContentRootStructureChangesCalculator - implements ExternalProjectStructureChangesCalculator -{ - @Override - public void calculate(@NotNull ContentRootData gradleEntity, - @NotNull ModuleAwareContentRoot ideEntity, - @NotNull ExternalProjectChangesCalculationContext context) - { - } - - // TODO den implement -// @NotNull -// @Override -// public Object getIdeKey(@NotNull ModuleAwareContentRoot entity) { -// return EntityIdMapper.mapEntityToId(entity); -// } -// -// @NotNull -// @Override -// public Object getGradleKey(@NotNull ContentRootData entity, @NotNull ExternalProjectChangesCalculationContext context) { -// // TODO den consider the known changes -// return EntityIdMapper.mapEntityToId(entity); -// } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/dependency/AbstractGradleDependencyStructureChangesCalculator.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/dependency/AbstractGradleDependencyStructureChangesCalculator.java deleted file mode 100644 index af96f396485b..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/dependency/AbstractGradleDependencyStructureChangesCalculator.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.jetbrains.plugins.gradle.diff.dependency; - -import com.intellij.openapi.externalSystem.model.project.DependencyData; -import com.intellij.openapi.externalSystem.model.project.change.DependencyExportedChange; -import com.intellij.openapi.externalSystem.model.project.change.DependencyScopeChange; -import com.intellij.openapi.externalSystem.model.project.change.ExternalProjectStructureChangesCalculator; -import com.intellij.openapi.externalSystem.model.project.id.AbstractExternalDependencyId; -import com.intellij.openapi.externalSystem.model.project.id.EntityIdMapper; -import com.intellij.openapi.externalSystem.service.project.change.ExternalProjectChangesCalculationContext; -import com.intellij.openapi.roots.ExportableOrderEntry; -import org.jetbrains.annotations.NotNull; - -/** - * Manages common dependency properties like 'scope', 'exported'. - *

- * Thread-safe. - * - * @author Denis Zhdanov - * @since 2/20/12 11:17 AM - */ -public abstract class AbstractGradleDependencyStructureChangesCalculator - implements ExternalProjectStructureChangesCalculator -{ - @Override - public void calculate(@NotNull G gradleEntity, @NotNull I ideEntity, @NotNull ExternalProjectChangesCalculationContext context) { - final AbstractExternalDependencyId id = EntityIdMapper.mapEntityToId(gradleEntity); - if (gradleEntity.getScope() != ideEntity.getScope()) { - context.register(new DependencyScopeChange(id, gradleEntity.getScope(), ideEntity.getScope())); - } - if (gradleEntity.isExported() != ideEntity.isExported()) { - context.register(new DependencyExportedChange(id, gradleEntity.isExported(), ideEntity.isExported())); - } - - doCalculate(gradleEntity, ideEntity, context); - } - - protected abstract void doCalculate(@NotNull G gradleEntity, @NotNull I intellijEntity, @NotNull ExternalProjectChangesCalculationContext context); -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/dependency/GradleLibraryDependencyStructureChangesCalculator.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/dependency/GradleLibraryDependencyStructureChangesCalculator.java deleted file mode 100644 index 708b965a3451..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/dependency/GradleLibraryDependencyStructureChangesCalculator.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.jetbrains.plugins.gradle.diff.dependency; - -import com.intellij.openapi.externalSystem.model.project.LibraryDependencyData; -import com.intellij.openapi.externalSystem.service.project.change.ExternalProjectChangesCalculationContext; -import com.intellij.openapi.roots.LibraryOrderEntry; -import com.intellij.openapi.roots.libraries.Library; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.plugins.gradle.diff.library.GradleLibraryStructureChangesCalculator; - -/** - * @author Denis Zhdanov - * @since 1/24/12 1:37 PM - */ -public class GradleLibraryDependencyStructureChangesCalculator - extends AbstractGradleDependencyStructureChangesCalculator -{ - - private final GradleLibraryStructureChangesCalculator myLibraryCalculator; - - public GradleLibraryDependencyStructureChangesCalculator(@NotNull GradleLibraryStructureChangesCalculator libraryCalculator) { - myLibraryCalculator = libraryCalculator; - } - - @Override - public void doCalculate(@NotNull LibraryDependencyData gradleEntity, - @NotNull LibraryOrderEntry intellijEntity, - @NotNull ExternalProjectChangesCalculationContext context) - { - final Library library = intellijEntity.getLibrary(); - if (library == null) { - return; - } - myLibraryCalculator.calculate(gradleEntity.getTarget(), library, context); - } - - // TODO den implement -// @NotNull -// @Override -// public Object getIdeKey(@NotNull LibraryOrderEntry entity) { -// final Library library = entity.getLibrary(); -// if (library == null) { -// return ""; -// } -// return myLibraryCalculator.getIdeKey(library); -// } -// -// @NotNull -// @Override -// public Object getGradleKey(@NotNull LibraryDependencyData entity, @NotNull ExternalProjectChangesCalculationContext context) { -// return myLibraryCalculator.getGradleKey(entity.getTarget(), context); -// } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/dependency/GradleModuleDependencyStructureChangesCalculator.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/dependency/GradleModuleDependencyStructureChangesCalculator.java deleted file mode 100644 index 3111b9ee76a3..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/dependency/GradleModuleDependencyStructureChangesCalculator.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.jetbrains.plugins.gradle.diff.dependency; - -import com.intellij.openapi.externalSystem.model.project.ModuleDependencyData; -import com.intellij.openapi.externalSystem.service.project.change.ExternalProjectChangesCalculationContext; -import com.intellij.openapi.roots.ModuleOrderEntry; -import org.jetbrains.annotations.NotNull; - -/** - * @author Denis Zhdanov - * @since 2/20/12 11:10 AM - */ -public class GradleModuleDependencyStructureChangesCalculator - extends AbstractGradleDependencyStructureChangesCalculator -{ - - @Override - public void doCalculate(@NotNull ModuleDependencyData gradleEntity, - @NotNull ModuleOrderEntry intellijEntity, - @NotNull ExternalProjectChangesCalculationContext context) - { - // Assuming that the modules referenced by the given dependencies are compared independently. - } - - @NotNull - public Object getIdeKey(@NotNull ModuleOrderEntry entity) { - final String intellijModuleName = entity.getModuleName(); - if (intellijModuleName == null) { - return ""; - } - return intellijModuleName; - } - - @NotNull - public Object getGradleKey(@NotNull ModuleDependencyData entity, @NotNull ExternalProjectChangesCalculationContext context) { - return entity.getTarget().getName(); - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/library/GradleLibraryStructureChangesCalculator.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/library/GradleLibraryStructureChangesCalculator.java deleted file mode 100644 index 4fcab4c3cd82..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/library/GradleLibraryStructureChangesCalculator.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.jetbrains.plugins.gradle.diff.library; - -import com.intellij.openapi.externalSystem.model.project.LibraryData; -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.model.project.change.ExternalProjectStructureChangesCalculator; -import com.intellij.openapi.externalSystem.model.project.change.JarPresenceChange; -import com.intellij.openapi.externalSystem.model.project.id.JarId; -import com.intellij.openapi.externalSystem.service.project.change.ExternalProjectChangesCalculationContext; -import com.intellij.openapi.roots.OrderRootType; -import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.vfs.VirtualFile; -import org.jetbrains.annotations.NotNull; -import com.intellij.openapi.externalSystem.service.project.PlatformFacade; -import com.intellij.openapi.externalSystem.model.project.LibraryPathType; -import com.intellij.openapi.externalSystem.model.project.id.LibraryId; -import org.jetbrains.plugins.gradle.util.GradleUtil; - -import java.util.HashSet; -import java.util.Set; - -/** - * @author Denis Zhdanov - * @since 2/3/12 11:17 AM - */ -public class GradleLibraryStructureChangesCalculator implements ExternalProjectStructureChangesCalculator { - - private final PlatformFacade myPlatformFacade; - - public GradleLibraryStructureChangesCalculator(@NotNull PlatformFacade platformFacade) { - myPlatformFacade = platformFacade; - } - - @Override - public void calculate(@NotNull LibraryData gradleEntity, - @NotNull Library ideEntity, - @NotNull ExternalProjectChangesCalculationContext context) - { - for (LibraryPathType pathType : LibraryPathType.values()) { - doCalculate(gradleEntity, pathType, context.getLibraryPathTypeMapper().map(pathType), ideEntity, context); - } - } - - private void doCalculate(@NotNull LibraryData gradleEntity, - @NotNull LibraryPathType gradleType, - @NotNull OrderRootType ideType, - @NotNull Library ideEntity, - @NotNull ExternalProjectChangesCalculationContext context) - { - final Set gradleBinaryPaths = new HashSet(gradleEntity.getPaths(gradleType)); - final Set ideBinaryPaths = new HashSet(); - for (VirtualFile file : ideEntity.getFiles(ideType)) { - final String path = myPlatformFacade.getLocalFileSystemPath(file); - if (!gradleBinaryPaths.remove(path)) { - ideBinaryPaths.add(path); - } - } - - if (!gradleBinaryPaths.isEmpty()) { - // TODO den implement -// LibraryId libraryId = new LibraryId(ProjectSystemId.GRADLE, gradleEntity.getName()); -// for (String path : gradleBinaryPaths) { -// context.register(new JarPresenceChange(new JarId(path, gradleType, libraryId), null)); -// } - } - - if (!ideBinaryPaths.isEmpty()) { - // TODO den implement -// LibraryId libraryId = new LibraryId(ProjectSystemId.IDE, GradleUtil.getLibraryName(ideEntity)); -// for (String path : ideBinaryPaths) { -// context.register(new JarPresenceChange(null, new JarId(path, gradleType, libraryId))); -// } - } - } - - // TODO den implement -// @NotNull -// @Override -// public Object getIdeKey(@NotNull Library entity) { -// return GradleUtil.getLibraryName(entity); -// } -// -// @NotNull -// @Override -// public Object getGradleKey(@NotNull LibraryData entity, @NotNull ExternalProjectChangesCalculationContext context) { -// return entity.getName(); -// } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/module/GradleModuleStructureChangesCalculator.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/module/GradleModuleStructureChangesCalculator.java deleted file mode 100644 index ee8fd62e4cf4..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/module/GradleModuleStructureChangesCalculator.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright 2000-2011 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.plugins.gradle.diff.module; - -import com.intellij.openapi.externalSystem.model.project.*; -import com.intellij.openapi.externalSystem.model.project.change.ExternalProjectStructureChangesCalculator; -import com.intellij.openapi.externalSystem.service.project.change.ExternalProjectChangesCalculationContext; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.roots.LibraryOrderEntry; -import com.intellij.openapi.roots.ModuleOrderEntry; -import com.intellij.openapi.roots.OrderEntry; -import com.intellij.openapi.roots.RootPolicy; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.plugins.gradle.diff.GradleDiffUtil; -import org.jetbrains.plugins.gradle.diff.contentroot.GradleContentRootStructureChangesCalculator; -import org.jetbrains.plugins.gradle.diff.dependency.GradleLibraryDependencyStructureChangesCalculator; -import org.jetbrains.plugins.gradle.diff.dependency.GradleModuleDependencyStructureChangesCalculator; -import com.intellij.openapi.externalSystem.service.project.ModuleAwareContentRoot; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -/** - * Encapsulates functionality of calculating changes between Gradle and IntelliJ IDEA module hierarchies. - *

- * Thread-safe. - * - * @author Denis Zhdanov - * @since 11/14/11 6:30 PM - */ -public class GradleModuleStructureChangesCalculator implements ExternalProjectStructureChangesCalculator { - - @NotNull private final GradleLibraryDependencyStructureChangesCalculator myLibraryDependencyCalculator; - @NotNull private final GradleModuleDependencyStructureChangesCalculator myModuleDependencyCalculator; - @NotNull private final GradleContentRootStructureChangesCalculator myContentRootCalculator; - - public GradleModuleStructureChangesCalculator(@NotNull GradleLibraryDependencyStructureChangesCalculator libraryDependencyCalculator, - @NotNull GradleModuleDependencyStructureChangesCalculator moduleDependencyCalculator, - @NotNull GradleContentRootStructureChangesCalculator calculator) - { - myLibraryDependencyCalculator = libraryDependencyCalculator; - myModuleDependencyCalculator = moduleDependencyCalculator; - myContentRootCalculator = calculator; - } - - @Override - public void calculate(@NotNull ModuleData gradleEntity, - @NotNull Module ideEntity, - @NotNull ExternalProjectChangesCalculationContext context) - { - // Content roots. - // TODO den implement -// final Collection gradleContentRoots = gradleEntity.getContentRoots(); -// final Collection intellijContentRoots = context.getPlatformFacade().getContentRoots(ideEntity); -// GradleDiffUtil.calculate(myContentRootCalculator, gradleContentRoots, intellijContentRoots, context); - - // Dependencies. - checkDependencies(gradleEntity, ideEntity, context); - } - - @NotNull - public Object getIdeKey(@NotNull Module entity) { - return entity.getName(); - } - - @NotNull - public Object getGradleKey(@NotNull ModuleData entity, @NotNull ExternalProjectChangesCalculationContext context) { - return entity.getName(); - } - - private void checkDependencies(@NotNull ModuleData gradleModule, - @NotNull Module intellijModule, - @NotNull ExternalProjectChangesCalculationContext context) - { - // Prepare intellij part. - final List intellijModuleDependencies = new ArrayList(); - final List intellijLibraryDependencies = new ArrayList(); - RootPolicy policy = new RootPolicy() { - @Override - public Object visitModuleOrderEntry(ModuleOrderEntry moduleOrderEntry, Object value) { - intellijModuleDependencies.add(moduleOrderEntry); - return moduleOrderEntry; - } - - @Override - public Object visitLibraryOrderEntry(LibraryOrderEntry libraryOrderEntry, Object value) { - intellijLibraryDependencies.add(libraryOrderEntry); - return libraryOrderEntry; - } - }; - for (OrderEntry orderEntry : context.getPlatformFacade().getOrderEntries(intellijModule)) { - orderEntry.accept(policy, null); - } - - // Prepare gradle part. - final List gradleModuleDependencies = new ArrayList(); - final List gradleLibraryDependencies = new ArrayList(); - // TODO den implement -// ExternalEntityVisitor visitor = new ExternalEntityVisitorAdapter() { -// @Override -// public void visit(@NotNull ModuleDependencyData dependency) { -// gradleModuleDependencies.add(dependency); -// } -// -// @Override -// public void visit(@NotNull LibraryDependencyData dependency) { -// gradleLibraryDependencies.add(dependency); -// } -// }; -// for (DependencyData dependency : gradleModule.getDependencies()) { -// dependency.invite(visitor); -// } - - // Calculate changes. - GradleDiffUtil.calculate(myLibraryDependencyCalculator, gradleLibraryDependencies, intellijLibraryDependencies, context); - GradleDiffUtil.calculate(myModuleDependencyCalculator, gradleModuleDependencies, intellijModuleDependencies, context); - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/project/GradleProjectStructureChangesCalculator.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/project/GradleProjectStructureChangesCalculator.java deleted file mode 100644 index 8a1e5201147d..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/project/GradleProjectStructureChangesCalculator.java +++ /dev/null @@ -1,103 +0,0 @@ -package org.jetbrains.plugins.gradle.diff.project; - -import com.intellij.openapi.externalSystem.model.project.ProjectData; -import com.intellij.openapi.externalSystem.model.project.ModuleData; -import com.intellij.openapi.externalSystem.model.project.change.ExternalProjectStructureChange; -import com.intellij.openapi.externalSystem.model.project.change.ExternalProjectStructureChangesCalculator; -import com.intellij.openapi.externalSystem.model.project.change.LanguageLevelChange; -import com.intellij.openapi.externalSystem.model.project.change.GradleProjectRenameChange; -import com.intellij.openapi.externalSystem.service.project.change.ExternalProjectChangesCalculationContext; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.libraries.LibraryTable; -import com.intellij.pom.java.LanguageLevel; -import org.jetbrains.annotations.NotNull; -import com.intellij.openapi.externalSystem.service.project.PlatformFacade; -import org.jetbrains.plugins.gradle.diff.GradleDiffUtil; -import org.jetbrains.plugins.gradle.diff.library.GradleLibraryStructureChangesCalculator; -import org.jetbrains.plugins.gradle.diff.module.GradleModuleStructureChangesCalculator; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Set; - -/** - * Encapsulates functionality of calculating changes between Gradle and IntelliJ IDEA project hierarchies. - *

- * Thread-safe. - * - * @author Denis Zhdanov - * @since 11/3/11 3:55 PM - */ -public class GradleProjectStructureChangesCalculator implements ExternalProjectStructureChangesCalculator { - - @NotNull private final GradleModuleStructureChangesCalculator myModuleChangesCalculator; - @NotNull private final GradleLibraryStructureChangesCalculator myLibraryChangesCalculator; - @NotNull private final PlatformFacade myPlatformFacade; - - public GradleProjectStructureChangesCalculator(@NotNull GradleModuleStructureChangesCalculator moduleCalculator, - @NotNull GradleLibraryStructureChangesCalculator calculator, - @NotNull PlatformFacade platformFacade) - { - myModuleChangesCalculator = moduleCalculator; - myLibraryChangesCalculator = calculator; - myPlatformFacade = platformFacade; - } - - @Override - public void calculate(@NotNull ProjectData gradleEntity, - @NotNull Project ideEntity, - @NotNull ExternalProjectChangesCalculationContext context) - { - calculateProjectChanges(gradleEntity, ideEntity, context.getCurrentChanges()); - - // TODO den implement -// final Set gradleSubEntities = gradleEntity.getModules(); -// final Collection intellijSubEntities = myPlatformFacade.getModules(ideEntity); -// GradleDiffUtil.calculate(myModuleChangesCalculator, gradleSubEntities, intellijSubEntities, context); -// -// LibraryTable libraryTable = myPlatformFacade.getProjectLibraryTable(ideEntity); -// GradleDiffUtil.calculate(myLibraryChangesCalculator, gradleEntity.getLibraries(), Arrays.asList(libraryTable.getLibraries()), context); - } - - @NotNull - public Object getIdeKey(@NotNull Project entity) { - return entity.getName(); - } - - @NotNull - public Object getGradleKey(@NotNull ProjectData entity, @NotNull ExternalProjectChangesCalculationContext context) { - return entity.getName(); - } - - private void calculateProjectChanges(@NotNull ProjectData gradleProject, - @NotNull Project intellijProject, - @NotNull Set currentChanges) - { - checkName(gradleProject, intellijProject, currentChanges); - checkLanguageLevel(gradleProject, intellijProject, currentChanges); - } - - private static void checkName(@NotNull ProjectData gradleProject, - @NotNull Project intellijProject, - @NotNull Set currentChanges) - { - String gradleName = gradleProject.getName(); - String intellijName = intellijProject.getName(); - if (!gradleName.equals(intellijName)) { - currentChanges.add(new GradleProjectRenameChange(gradleName, intellijName)); - } - } - - private void checkLanguageLevel(@NotNull ProjectData gradleProject, - @NotNull Project intellijProject, - @NotNull Set currentChanges) - { - // TODO den implement -// LanguageLevel gradleLevel = gradleProject.getLanguageLevel(); -// LanguageLevel intellijLevel = myPlatformFacade.getLanguageLevel(intellijProject); -// if (gradleLevel != intellijLevel) { -// currentChanges.add(new LanguageLevelChange(gradleLevel, intellijLevel)); -// } - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleAdjustImportSettingsUtil.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleAdjustImportSettingsUtil.java deleted file mode 100644 index 9910ad2271f1..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleAdjustImportSettingsUtil.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.jetbrains.plugins.gradle.manage.wizard.adjust; - -import com.intellij.openapi.externalSystem.model.project.AbstractDependencyData; -import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; -import com.intellij.openapi.externalSystem.util.ExternalSystemUiUtil; -import com.intellij.openapi.roots.DependencyScope; -import com.intellij.openapi.ui.MessageType; -import com.intellij.openapi.util.Pair; -import com.intellij.openapi.util.text.StringUtil; -import org.jetbrains.annotations.NotNull; -import com.intellij.openapi.externalSystem.model.project.Named; -import org.jetbrains.plugins.gradle.util.GradleUtil; - -import javax.swing.*; - -/** - * @author Denis Zhdanov - * @since 8/24/11 2:40 PM - */ -public class GradleAdjustImportSettingsUtil { - - private GradleAdjustImportSettingsUtil() { - } - - /** - * Performs generic check of the name of the given component. - * - * @param namedComponent target component - * @param componentNameUI UI control that allow to manage target component's name - * @return true if validation is successful; false otherwise - */ - public static boolean validate(@NotNull Named namedComponent, @NotNull JComponent componentNameUI) { - if (!StringUtil.isEmptyOrSpaces(namedComponent.getName())) { - return true; - } - // TODO den uncomment - //ExternalSystemUiUtil.showBalloon(componentNameUI, MessageType.ERROR, ExternalSystemBundle.message("gradle.import.text.error.undefined.name")); - return false; - } - - /** - * Allows to configure GUI controls for managing common dependency settings. - * - * @param builder target GUI builder - * @param dependency target dependency - * @return pair of two callbacks. The first one is {@link GradleProjectStructureNodeSettings#refresh() 'refresh'} callback, - * the second one is {@link GradleProjectStructureNodeSettings#validate() 'validate'} callback - */ - @NotNull - public static Pair configureCommonDependencyControls(@NotNull GradleProjectSettingsBuilder builder, - @NotNull final AbstractDependencyData dependency) - { - builder.setKeyAndValueControlsOnSameRow(true); - - final JCheckBox exportedCheckBock = new JCheckBox(); - // TODO den uncomment - //builder.add("gradle.import.structure.settings.label.export", exportedCheckBock); - - final JComboBox scopeComboBox = new JComboBox(DependencyScope.values()); - // TODO den uncomment - //builder.add("gradle.import.structure.settings.label.scope", scopeComboBox); - - Runnable refreshCallback = new Runnable() { - @Override - public void run() { - exportedCheckBock.setSelected(dependency.isExported()); - scopeComboBox.setSelectedItem(dependency.getScope()); - } - }; - - Runnable validateCallback = new Runnable() { - @Override - public void run() { - dependency.setExported(exportedCheckBock.isSelected()); - dependency.setScope((DependencyScope)scopeComboBox.getSelectedItem()); - } - }; - return new Pair(refreshCallback, validateCallback); - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleContentRootSettings.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleContentRootSettings.java deleted file mode 100644 index edcedf050632..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleContentRootSettings.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.jetbrains.plugins.gradle.manage.wizard.adjust; - -import com.intellij.ide.util.projectWizard.NamePathComponent; -import com.intellij.openapi.externalSystem.model.project.ContentRootData; -import com.intellij.openapi.externalSystem.model.project.ExternalSystemSourceType; -import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; -import com.intellij.util.containers.ContainerUtilRt; -import org.jetbrains.annotations.NotNull; - -import javax.swing.*; -import java.util.Collection; -import java.util.EnumMap; -import java.util.Map; - -/** - * @author Denis Zhdanov - * @since 10/31/11 1:52 PM - */ -public class GradleContentRootSettings implements GradleProjectStructureNodeSettings { - - private static final Map ROOT_TYPE_TITLES = ContainerUtilRt.newHashMap(); - - static { - // TODO den implement -// ROOT_TYPE_TITLES.put(ExternalSystemSourceType.SOURCE, -// ExternalSystemBundle.message("gradle.import.structure.settings.label.root.source")); -// ROOT_TYPE_TITLES.put(ExternalSystemSourceType.TEST, -// ExternalSystemBundle.message("gradle.import.structure.settings.label.root.test")); -// ROOT_TYPE_TITLES.put(ExternalSystemSourceType.EXCLUDED, -// ExternalSystemBundle.message("gradle.import.structure.settings.label.root.excluded")); - } - - @NotNull private final JComponent myComponent; - - public GradleContentRootSettings(@NotNull ContentRootData contentRoot) { - GradleProjectSettingsBuilder builder = new GradleProjectSettingsBuilder(); - // TODO den implement -// for (ExternalSystemSourceType sourceType : ExternalSystemSourceType.values()) { -// Collection paths = contentRoot.getPaths(sourceType); -// if (paths.isEmpty()) { -// continue; -// } -// builder.add(new JLabel(ROOT_TYPE_TITLES.get(sourceType))); -// for (String path : paths) { -// NamePathComponent component = new NamePathComponent("", " ", "", "", false); -// component.setNameComponentVisible(false); -// component.setPath(path); -// component.getPathPanel().setEditable(false); -// builder.add(component, GradleProjectSettingsBuilder.InsetSize.SMALL); -// } -// } - myComponent = builder.build(); - } - - @Override - public boolean validate() { - return true; - } - - @Override - public void refresh() { - } - - @NotNull - @Override - public JComponent getComponent() { - return myComponent; - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleJarSettings.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleJarSettings.java deleted file mode 100644 index c187fecee849..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleJarSettings.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2000-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.plugins.gradle.manage.wizard.adjust; - -import com.intellij.ide.util.projectWizard.NamePathComponent; -import com.intellij.openapi.externalSystem.model.project.JarData; -import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; -import org.jetbrains.annotations.NotNull; - -import javax.swing.*; - -/** - * @author Denis Zhdanov - * @since 12/12/12 2:16 PM - */ -public class GradleJarSettings implements GradleProjectStructureNodeSettings { - - @NotNull private final JComponent myComponent; - - public GradleJarSettings(@NotNull JarData jar) { - GradleProjectSettingsBuilder builder = new GradleProjectSettingsBuilder(); - builder.add(new JLabel(ExternalSystemBundle.message("gradle.import.structure.settings.label.jar.path"))); - NamePathComponent component = new NamePathComponent("", " ", "", "", false); - component.setNameComponentVisible(false); - component.setPath(jar.getPath()); - component.getPathPanel().setEditable(false); - builder.add(component, GradleProjectSettingsBuilder.InsetSize.SMALL); - - myComponent = builder.build(); - } - - @Override - public boolean validate() { - return true; - } - - @Override - public void refresh() { - } - - @NotNull - @Override - public JComponent getComponent() { - return myComponent; - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleLibraryDependencySettings.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleLibraryDependencySettings.java deleted file mode 100644 index 320c47798c78..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleLibraryDependencySettings.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.jetbrains.plugins.gradle.manage.wizard.adjust; - -import com.intellij.openapi.externalSystem.model.project.LibraryDependencyData; -import com.intellij.openapi.util.Pair; -import org.jetbrains.annotations.NotNull; - -import javax.swing.*; - -/** - * @author Denis Zhdanov - * @since 10/24/11 3:00 PM - */ -public class GradleLibraryDependencySettings implements GradleProjectStructureNodeSettings { - - private final GradleLibrarySettings myLibrarySettings; - private final Runnable myRefreshCallback; - private final Runnable myValidateCallback; - private final JComponent myComponent; - - public GradleLibraryDependencySettings(@NotNull LibraryDependencyData dependency) { - myLibrarySettings = new GradleLibrarySettings(); - - GradleProjectSettingsBuilder builder = new GradleProjectSettingsBuilder(); - builder.add(myLibrarySettings.getComponent(), GradleProjectSettingsBuilder.InsetSize.NONE); - Pair pair = GradleAdjustImportSettingsUtil.configureCommonDependencyControls(builder, dependency); - myRefreshCallback = pair.first; - myValidateCallback = pair.second; - myComponent = builder.build(); - refresh(); - } - - @Override - public void refresh() { - myLibrarySettings.refresh(); - myRefreshCallback.run(); - } - - @Override - public boolean validate() { - if (!myLibrarySettings.validate()) { - return false; - } - myValidateCallback.run(); - return true; - } - - @NotNull - @Override - public JComponent getComponent() { - return myComponent; - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleLibrarySettings.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleLibrarySettings.java deleted file mode 100644 index ad00e7e97554..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleLibrarySettings.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.jetbrains.plugins.gradle.manage.wizard.adjust; - -import org.jetbrains.annotations.NotNull; - -import javax.swing.*; - -/** - * @author Denis Zhdanov - * @since 8/23/11 4:22 PM - */ -public class GradleLibrarySettings implements GradleProjectStructureNodeSettings { - - private final JComponent myComponent; - - public GradleLibrarySettings() { - myComponent = new JPanel(); - } - - @Override - public boolean validate() { - return true; - } - - @Override - public void refresh() { - } - - @NotNull - @Override - public JComponent getComponent() { - return myComponent; - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleModuleDependencySettings.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleModuleDependencySettings.java deleted file mode 100644 index fbd0ec8e2ae1..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleModuleDependencySettings.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.jetbrains.plugins.gradle.manage.wizard.adjust; - -import com.intellij.openapi.externalSystem.model.project.ModuleDependencyData; -import com.intellij.openapi.util.Pair; -import org.jetbrains.annotations.NotNull; - -import javax.swing.*; - -/** - * @author Denis Zhdanov - * @since 10/28/11 12:40 PM - */ -public class GradleModuleDependencySettings implements GradleProjectStructureNodeSettings { - - private final GradleModuleSettings myModuleSettings; - private final Runnable myRefreshCallback; - private final Runnable myValidateCallback; - private final JComponent myComponent; - - public GradleModuleDependencySettings(@NotNull ModuleDependencyData dependency) { - myModuleSettings = new GradleModuleSettings(dependency.getTarget()); - - GradleProjectSettingsBuilder builder = new GradleProjectSettingsBuilder(); - builder.add(myModuleSettings.getComponent(), GradleProjectSettingsBuilder.InsetSize.NONE); - Pair pair = GradleAdjustImportSettingsUtil.configureCommonDependencyControls(builder, dependency); - myRefreshCallback = pair.first; - myValidateCallback = pair.second; - myComponent = builder.build(); - refresh(); - } - - @Override - public boolean validate() { - if (!myModuleSettings.validate()) { - return false; - } - myValidateCallback.run(); - return true; - } - - @Override - public void refresh() { - myModuleSettings.refresh(); - myRefreshCallback.run(); - } - - @NotNull - @Override - public JComponent getComponent() { - return myComponent; - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleModuleSettings.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleModuleSettings.java deleted file mode 100644 index 4406d227d7eb..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleModuleSettings.java +++ /dev/null @@ -1,134 +0,0 @@ -package org.jetbrains.plugins.gradle.manage.wizard.adjust; - -import com.intellij.ide.util.BrowseFilesListener; -import com.intellij.openapi.externalSystem.model.project.ModuleData; -import com.intellij.openapi.externalSystem.model.project.ExternalSystemSourceType; -import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; -import com.intellij.openapi.externalSystem.util.ExternalSystemUiUtil; -import com.intellij.openapi.project.ProjectBundle; -import com.intellij.openapi.ui.MessageType; -import com.intellij.openapi.ui.TextFieldWithBrowseButton; -import com.intellij.openapi.util.Pair; -import com.intellij.openapi.util.text.StringUtil; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.plugins.gradle.util.GradleUtil; - -import javax.swing.*; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; - -/** - * Manages settings of {@link ModuleData gradle module} component. - * - * @author Denis Zhdanov - * @since 8/12/11 3:39 PM - */ -public class GradleModuleSettings implements GradleProjectStructureNodeSettings { - - private final JComponent myComponent; - private final ModuleData myModule; - private final JRadioButton myInheritProjectCompileOutputPathButton; - private final JRadioButton myUseModuleCompileOutputPathButton; - private final TextFieldWithBrowseButton myOutputLocationField; - private final TextFieldWithBrowseButton myTestOutputLocationField; - - public GradleModuleSettings(@NotNull ModuleData module) { - myModule = module; - GradleProjectSettingsBuilder builder = new GradleProjectSettingsBuilder(); - Pair pair = setupCompileOutput(builder); - myInheritProjectCompileOutputPathButton = pair.first; - myUseModuleCompileOutputPathButton = pair.second; - Pair locationPair = setupOutputLocation(builder); - myOutputLocationField = locationPair.first; - myTestOutputLocationField = locationPair.second; - myComponent = builder.build(); - refresh(); - } - - @NotNull - private Pair setupCompileOutput(@NotNull GradleProjectSettingsBuilder builder) { - JRadioButton inheritButton = new JRadioButton(ProjectBundle.message("project.inherit.compile.output.path")); - JRadioButton moduleButton = new JRadioButton(ProjectBundle.message("project.module.compile.output.path")); - ButtonGroup group = new ButtonGroup(); - group.add(inheritButton); - group.add(moduleButton); - builder.add(inheritButton); - builder.add(moduleButton, GradleProjectSettingsBuilder.InsetSize.SMALL); - ItemListener listener = new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - myOutputLocationField.setEditable(myUseModuleCompileOutputPathButton.isSelected()); - myTestOutputLocationField.setEditable(myUseModuleCompileOutputPathButton.isSelected()); - } - }; - inheritButton.addItemListener(listener); - moduleButton.addItemListener(listener); - return new Pair(inheritButton, moduleButton); - } - - @NotNull - private static Pair setupOutputLocation( - @NotNull GradleProjectSettingsBuilder builder) - { - TextFieldWithBrowseButton outputField = new TextFieldWithBrowseButton(); - String title = ProjectBundle.message("module.paths.output.label"); - outputField.addBrowseFolderListener(title, "", null, BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR); - builder.add(new JLabel(title), outputField, GradleProjectSettingsBuilder.InsetSize.SMALL); - - TextFieldWithBrowseButton testOutputField = new TextFieldWithBrowseButton(); - title = ProjectBundle.message("module.paths.test.output.label"); - testOutputField.addBrowseFolderListener(title, "", null, BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR); - builder.add(new JLabel(title), testOutputField, GradleProjectSettingsBuilder.InsetSize.SMALL); - - return new Pair(outputField, testOutputField); - } - - @Override - public boolean validate() { - if (myUseModuleCompileOutputPathButton.isSelected()) { - String outputLocation = myOutputLocationField.getText(); - if (outputLocation == null || StringUtil.isEmpty(outputLocation.trim())) { - // TODO den uncomment - } - // ExternalSystemUiUtil.showBalloon( - // myOutputLocationField, - // MessageType.ERROR, - // ExternalSystemBundle.message("gradle.import.text.error.file.module.compile.output.location") - // ); - // return false; - //} - String testOutputLocation = myTestOutputLocationField.getText(); - // TODO den uncomment - //if (testOutputLocation == null || StringUtil.isEmpty(testOutputLocation.trim())) { - // ExternalSystemUiUtil.showBalloon( - // myTestOutputLocationField, - // MessageType.ERROR, - // ExternalSystemBundle.message("gradle.import.text.error.file.module.test.output.location") - // ); - // return false; - //} - myModule.setCompileOutputPath(ExternalSystemSourceType.SOURCE, outputLocation.trim()); - myModule.setCompileOutputPath(ExternalSystemSourceType.TEST, testOutputLocation.trim()); - } - myModule.setInheritProjectCompileOutputPath(myInheritProjectCompileOutputPathButton.isSelected()); - return true; - } - - @Override - public void refresh() { - if (myModule.isInheritProjectCompileOutputPath()) { - myInheritProjectCompileOutputPathButton.setSelected(true); - } - else { - myUseModuleCompileOutputPathButton.setSelected(true); - } - myOutputLocationField.setText(myModule.getCompileOutputPath(ExternalSystemSourceType.SOURCE)); - myTestOutputLocationField.setText(myModule.getCompileOutputPath(ExternalSystemSourceType.TEST)); - } - - @NotNull - @Override - public JComponent getComponent() { - return myComponent; - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleProjectSettings.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleProjectSettings.java deleted file mode 100644 index c0ac1f441027..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleProjectSettings.java +++ /dev/null @@ -1,271 +0,0 @@ -package org.jetbrains.plugins.gradle.manage.wizard.adjust; - -import com.intellij.ide.util.PropertiesComponent; -import com.intellij.openapi.externalSystem.model.project.ProjectData; -import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; -import com.intellij.openapi.externalSystem.util.ExternalSystemUiUtil; -import com.intellij.openapi.projectRoots.JavaSdk; -import com.intellij.openapi.projectRoots.JavaSdkVersion; -import com.intellij.openapi.projectRoots.ProjectJdkTable; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.openapi.ui.MessageType; -import com.intellij.openapi.ui.TextFieldWithBrowseButton; -import com.intellij.openapi.util.io.FileUtilRt; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.pom.java.LanguageLevel; -import com.intellij.ui.components.JBRadioButton; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.PropertyKey; -import org.jetbrains.plugins.gradle.util.GradleBundle; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Manages settings of {@link ProjectData gradle project} component. - * - * @author Denis Zhdanov - * @since 8/12/11 2:58 PM - */ -public class GradleProjectSettings implements GradleProjectStructureNodeSettings { - - private static final String KEEP_IML_AT_MODULE_DIR_PROPERTY_KEY = "gradle.iml.at.module.dir"; - - @NotNull private final JComponent myComponent; - @NotNull private final ProjectData myProject; - @NotNull private final JComboBox myLanguageLevelComboBox; - @NotNull private final DefaultComboBoxModel mySdkModel; - @NotNull private final TextFieldWithBrowseButton myProjectConfigLocationField; - @NotNull private final TextFieldWithBrowseButton myProjectCompileOutputLocationField; - @NotNull private final JRadioButton myImlAtModuleContentRootsButton; - @NotNull private final JRadioButton myImlAtProjectDirButton; - - public GradleProjectSettings(@NotNull ProjectData project) { - myProject = project; - GradleProjectSettingsBuilder builder = new GradleProjectSettingsBuilder(); - myLanguageLevelComboBox = setupLanguageLevelControls(builder); - setupSdkControls(mySdkModel = new DefaultComboBoxModel(), builder); - myProjectConfigLocationField = setupProjectConfigLocation(builder); - myProjectCompileOutputLocationField = setupProjectCompileOutputLocation(builder); - filterSdksByLanguageLevel(); - myImlAtModuleContentRootsButton = - new JBRadioButton(GradleBundle.message("gradle.import.structure.settings.label.iml.location.per.module")); - myImlAtProjectDirButton = new JBRadioButton( - GradleBundle.message("gradle.import.structure.settings.label.iml.location.project.dir")); - setModuleFilesLocationControl(builder); - myComponent = builder.build(); - refresh(); - } - - private JComboBox setupLanguageLevelControls(@NotNull GradleProjectSettingsBuilder builder) { - JComboBox result = new JComboBox(); - final Map levels = new HashMap(); - for (LanguageLevel level : LanguageLevel.values()) { - levels.put(level.getPresentableText(), level); - result.addItem(level.getPresentableText()); - } - result.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - // TODO den implement -// myProject.setLanguageLevel(levels.get(e.getItem())); - filterSdksByLanguageLevel(); - } - }); - // TODO den implement -// builder.add("gradle.import.structure.settings.label.language.level", result); - return result; - } - - private void filterSdksByLanguageLevel() { - Object selectedItem = mySdkModel.getSelectedItem(); - mySdkModel.removeAllElements(); - // TODO den implement - LanguageLevel languageLevel = null; -// LanguageLevel languageLevel = myProject.getLanguageLevel(); - boolean restoreSelection = false; - List matchedRegisteredSdks = new ArrayList(); - JavaSdk javaSdk = JavaSdk.getInstance(); - List javaSdks = ProjectJdkTable.getInstance().getSdksOfType(javaSdk); - for (Sdk sdk : javaSdks) { - JavaSdkVersion version = javaSdk.getVersion(sdk); - if (version == null || !version.getMaxLanguageLevel().isAtLeast(languageLevel)) { - continue; - } - matchedRegisteredSdks.add(sdk); - } - - // TODO den implement -// if (matchedRegisteredSdks.isEmpty()) { -// mySdkModel.addElement(ExternalSystemBundle.message("gradle.import.structure.settings.no.sdk.for.language.level.text")); -// } - - for (Sdk sdk : matchedRegisteredSdks) { - mySdkModel.addElement(sdk.getName()); - if (sdk.getName().equals(selectedItem)) { - restoreSelection = true; - } - } - - if (restoreSelection) { - mySdkModel.setSelectedItem(selectedItem); - } - } - - private void setupSdkControls(@NotNull ComboBoxModel model, @NotNull GradleProjectSettingsBuilder builder) { - // Configure SDK combo box with all jdk versions. - final JComboBox sdkComboBox = new JComboBox(model); - sdkComboBox.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - Object selectedItem = sdkComboBox.getSelectedItem(); - if (selectedItem == null) { - return; - } - Sdk sdk = ProjectJdkTable.getInstance().findJdk(selectedItem.toString()); - if (sdk != null) { - // TODO den implement -// myProject.setSdk(sdk); - } - } - }); - // TODO den implement -// builder.add("gradle.import.structure.settings.label.sdk", sdkComboBox); - } - - @NotNull - private TextFieldWithBrowseButton setupProjectConfigLocation(@NotNull GradleProjectSettingsBuilder builder) { - TextFieldWithBrowseButton result = new TextFieldWithBrowseButton(); - // TODO den implement -// String title = ExternalSystemBundle.message("gradle.import.structure.settings.title.project.config.location"); -// result.addBrowseFolderListener(title, "", null, BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR); -// result.setText(myProject.getProjectFileDirectoryPath()); -// builder.add("gradle.import.structure.settings.label.project.config.location", result); - return result; - } - - @NotNull - private TextFieldWithBrowseButton setupProjectCompileOutputLocation(@NotNull GradleProjectSettingsBuilder builder) { - TextFieldWithBrowseButton result = new TextFieldWithBrowseButton(); - // TODO den implement -// String title = ExternalSystemBundle.message("gradle.import.structure.settings.title.project.compile.output.location"); -// result.addBrowseFolderListener(title, "", null, BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR); -// result.setText(myProject.getCompileOutputPath()); -// builder.add("gradle.import.structure.settings.label.project.compile.output.location", result); - return result; - } - - private void setModuleFilesLocationControl(@NotNull GradleProjectSettingsBuilder builder) { - ButtonGroup group = new ButtonGroup(); - group.add(myImlAtModuleContentRootsButton); - group.add(myImlAtProjectDirButton); - JPanel panel = new JPanel(new GridLayout(2, 1)); - panel.add(myImlAtModuleContentRootsButton); - panel.add(myImlAtProjectDirButton); - myImlAtModuleContentRootsButton.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - if (e.getStateChange() != ItemEvent.SELECTED) { - return; - } - // TODO den implement -// for (ModuleData module : myProject.getModules()) { -// Collection contentRoots = module.getContentRoots(); -// if (contentRoots.isEmpty()) { -// continue; -// } -// module.setModuleFileDirectoryPath(contentRoots.iterator().next().getRootPath()); -// } - PropertiesComponent.getInstance().setValue(KEEP_IML_AT_MODULE_DIR_PROPERTY_KEY, String.valueOf(true)); - } - }); - myImlAtProjectDirButton.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - if (e.getStateChange() != ItemEvent.SELECTED) { - return; - } - String dirPath = myProjectConfigLocationField.getText(); - if (StringUtil.isEmpty(dirPath)) { - return; - } - boolean goodDir = FileUtilRt.createDirectory(new File(dirPath)); - if (!goodDir) { - return; - } - // TODO den implement -// for (ModuleData module : myProject.getModules()) { -// module.setModuleFileDirectoryPath(dirPath); -// } - PropertiesComponent.getInstance().setValue(KEEP_IML_AT_MODULE_DIR_PROPERTY_KEY, String.valueOf(false)); - } - }); - boolean imlAtModuleDir = PropertiesComponent.getInstance().getBoolean(KEEP_IML_AT_MODULE_DIR_PROPERTY_KEY, true); - if (imlAtModuleDir) { - myImlAtModuleContentRootsButton.setSelected(true); - } - else { - myImlAtProjectDirButton.setSelected(true); - } - // TODO den implement -// builder.add("gradle.import.structure.settings.label.iml.location", panel); - } - - @Override - public boolean validate() { - // TODO den implement -// if (!validateDirLocation(myProjectConfigLocationField, "gradle.import.text.error.project.undefined.config.location", -// "gradle.import.text.error.file.config.location")) -// { -// return false; -// } -// myProject.setProjectFileDirectoryPath(myProjectConfigLocationField.getText()); -// -// if (!validateDirLocation(myProjectCompileOutputLocationField, "gradle.import.text.error.undefined.project.compile.output.location", -// "gradle.import.text.error.file.project.compile.output.location")) -// { -// return false; -// } -// myProject.setCompileOutputPath(myProjectCompileOutputLocationField.getText()); - - return true; - } - - @Override - public void refresh() { - myProjectConfigLocationField.setText(myProject.getProjectFileDirectoryPath()); - // TODO den implement -// myProjectCompileOutputLocationField.setText(myProject.getCompileOutputPath()); -// myLanguageLevelComboBox.setSelectedItem(myProject.getLanguageLevel().getPresentableText()); - } - - private static boolean validateDirLocation( - @NotNull TextFieldWithBrowseButton dataHolder, - @NotNull @PropertyKey(resourceBundle = ExternalSystemBundle.PATH_TO_BUNDLE)String undefinedPathMessageKey, - @NotNull @PropertyKey(resourceBundle = ExternalSystemBundle.PATH_TO_BUNDLE) String filePathMessageKey) - { - String path = dataHolder.getText(); - if (path == null || path.trim().isEmpty()) { - ExternalSystemUiUtil.showBalloon(dataHolder, MessageType.ERROR, ExternalSystemBundle.message(undefinedPathMessageKey)); - return false; - } - else if (new File(path).isFile()) { - ExternalSystemUiUtil.showBalloon(dataHolder, MessageType.ERROR, ExternalSystemBundle.message(filePathMessageKey)); - return false; - } - return true; - } - - @NotNull - @Override - public JComponent getComponent() { - return myComponent; - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleProjectSettingsBuilder.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleProjectSettingsBuilder.java deleted file mode 100644 index d4711e5c76c5..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleProjectSettingsBuilder.java +++ /dev/null @@ -1,130 +0,0 @@ -package org.jetbrains.plugins.gradle.manage.wizard.adjust; - -import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.PropertyKey; - -import javax.swing.*; -import java.awt.*; - -/** - * Reliefs implementation of the {@link GradleProjectStructureNodeSettings#getComponent() GUI for managing gradle entity settings}. - *

- * Basically, assumes that all settings are displayed at the two-columns view where left column holds setting name and the right one - * holds GUI control that shows current setting value and/or allows to modify it. - *

- * See method-level documentation for more details. - * - * @author Denis Zhdanov - * @since 8/12/11 3:03 PM - */ -public class GradleProjectSettingsBuilder { - - public enum InsetSize { - NONE(0), SMALL(3), NORMAL(15); - - private final int myInsetValue; - - InsetSize(int insetValue) { - myInsetValue = insetValue; - } - - public int getValue() { - return myInsetValue; - } - } - - private final JPanel myResult = new JPanel(new GridBagLayout()); - private final GridBagConstraints myKeyConstraint = new GridBagConstraints(); - private final GridBagConstraints myValueConstraint = new GridBagConstraints(); - - public GradleProjectSettingsBuilder() { - myKeyConstraint.anchor = myValueConstraint.anchor = GridBagConstraints.WEST; - myKeyConstraint.gridwidth = myValueConstraint.gridwidth = GridBagConstraints.REMAINDER; - myKeyConstraint.weightx = myValueConstraint.weightx = 1; - myKeyConstraint.fill = myValueConstraint.fill = GridBagConstraints.HORIZONTAL; - myKeyConstraint.insets.top = InsetSize.NORMAL.getValue(); - myValueConstraint.insets.top = InsetSize.SMALL.getValue(); - } - - public void add(@NotNull JComponent component) { - add(component, InsetSize.NORMAL); - } - - /** - * Instructs current builder to use given component for the target property management. - * - * @param component component to use - * @param insetSize top insets to use - */ - public void add(@NotNull JComponent component, @NotNull InsetSize insetSize) { - int insetsToRestore = myValueConstraint.insets.top; - myValueConstraint.insets.top = insetSize.getValue(); - myResult.add(component, myValueConstraint); - myValueConstraint.insets.top = insetsToRestore; - } - - /** - * Instructs current builder to use given property key for the setting label name retrieval and given control for - * the settings value processing - * - * @param labelKey bundle key to use for retrieving setting's label name - * @param control GUI control for managing target setting's value - */ - public void add(@NotNull @PropertyKey(resourceBundle = ExternalSystemBundle.PATH_TO_BUNDLE) String labelKey, @NotNull JComponent control) { - myResult.add(new JLabel(ExternalSystemBundle.message(labelKey)), myKeyConstraint); - myResult.add(control, myValueConstraint); - } - - /** - * Shortcut for calling {@link #add(JComponent, JComponent, InsetSize)} with {@link InsetSize#NORMAL}. - * - * @param keyComponent control that provides information about the target property (e.g. its name or description) - * @param valueComponent control that holds available property values and (possibly) allows to choose between them - */ - public void add(@NotNull JComponent keyComponent, @NotNull JComponent valueComponent) { - add(keyComponent, valueComponent, InsetSize.NORMAL); - } - - /** - * Instructs current builder to expose target property using the given UI controls. - * - * @param keyComponent control that provides information about the target property (e.g. its name or description) - * @param valueComponent control that holds available property values and (possibly) allows to choose between them - * @param insetSize top vertical inset to use for the 'key' component - */ - public void add(@NotNull JComponent keyComponent, @NotNull JComponent valueComponent, @NotNull InsetSize insetSize) { - int insetToRestore = myKeyConstraint.insets.top; - myKeyConstraint.insets.top = insetSize.getValue(); - - myResult.add(keyComponent, myKeyConstraint); - myResult.add(valueComponent, myValueConstraint); - - myKeyConstraint.insets.top = insetToRestore; - } - - /** - * Allows to define whether 'key'/'value' components ({@link #add(String, JComponent)}, {@link #add(JComponent, JComponent)}) - * should be located on the same line. - * - * @param sameRow flag that defines whether 'key'/'value' components should be located on the same line - */ - public void setKeyAndValueControlsOnSameRow(boolean sameRow) { - myKeyConstraint.gridwidth = sameRow ? 1 : GridBagConstraints.REMAINDER; - myKeyConstraint.weightx = sameRow ? 0 : 1; - myValueConstraint.insets.top = sameRow ? InsetSize.NORMAL.getValue() : InsetSize.SMALL.getValue(); - } - - /** - * @return GUI component that shows all of the stuff registered earlier via {@link #add(String, JComponent)} - */ - @NotNull - public JComponent build() { - // We don't check that this method hasn't been called already. Add that check if necessary. - GridBagConstraints constraints = new GridBagConstraints(); - constraints.weighty = 1; - constraints.fill = GridBagConstraints.VERTICAL; - myResult.add(new JLabel(""), constraints); - return myResult; - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleProjectStructureFactory.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleProjectStructureFactory.java deleted file mode 100644 index e832caaabd5d..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleProjectStructureFactory.java +++ /dev/null @@ -1,163 +0,0 @@ -package org.jetbrains.plugins.gradle.manage.wizard.adjust; - -import com.intellij.openapi.externalSystem.model.project.*; -import com.intellij.openapi.externalSystem.model.project.id.EntityIdMapper; -import com.intellij.openapi.externalSystem.model.project.id.ProjectEntityId; -import com.intellij.openapi.externalSystem.ui.ProjectStructureNode; -import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; -import com.intellij.openapi.util.Ref; -import org.jetbrains.annotations.NotNull; -import com.intellij.openapi.externalSystem.ui.ProjectStructureNodeDescriptor; -import org.jetbrains.plugins.gradle.util.GradleUtil; - -import javax.swing.tree.DefaultTreeModel; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.Collection; - -/** - * Allows to build various entities related to the 'project structure' view elements. - *

- * Thread-safe. - *

- * This class is not singleton but offers single-point-of-usage field - {@link #INSTANCE}. - * - * @author Denis Zhdanov - * @since 8/12/11 2:52 PM - */ -public class GradleProjectStructureFactory { - - /** Shared instance of the current (stateless) class. */ - public static final GradleProjectStructureFactory INSTANCE = new GradleProjectStructureFactory(); - - @SuppressWarnings({"MethodMayBeStatic", "unchecked"}) - @NotNull - public ProjectStructureNodeDescriptor buildDescriptor(@NotNull T entity) { - final Ref text = new Ref(); - // TODO den implement -// entity.invite(new ExternalEntityVisitor() { -// @Override -// public void visit(@NotNull ProjectData project) { -// text.set(project.getName()); -// } -// -// @Override -// public void visit(@NotNull ModuleData module) { -// text.set(module.getName()); -// } -// -// @Override -// public void visit(@NotNull ContentRootData contentRoot) { -// text.set(ExternalSystemBundle.message("gradle.import.structure.tree.node.content.root")); -// } -// -// @Override -// public void visit(@NotNull LibraryData library) { -// text.set(library.getName()); -// } -// -// @Override -// public void visit(@NotNull JarData jar) { -// text.set(GradleUtil.extractNameFromPath(jar.getPath())); -// } -// -// @Override -// public void visit(@NotNull ModuleDependencyData dependency) { -// visit(dependency.getTarget()); -// } -// -// @Override -// public void visit(@NotNull LibraryDependencyData dependency) { -// visit(dependency.getTarget()); -// } -// -// @Override -// public void visit(@NotNull CompositeLibraryDependencyData dependency) { -// assert false; // We don't expect outdated library during importing project. -// } -// }); - return GradleUtil.buildDescriptor(EntityIdMapper.mapEntityToId(entity), text.get()); - } - - @SuppressWarnings("MethodMayBeStatic") - @NotNull - public GradleProjectStructureNodeSettings buildSettings(@NotNull ProjectEntityData entity, - @NotNull final DefaultTreeModel treeModel, - @NotNull final Collection treeNodes) - { - final Ref result = new Ref(); - // TODO den implement -// entity.invite(new ExternalEntityVisitor() { -// @Override -// public void visit(@NotNull ProjectData project) { -// setupController(project, treeModel, treeNodes); -// result.set(new GradleProjectSettings(project)); -// } -// -// @Override -// public void visit(@NotNull ModuleData module) { -// setupController(module, treeModel, treeNodes); -// result.set(new GradleModuleSettings(module)); -// } -// -// @Override -// public void visit(@NotNull ContentRootData contentRoot) { -// result.set(new GradleContentRootSettings(contentRoot)); -// } -// -// @Override -// public void visit(@NotNull LibraryData library) { -// result.set(new GradleLibrarySettings()); -// } -// -// @Override -// public void visit(@NotNull JarData jar) { -// result.set(new GradleJarSettings(jar)); -// } -// -// @Override -// public void visit(@NotNull ModuleDependencyData dependency) { -// setupController(dependency, treeModel, treeNodes); -// result.set(new GradleModuleDependencySettings(dependency)); -// } -// -// @Override -// public void visit(@NotNull LibraryDependencyData dependency) { -// setupController(dependency, treeModel, treeNodes); -// result.set(new GradleLibraryDependencySettings(dependency)); -// } -// -// @Override -// public void visit(@NotNull CompositeLibraryDependencyData dependency) { -// assert false; // We don't expect outdated library during importing project. -// } -// }); - return result.get(); - } - - /** - * Configures controller that delegates entity state change to all corresponding nodes. - * - * @param entity target entity to wrap - * @param model model of the target tree - * @param treeNodes tree nodes that represent the given entity - */ - @SuppressWarnings("unchecked") - private static void setupController(@NotNull final ProjectEntityData entity, @NotNull final DefaultTreeModel model, - @NotNull final Collection treeNodes) - { - - entity.addPropertyChangeListener(new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - if (!Named.NAME_PROPERTY.equals(evt.getPropertyName())) { - return; - } - for (ProjectStructureNode node : treeNodes) { - node.getDescriptor().setName(evt.getNewValue().toString()); - model.nodeChanged(node); - } - } - }); - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleProjectStructureNodeSettings.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleProjectStructureNodeSettings.java deleted file mode 100644 index 2c5404e0aa4d..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/manage/wizard/adjust/GradleProjectStructureNodeSettings.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.jetbrains.plugins.gradle.manage.wizard.adjust; - -import org.jetbrains.annotations.NotNull; - -import javax.swing.*; - -/** - * Defines contract for the control that exposes settings of particular node of the 'project structure' view derived from gradle. - * - * @author Denis Zhdanov - * @since 8/12/11 2:50 PM - */ -public interface GradleProjectStructureNodeSettings { - - /** - * Asks current component to validate current model state, i.e. expected actions sequence is below: - *

- *

-   * 
    - *
  1. - * Particular node settings are {@link #getComponent() exposed} to the end user; - *
  2. - *
  3. He or she tweaks the settings;
  4. - *
  5. This method is called on request to finish editing;
  6. - *
- *
- * - * @return true if everything is ok; false otherwise - */ - boolean validate(); - - /** - * Asks current control to refresh, i.e. show values stored at the underlying model. - */ - void refresh(); - - @NotNull - JComponent getComponent(); -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleProjectResolver.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleProjectResolver.java index 209cefc332f1..354d5a298bb0 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleProjectResolver.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleProjectResolver.java @@ -1,12 +1,13 @@ package org.jetbrains.plugins.gradle.service.project; +import com.intellij.externalSystem.JavaProjectData; import com.intellij.openapi.externalSystem.model.DataNode; import com.intellij.openapi.externalSystem.model.ExternalSystemException; import com.intellij.openapi.externalSystem.model.ProjectKeys; import com.intellij.openapi.externalSystem.model.project.*; import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId; import com.intellij.openapi.externalSystem.service.project.ExternalSystemProjectResolver; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; +import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil; import com.intellij.openapi.roots.DependencyScope; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.io.FileUtil; @@ -98,14 +99,14 @@ public class GradleProjectResolver implements ExternalSystemProjectResolver, IdeaModule>> modules = createModules(project, result); populateModules(modules.values(), result); - Collection> libraries = ExternalSystemUtil.getChildren(result, ProjectKeys.LIBRARY); + Collection> libraries = ExternalSystemApiUtil.getChildren(result, ProjectKeys.LIBRARY); myLibraryNamesMixer.mixNames(libraries); return result; } @NotNull private static DataNode populateProject(@NotNull IdeaProject project, @NotNull String projectPath) { - String projectDirPath = ExternalSystemUtil.toCanonicalPath(PathUtil.getParentPath(projectPath)); + String projectDirPath = ExternalSystemApiUtil.toCanonicalPath(PathUtil.getParentPath(projectPath)); ProjectData projectData = new ProjectData(GradleConstants.SYSTEM_ID, projectDirPath); projectData.setName(project.getName()); @@ -116,7 +117,7 @@ public class GradleProjectResolver implements ExternalSystemProjectResolver result = new DataNode(ProjectKeys.PROJECT, projectData, null); - result.createChild(ProjectKeys.JAVA_PROJECT, javaProjectData); + result.createChild(JavaProjectData.KEY, javaProjectData); return result; } @@ -305,7 +306,7 @@ public class GradleProjectResolver implements ExternalSystemProjectResolver registeredModuleNames = ContainerUtilRt.newHashSet(); - Collection> modulesDataNode = ExternalSystemUtil.getChildren(ideProject, ProjectKeys.MODULE); + Collection> modulesDataNode = ExternalSystemApiUtil.getChildren(ideProject, ProjectKeys.MODULE); for (DataNode moduleDataNode : modulesDataNode) { String name = moduleDataNode.getData().getName(); registeredModuleNames.add(name); @@ -347,7 +348,7 @@ public class GradleProjectResolver implements ExternalSystemProjectResolver libraryData = - ExternalSystemUtil.find(ideProject, ProjectKeys.LIBRARY, new BooleanFunction>() { + ExternalSystemApiUtil.find(ideProject, ProjectKeys.LIBRARY, new BooleanFunction>() { @Override public boolean fun(DataNode node) { return library.equals(node.getData()); diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/GradleProjectImportBuilder.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/GradleProjectImportBuilder.java index 075058f2afa4..d09f8cdafe07 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/GradleProjectImportBuilder.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/GradleProjectImportBuilder.java @@ -15,29 +15,32 @@ */ package org.jetbrains.plugins.gradle.service.settings; +import com.intellij.externalSystem.JavaProjectData; import com.intellij.ide.util.projectWizard.WizardContext; import com.intellij.openapi.externalSystem.model.DataNode; -import com.intellij.openapi.externalSystem.model.ProjectKeys; -import com.intellij.openapi.externalSystem.model.project.JavaProjectData; import com.intellij.openapi.externalSystem.model.project.ProjectData; -import com.intellij.openapi.externalSystem.service.project.manage.*; +import com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager; import com.intellij.openapi.externalSystem.service.project.wizard.AbstractExternalProjectImportBuilder; import com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsManager; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; +import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectManager; +import com.intellij.openapi.projectRoots.JavaSdk; import com.intellij.openapi.projectRoots.JavaSdkVersion; +import com.intellij.openapi.projectRoots.ProjectJdkTable; import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.roots.LanguageLevelProjectExtension; import com.intellij.pom.java.LanguageLevel; import icons.GradleIcons; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.gradle.settings.GradleSettings; import org.jetbrains.plugins.gradle.util.GradleBundle; import org.jetbrains.plugins.gradle.util.GradleConstants; import javax.swing.*; import java.io.File; +import java.util.List; /** * @author Denis Zhdanov @@ -71,7 +74,7 @@ public class GradleProjectImportBuilder extends AbstractExternalProjectImportBui @Override protected void beforeCommit(@NotNull DataNode dataNode, @NotNull Project project) { - DataNode javaProjectNode = ExternalSystemUtil.find(dataNode, ProjectKeys.JAVA_PROJECT); + DataNode javaProjectNode = ExternalSystemApiUtil.find(dataNode, JavaProjectData.KEY); if (javaProjectNode == null) { return; } @@ -90,18 +93,36 @@ public class GradleProjectImportBuilder extends AbstractExternalProjectImportBui return; } - DataNode javaProjectNode = ExternalSystemUtil.find(node, ProjectKeys.JAVA_PROJECT); + DataNode javaProjectNode = ExternalSystemApiUtil.find(node, JavaProjectData.KEY); if (javaProjectNode != null) { JavaProjectData data = javaProjectNode.getData(); context.setCompilerOutputDirectory(data.getCompileOutputPath()); JavaSdkVersion version = data.getJdkVersion(); - Sdk jdk = ExternalSystemUtil.findJdk(version); + Sdk jdk = findJdk(version); if (jdk != null) { context.setProjectJdk(jdk); } } } + @Nullable + private static Sdk findJdk(@NotNull JavaSdkVersion version) { + JavaSdk javaSdk = JavaSdk.getInstance(); + List javaSdks = ProjectJdkTable.getInstance().getSdksOfType(javaSdk); + Sdk candidate = null; + for (Sdk sdk : javaSdks) { + JavaSdkVersion v = javaSdk.getVersion(sdk); + if (v == version) { + return sdk; + } + else if (candidate == null && v != null && version.getMaxLanguageLevel().isAtLeast(version.getMaxLanguageLevel())) { + candidate = sdk; + } + } + return candidate; + } + + @Override protected void onProjectInit(@NotNull Project project) { GradleSettings settings = (GradleSettings)getSettingsManager().getSettings(project, GradleConstants.SYSTEM_ID); diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/settings/GradleExecutionSettings.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/settings/GradleExecutionSettings.java index 0e73d6caaddb..24f5af420fb7 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/settings/GradleExecutionSettings.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/settings/GradleExecutionSettings.java @@ -15,7 +15,7 @@ */ package org.jetbrains.plugins.gradle.settings; -import com.intellij.openapi.externalSystem.service.remote.ExternalSystemExecutionSettings; +import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings; import com.intellij.util.containers.ContainerUtilRt; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/GradleDuplicateLibrariesPreProcessor.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/GradleDuplicateLibrariesPreProcessor.java deleted file mode 100644 index 8368c092c494..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/GradleDuplicateLibrariesPreProcessor.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.plugins.gradle.sync; - -import com.intellij.openapi.externalSystem.model.project.*; -import com.intellij.openapi.externalSystem.service.project.change.ExternalProjectStructureChangesPreProcessor; -import com.intellij.openapi.externalSystem.service.project.manage.LibraryDataService; -import com.intellij.openapi.externalSystem.service.project.manage.LibraryDependencyDataService; -import com.intellij.openapi.project.Project; -import org.jetbrains.annotations.NotNull; - -/** - * There is a possible situation that there are module-local libraries which reference jars similar to those provided by gradle - * as project libraries (IDEA-100968). This class manages that by auto-removing module-local libraries and replacing it by - * references to project-level libraries instead. - * - * @author Denis Zhdanov - * @since 2/13/13 9:15 AM - */ -public class GradleDuplicateLibrariesPreProcessor implements ExternalProjectStructureChangesPreProcessor { - - @NotNull private final LibraryDependencyDataService myDependencyManager; - @NotNull private final LibraryDataService myLibraryManager; - - public GradleDuplicateLibrariesPreProcessor(@NotNull LibraryDependencyDataService manager, @NotNull LibraryDataService manager1) { - myDependencyManager = manager; - myLibraryManager = manager1; - } - - @NotNull - @Override - public ProjectData preProcess(@NotNull ProjectData externalProject, @NotNull final Project ideProject) { - // TODO den implement -// final ProjectStructureHelper projectStructureHelper = ServiceManager.getService(ideProject, ProjectStructureHelper.class); -// for (ModuleData gradleModule : externalProject.getModules()) { -// final Module ideModule = projectStructureHelper.findIdeModule(gradleModule); -// if (ideModule == null) { -// continue; -// } -// ExternalEntityVisitor visitor = new ExternalEntityVisitorAdapter() { -// @Override -// public void visit(@NotNull LibraryDependencyData gradleDependency) { -// LibraryDependencyId id = EntityIdMapper.mapEntityToId(gradleDependency); -// LibraryOrderEntry ideDependency = projectStructureHelper.findIdeModuleLocalLibraryDependency( -// id.getOwnerModuleName(), id.getDependencyName() -// ); -// if (ideDependency == null) { -// return; -// } -// myDependencyManager.removeDependency(ideDependency, true); -// -// ideDependency = projectStructureHelper.findIdeLibraryDependency(id); -// if (ideDependency == null) { -// myDependencyManager.importDependency(gradleDependency, ideModule, true); -// } -// -// LibraryData gradleLibrary = gradleDependency.getTarget(); -// Library ideLibrary = projectStructureHelper.findIdeLibrary(gradleLibrary); -// if (ideLibrary == null) { -// myLibraryManager.importLibrary(gradleLibrary, ideProject, true); -// } -// else { -// myLibraryManager.syncPaths(gradleLibrary, ideLibrary, ideProject, true); -// } -// } -// }; -// for (DependencyData dependency : gradleModule.getDependencies()) { -// dependency.invite(visitor); -// } -// } - - return externalProject; - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/GradleProjectStructureChangesPanel.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/GradleProjectStructureChangesPanel.java deleted file mode 100644 index b209bfa826b6..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/GradleProjectStructureChangesPanel.java +++ /dev/null @@ -1,319 +0,0 @@ -package org.jetbrains.plugins.gradle.sync; - -import com.intellij.ide.ui.customization.CustomizationUtil; -import com.intellij.openapi.actionSystem.PlatformDataKeys; -import com.intellij.openapi.components.ServiceManager; -import com.intellij.openapi.externalSystem.model.ExternalSystemDataKeys; -import com.intellij.openapi.externalSystem.service.project.ProjectStructureServices; -import com.intellij.openapi.externalSystem.ui.ExternalProjectStructureTreeModel; -import com.intellij.openapi.project.Project; -import com.intellij.ui.TreeSpeedSearch; -import com.intellij.ui.treeStructure.Tree; -import com.intellij.util.Alarm; -import com.intellij.util.Consumer; -import com.intellij.util.containers.ContainerUtilRt; -import com.intellij.util.messages.MessageBusConnection; -import com.intellij.util.ui.UIUtil; -import com.intellij.util.ui.tree.TreeModelAdapter; -import com.intellij.util.ui.tree.TreeUtil; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.plugins.gradle.settings.GradleSettingsListener; -import org.jetbrains.plugins.gradle.settings.GradleLocalSettings; -import org.jetbrains.plugins.gradle.config.GradleToolWindowPanel; -import org.jetbrains.plugins.gradle.notification.GradleConfigNotificationManager; -import com.intellij.openapi.externalSystem.ui.ProjectStructureNode; -import org.jetbrains.plugins.gradle.util.GradleConstants; -import org.jetbrains.plugins.gradle.util.GradleUtil; - -import javax.swing.*; -import javax.swing.event.TreeExpansionEvent; -import javax.swing.event.TreeModelEvent; -import javax.swing.event.TreeWillExpandListener; -import javax.swing.tree.ExpandVetoException; -import javax.swing.tree.TreePath; -import java.awt.*; -import java.awt.event.MouseEvent; -import java.awt.event.MouseMotionAdapter; -import java.util.*; -import java.util.List; - -/** - * UI control for showing difference between the gradle and intellij project structure. - * - * @author Denis Zhdanov - * @since 11/3/11 3:58 PM - */ -public class GradleProjectStructureChangesPanel extends GradleToolWindowPanel { - - private static final int COLLAPSE_STATE_PROCESSING_DELAY_MILLIS = 200; - - private static final Comparator PATH_COMPARATOR = new Comparator() { - @Override - public int compare(TreePath o1, TreePath o2) { - return o2.getPathCount() - o1.getPathCount(); - } - }; - - private final Alarm myCollapseStateAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD); - private final List myToolbarControls = new ArrayList(); - - /** Holds list of paths which 'expand/collapse' state should be restored. */ - private final Set myPathsToProcessCollapseState = ContainerUtilRt.newHashSet(); - - private final GradleLocalSettings mySettings; - - private Tree myTree; - private ExternalProjectStructureTreeModel myTreeModel; - private ProjectStructureServices myContext; - private Object myNodeUnderMouse; - private boolean mySuppressCollapseTracking; - - public GradleProjectStructureChangesPanel(@NotNull Project project, - @NotNull ProjectStructureServices context) - { - super(project, GradleConstants.TOOL_WINDOW_TOOLBAR_PLACE); - myContext = context; - myToolbarControls.add(new GradleProjectStructureFiltersPanel()); - mySettings = GradleLocalSettings.getInstance(project); - initContent(); - - MessageBusConnection connection = project.getMessageBus().connect(project); - // TODO den implement -// connection.subscribe(GradleSettingsListener.TOPIC, new GradleSettingsListener() { -// -// private boolean myRefresh; -// private boolean myInBulk; -// -// @Override -// public void onBulkChangeStart() { -// myInBulk = true; -// } -// -// @Override -// public void onBulkChangeEnd() { -// myInBulk = false; -// if (myRefresh) { -// myRefresh = false; -// refreshAll(); -// } -// } -// -// @Override -// public void onLinkedProjectPathChange(@Nullable String oldPath, @Nullable String newPath) { refreshAll(); } -// -// @Override -// public void onPreferLocalGradleDistributionToWrapperChange(boolean currentValue) { refreshAll(); } -// -// @Override -// public void onGradleHomeChange(@Nullable String oldPath, @Nullable String newPath) { refreshAll(); } -// -// @Override -// public void onServiceDirectoryPathChange(@Nullable String oldPath, @Nullable String newPath) { refreshAll(); } -// -// @Override -// public void onUseAutoImportChange(boolean oldValue, boolean newValue) { -// if (newValue) { -// update(); -// } -// } -// -// private void refreshAll() { -// if (myInBulk) { -// myRefresh = true; -// return; -// } -// GradleUtil.refreshProject(getProject(), new Consumer() { -// @Override -// public void consume(String s) { -// GradleConfigNotificationManager notificationManager -// = ServiceManager.getService(getProject(), GradleConfigNotificationManager.class); -// notificationManager.processRefreshError(s); -// UIUtil.invokeLaterIfNeeded(new Runnable() { -// @Override -// public void run() { -// update(); -// } -// }); -// } -// }); -// update(); -// } -// }); - } - - @NotNull - public ExternalProjectStructureTreeModel getTreeModel() { - return myTreeModel; - } - - @NotNull - @Override - protected JComponent buildContent() { - JPanel result = new JPanel(new GridBagLayout()); - // TODO den implement - myTreeModel = null; -// myTreeModel = new ExternalProjectStructureTreeModel(getProject(), myContext, false); - myTree = new Tree(myTreeModel); - myTree.addTreeWillExpandListener(new TreeWillExpandListener() { - @Override - public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException { - if (!mySuppressCollapseTracking) { - mySettings.getWorkingExpandStates().put(getPath(event.getPath()), true); - } - } - - @Override - public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException { - if (!mySuppressCollapseTracking) { - mySettings.getWorkingExpandStates().put(getPath(event.getPath()), false); - } - } - }); - myTreeModel.addTreeModelListener(new TreeModelAdapter() { - @Override - public void treeStructureChanged(TreeModelEvent e) { - scheduleCollapseStateAppliance(e.getTreePath()); - } - - @Override - public void treeNodesInserted(TreeModelEvent e) { - scheduleCollapseStateAppliance(e.getTreePath()); - } - }); - new TreeSpeedSearch(myTree, TreeSpeedSearch.NODE_DESCRIPTOR_TOSTRING, true); - TreeUtil.installActions(myTree); - - GridBagConstraints constraints = new GridBagConstraints(); - constraints.gridwidth = GridBagConstraints.REMAINDER; - constraints.anchor = GridBagConstraints.WEST; - constraints.fill = GridBagConstraints.BOTH; - constraints.weightx = constraints.weighty = 1; - result.add(myTree, constraints); - result.setBackground(myTree.getBackground()); - - CustomizationUtil.installPopupHandler(myTree, GradleConstants.ACTION_GROUP_SYNC_TREE, GradleConstants.SYNC_TREE_CONTEXT_MENU_PLACE); - myTree.addMouseMotionListener(new MouseMotionAdapter() { - @Override - public void mouseMoved(MouseEvent e) { - final TreePath path = myTree.getPathForLocation(e.getX(), e.getY()); - if (path == null) { - return; - } - myNodeUnderMouse = path.getLastPathComponent(); - } - }); - return result; - } - - @NotNull - @Override - protected List getToolbarControls() { - return myToolbarControls; - } - - @Override - protected void updateContent() { - myTreeModel.rebuild(); - } - - @Nullable - @Override - public Object getData(@NonNls String dataId) { - if (ExternalSystemDataKeys.PROJECT_TREE.is(dataId)) { - return myTree; - } - else if (ExternalSystemDataKeys.PROJECT_TREE_MODEL.is(dataId)) { - return myTreeModel; - } - else if (ExternalSystemDataKeys.PROJECT_TREE_SELECTED_NODE.is(dataId)) { - TreePath[] paths = myTree.getSelectionPaths(); - if (paths == null) { - return null; - } - List> result = new ArrayList>(); - for (TreePath path : paths) { - result.add((ProjectStructureNode)path.getLastPathComponent()); - } - return result; - } - else if (ExternalSystemDataKeys.SYNC_TREE_NODE_UNDER_MOUSE.is(dataId)) { - return myNodeUnderMouse; - } - else if (PlatformDataKeys.HELP_ID.is(dataId)) { - return GradleConstants.HELP_TOPIC_TOOL_WINDOW; - } - else { - return super.getData(dataId); - } - } - - /** - * Schedules 'collapse/expand' state restoring for the given path. We can't do that immediately from the tree model listener - * as there is a possible case that other listeners have not been notified about the model state change, hence, attempt to define - * 'collapse/expand' state may bring us to the inconsistent state. - * - * @param path target path - */ - private void scheduleCollapseStateAppliance(@NotNull TreePath path) { - myPathsToProcessCollapseState.add(path); - myCollapseStateAlarm.cancelAllRequests(); - myCollapseStateAlarm.addRequest(new Runnable() { - @Override - public void run() { - // We assume that the paths collection is modified only from the EDT, so, ConcurrentModificationException doesn't have - // a chance. - // Another thing is that we sort the paths in order to process the longest first. That is related to the JTree specifics - // that it automatically expands parent paths on child path expansion. - List paths = new ArrayList(myPathsToProcessCollapseState); - myPathsToProcessCollapseState.clear(); - Collections.sort(paths, PATH_COMPARATOR); - for (TreePath treePath : paths) { - applyCollapseState(treePath); - } - final TreePath rootPath = new TreePath(myTreeModel.getRoot()); - if (myTree.isCollapsed(rootPath)) { - myTree.expandPath(rootPath); - } - } - }, COLLAPSE_STATE_PROCESSING_DELAY_MILLIS); - } - - /** - * Applies stored 'collapse/expand' state to the node located at the given path. - * - * @param path target path - */ - private void applyCollapseState(@NotNull TreePath path) { - final String key = getPath(path); - final Boolean expanded = mySettings.getWorkingExpandStates().get(key); - if (expanded == null) { - return; - } - boolean s = mySuppressCollapseTracking; - mySuppressCollapseTracking = true; - try { - if (expanded) { - myTree.expandPath(path); - } - else { - myTree.collapsePath(path); - } - } - finally { - mySuppressCollapseTracking = s; - } - } - - @NotNull - private static String getPath(@NotNull TreePath path) { - StringBuilder buffer = new StringBuilder(); - for (TreePath current = path; current != null; current = current.getParentPath()) { - // TODO den implement -// buffer.append(current.getLastPathComponent().toString()).append(GradleUtil.PATH_SEPARATOR); - } - buffer.setLength(buffer.length() - 1); - return buffer.toString(); - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/GradleProjectStructureFiltersPanel.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/GradleProjectStructureFiltersPanel.java deleted file mode 100644 index 46b61c7f1bb0..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/GradleProjectStructureFiltersPanel.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.jetbrains.plugins.gradle.sync; - -import com.intellij.openapi.actionSystem.ActionGroup; -import com.intellij.openapi.actionSystem.ActionManager; -import com.intellij.openapi.actionSystem.ActionToolbar; -import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; -import org.jetbrains.plugins.gradle.util.GradleConstants; - -import javax.swing.*; - -/** - * @author Denis Zhdanov - * @since 3/6/12 3:44 PM - */ -public class GradleProjectStructureFiltersPanel extends JPanel { - - - public GradleProjectStructureFiltersPanel() { - setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); - add(Box.createHorizontalStrut(7)); - add(new JLabel(ExternalSystemBundle.message("gradle.import.structure.settings.label.filters"))); - final ActionManager actionManager = ActionManager.getInstance(); - final ActionGroup group = (ActionGroup)actionManager.getAction("Gradle.SyncTreeFilter"); - final ActionToolbar toolbar = actionManager.createActionToolbar(GradleConstants.SYNC_TREE_FILTER_PLACE, group, true); - add(toolbar.getComponent()); - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/conflict/GradleCommonDependencyConflictControlFactory.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/conflict/GradleCommonDependencyConflictControlFactory.java deleted file mode 100644 index 20b671c450f1..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/conflict/GradleCommonDependencyConflictControlFactory.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.jetbrains.plugins.gradle.sync.conflict; - -import com.intellij.openapi.externalSystem.model.project.change.*; -import com.intellij.openapi.externalSystem.model.project.id.EntityIdMapper; -import com.intellij.openapi.externalSystem.model.project.id.ProjectEntityId; -import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; -import com.intellij.openapi.roots.ExportableOrderEntry; -import com.intellij.openapi.util.Ref; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import com.intellij.openapi.externalSystem.model.project.change.DependencyExportedChange; -import org.jetbrains.plugins.gradle.ui.MatrixControlBuilder; -import org.jetbrains.plugins.gradle.util.GradleUtil; - -import javax.swing.*; -import java.util.Collection; - -/** - * Encapsulates functionality of building UI that represents common dependency settings conflicts (scope, 'exported'). - *

- * Thread-safe. - * - * @author Denis Zhdanov - * @since 3/14/12 2:20 PM - */ -public class GradleCommonDependencyConflictControlFactory { - - /** - * Allows to build UI for showing common dependency settings conflicts (scope, 'exported'). - * - * @param dependency target dependency which conflict changes should be shown - * @param changes target changes to use represent - * @return UI control for showing common dependency settings conflicts if they are present at the given settings; - * null otherwise - */ - @SuppressWarnings("MethodMayBeStatic") - @Nullable - public JComponent getControl(@NotNull ExportableOrderEntry dependency, @NotNull Collection changes) { - final ProjectEntityId id = EntityIdMapper.mapEntityToId(dependency); - final Ref scopeChangeRef = new Ref(); - final Ref exportedChangeRef = new Ref(); - ExternalProjectStructureChangeVisitor visitor = new ExternalProjectStructureChangeVisitorAdapter() { - @Override - public void visit(@NotNull DependencyScopeChange change) { - if (id.equals(change.getEntityId())) { - scopeChangeRef.set(change); - } - } - - @Override - public void visit(@NotNull DependencyExportedChange change) { - if (id.equals(change.getEntityId())) { - exportedChangeRef.set(change); - } - } - }; - for (ExternalProjectStructureChange change : changes) { - if (scopeChangeRef.get() != null && exportedChangeRef.get() != null) { - break; - } - change.invite(visitor); - } - - final DependencyScopeChange scopeChange = scopeChangeRef.get(); - final DependencyExportedChange exportedChange = exportedChangeRef.get(); - if (scopeChange == null && exportedChange == null) { - return null; - } - MatrixControlBuilder builder = GradleUtil.getConflictChangeBuilder(); - if (scopeChange != null) { - builder.addRow(ExternalSystemBundle.message("gradle.sync.change.dependency.scope.text"), - scopeChange.getExternalValue(), scopeChange.getIdeValue()); - } - if (exportedChange != null) { - builder.addRow(ExternalSystemBundle.message("gradle.sync.change.dependency.exported.text"), - exportedChange.getExternalValue(), exportedChange.getIdeValue()); - } - return builder.build(); - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/conflict/GradleConflictControlFactory.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/conflict/GradleConflictControlFactory.java deleted file mode 100644 index 2fd5d64d2fd1..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/conflict/GradleConflictControlFactory.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.jetbrains.plugins.gradle.sync.conflict; - -import com.intellij.openapi.externalSystem.model.project.change.ExternalProjectStructureChange; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.LibraryOrderEntry; -import com.intellij.openapi.roots.ModuleOrderEntry; -import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.util.Ref; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import com.intellij.openapi.externalSystem.util.IdeEntityVisitor; -import com.intellij.openapi.externalSystem.service.project.ModuleAwareContentRoot; -import org.jetbrains.plugins.gradle.util.GradleUtil; - -import javax.swing.*; -import java.util.Collection; - -/** - * We want to be able to show changes for the conflicting gradle and intellij project structure entities. - *

- * For example, there is a possible case that particular library has a different classpath configuration at the gradle and the intellij. - * We want to be able to show them to the user. - *

- * This class allows to retrieve UI controls for such a conflicting changes. - *

- * Thread-safe. - * - * @author Denis Zhdanov - * @since 3/2/12 3:03 PM - */ -public class GradleConflictControlFactory { - - @NotNull private final GradleProjectConflictControlFactory myProjectFactory; - @NotNull private final GradleCommonDependencyConflictControlFactory myCommonDependencyFactory; - - public GradleConflictControlFactory(@NotNull GradleProjectConflictControlFactory factory, - @NotNull GradleCommonDependencyConflictControlFactory commonDependencyFactory) { - myProjectFactory = factory; - myCommonDependencyFactory = commonDependencyFactory; - } - - /** - * Tries to build UI control for showing the differences between the gradle and intellij setup of the given project structure entity. - * - * @param entity target entity - * @param changes known changes for the given entity - * @return UI control for showing the differences between the gradle and intellij setup of the given project structure entity; - * null if there are no differences or if we don't know how to show them - */ - @Nullable - public JComponent getDiffControl(@NotNull Object entity, final @NotNull Collection changes) { - final Ref result = new Ref(); - // TODO den implement -// GradleUtil.dispatch(entity, new IdeEntityVisitor() { -// @Override -// public void visit(@NotNull Project project) { -// result.set(myProjectFactory.getControl(changes)); -// } -// -// @Override -// public void visit(@NotNull Module module) { -// } -// -// @Override -// public void visit(@NotNull ModuleAwareContentRoot contentRoot) { -// } -// -// @Override -// public void visit(@NotNull LibraryOrderEntry libraryDependency) { -// result.set(myCommonDependencyFactory.getControl(libraryDependency, changes)); -// } -// -// @Override -// public void visit(@NotNull ModuleOrderEntry moduleDependency) { -// result.set(myCommonDependencyFactory.getControl(moduleDependency, changes)); -// } -// -// @Override -// public void visit(@NotNull Library library) { -// } -// }); - return result.get(); - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/conflict/GradleProjectConflictControlFactory.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/conflict/GradleProjectConflictControlFactory.java deleted file mode 100644 index ecd6cea238f0..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/conflict/GradleProjectConflictControlFactory.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.jetbrains.plugins.gradle.sync.conflict; - -import com.intellij.openapi.externalSystem.model.project.change.*; -import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; -import com.intellij.openapi.util.Ref; -import com.intellij.pom.java.LanguageLevel; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import com.intellij.openapi.externalSystem.model.project.change.LanguageLevelChange; -import org.jetbrains.plugins.gradle.ui.MatrixControlBuilder; -import org.jetbrains.plugins.gradle.util.GradleUtil; - -import javax.swing.*; -import java.util.Collection; - -/** - * Thread-safe. - * - * @author Denis Zhdanov - * @since 3/15/12 4:26 PM - */ -public class GradleProjectConflictControlFactory { - - @SuppressWarnings("MethodMayBeStatic") - @Nullable - public JComponent getControl(Collection changes) { - final Ref renameChangeRef = new Ref(); - final Ref languageLevelChangeRef = new Ref(); - - ExternalProjectStructureChangeVisitor visitor = new ExternalProjectStructureChangeVisitorAdapter() { - @Override - public void visit(@NotNull GradleProjectRenameChange change) { - renameChangeRef.set(change); - } - - @Override - public void visit(@NotNull LanguageLevelChange change) { - languageLevelChangeRef.set(change); - } - }; - - for (ExternalProjectStructureChange change : changes) { - if (renameChangeRef.get() != null && languageLevelChangeRef.get() != null) { - break; - } - change.invite(visitor); - } - - final GradleProjectRenameChange renameChange = renameChangeRef.get(); - final LanguageLevelChange languageLevelChange = languageLevelChangeRef.get(); - if (renameChange == null && languageLevelChange == null) { - return null; - } - - MatrixControlBuilder builder = GradleUtil.getConflictChangeBuilder(); - if (renameChange != null) { - builder.addRow(ExternalSystemBundle.message("gradle.import.structure.settings.label.name"), - renameChange.getExternalValue(), renameChange.getIdeValue()); - } - - if (languageLevelChange != null) { - builder.addRow(ExternalSystemBundle.message("gradle.import.structure.settings.label.language.level"), - getTextToShow(languageLevelChange.getExternalValue()), getTextToShow(languageLevelChange.getIdeValue())); - } - - return builder.build(); - } - - @NotNull - private static String getTextToShow(@NotNull LanguageLevel level) { - final String s = level.toString(); - return s.substring(s.indexOf('1')).replace('_', '.'); - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/GradleToolWindowFactory.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/GradleToolWindowFactory.java index ccd65695194d..3a4e833ba001 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/GradleToolWindowFactory.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/GradleToolWindowFactory.java @@ -15,7 +15,6 @@ import com.intellij.ui.content.ContentManager; import com.intellij.ui.content.ContentManagerAdapter; import com.intellij.ui.content.ContentManagerEvent; import com.intellij.ui.content.impl.ContentImpl; -import org.jetbrains.plugins.gradle.sync.GradleProjectStructureChangesPanel; import org.jetbrains.plugins.gradle.tasks.GradleTasksPanel; import org.jetbrains.plugins.gradle.util.GradleConstants; @@ -25,31 +24,13 @@ public class GradleToolWindowFactory implements ToolWindowFactory, DumbAware { public void createToolWindowContent(final Project project, final ToolWindow toolWindow) { final ProjectStructureServices context = ServiceManager.getService(project, ProjectStructureServices.class); - // Project structure. - final GradleProjectStructureChangesPanel projectStructurePanel = new GradleProjectStructureChangesPanel(project, context); - final String projectStructureTitle = ExternalSystemBundle.message("gradle.sync.title.tab"); - ContentImpl projectStructureContent = new ContentImpl(projectStructurePanel, projectStructureTitle, true); ContentManager contentManager = toolWindow.getContentManager(); - contentManager.addContent(projectStructureContent); - - // Task. - String tasksTitle = ExternalSystemBundle.message("gradle.task.title.tab"); + // TODO den implement + String tasksTitle = "tasks"; +// String tasksTitle = ExternalSystemBundle.message("gradle.task.title.tab"); ContentImpl tasksContent = new ContentImpl( new GradleTasksPanel(project), tasksTitle, true); contentManager.addContent(tasksContent); - project.getMessageBus().connect(project).subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() { - @Override - public void rootsChanged(ModuleRootEvent event) { - // The general idea is to change dependencies order at the UI if they are changed at the module settings. - projectStructurePanel.getTreeModel().onModuleRootsChange(); - } - }); - - // Restore previously selected tab. - String toSelect = PropertiesComponent.getInstance(project).getValue(GradleConstants.ACTIVE_TOOL_WINDOW_TAB_KEY, projectStructureTitle); - if (tasksTitle.equals(toSelect)) { - contentManager.setSelectedContent(tasksContent); - } contentManager.addContentManagerListener(new ContentManagerAdapter() { @Override diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleConstants.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleConstants.java index 010eab7af761..41affcfe96d1 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleConstants.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleConstants.java @@ -1,10 +1,7 @@ package org.jetbrains.plugins.gradle.util; import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.ui.ProjectStructureNodeDescriptor; -import com.intellij.openapi.externalSystem.util.ExternalSystemBundle; import org.jetbrains.annotations.NonNls; -import com.intellij.openapi.externalSystem.model.project.id.GradleSyntheticId; import org.jetbrains.annotations.NotNull; /** diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleUtil.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleUtil.java index 9f9133365aea..c6f048df2b31 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleUtil.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleUtil.java @@ -1,29 +1,19 @@ package org.jetbrains.plugins.gradle.util; import com.intellij.ide.actions.OpenProjectFileChooserDescriptor; -import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.components.ServiceManager; -import com.intellij.openapi.externalSystem.model.project.id.GradleSyntheticId; -import com.intellij.openapi.externalSystem.model.project.id.ProjectEntityId; -import com.intellij.openapi.externalSystem.ui.ExternalProjectStructureTreeModel; -import com.intellij.openapi.externalSystem.ui.ProjectStructureNode; -import com.intellij.openapi.externalSystem.ui.ProjectStructureNodeDescriptor; import com.intellij.openapi.fileChooser.FileChooserDescriptor; import com.intellij.openapi.fileChooser.FileTypeDescriptor; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.NotNullLazyValue; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.ui.treeStructure.Tree; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.gradle.service.GradleInstallationManager; import org.jetbrains.plugins.gradle.settings.GradleSettings; import org.jetbrains.plugins.gradle.ui.MatrixControlBuilder; -import javax.swing.*; -import javax.swing.tree.TreePath; -import java.awt.*; import java.io.*; import java.util.Arrays; import java.util.Properties; @@ -156,55 +146,6 @@ public class GradleUtil { return null; } - @NotNull - public static ProjectStructureNodeDescriptor buildDescriptor(@NotNull T id, @NotNull String name) { - return new ProjectStructureNodeDescriptor(id, name, id.getType().getIcon()); - } - - @NotNull - public static ProjectStructureNodeDescriptor buildSyntheticDescriptor(@NotNull String text) { - return buildSyntheticDescriptor(text, null); - } - - public static ProjectStructureNodeDescriptor buildSyntheticDescriptor(@NotNull String text, @Nullable Icon icon) { - return new ProjectStructureNodeDescriptor(new GradleSyntheticId(text), text, icon); - } - - /** - * Tries to calculate the position to use for showing hint for the given node of the given tree. - * - * @param node target node for which a hint should be shown - * @param tree target tree that contains given node - * @return preferred hint position (in coordinates relative to the given tree) if it's possible to calculate the one; - * null otherwise - */ - @Nullable - public static Point getHintPosition(@NotNull ProjectStructureNode node, @NotNull Tree tree) { - final Rectangle bounds = tree.getPathBounds(new TreePath(node.getPath())); - if (bounds == null) { - return null; - } - final Icon icon = ((ProjectStructureNode)node).getDescriptor().getIcon(); - int xAdjustment = 0; - if (icon != null) { - xAdjustment = icon.getIconWidth(); - } - return new Point(bounds.x + xAdjustment, bounds.y + bounds.height); - } - - /** - * Tries to find the current {@link ExternalProjectStructureTreeModel} instance. - * - * @param context target context (if defined) - * @return current {@link ExternalProjectStructureTreeModel} instance (if any has been found); null otherwise - */ - @Nullable - public static ExternalProjectStructureTreeModel getProjectStructureTreeModel(@Nullable DataContext context) { - // TODO den implement - return null; -// return getToolWindowElement(ExternalProjectStructureTreeModel.class, context, ExternalSystemDataKeys.PROJECT_TREE_MODEL); - } - /** * @return {@link MatrixControlBuilder} with predefined set of columns ('gradle' and 'intellij') */ diff --git a/plugins/gradle/testSources/org/jetbrains/plugins/gradle/util/TestMovedJarsPostProcessor.java b/plugins/gradle/testSources/org/jetbrains/plugins/gradle/util/TestMovedJarsPostProcessor.java deleted file mode 100644 index d35cadeccf2e..000000000000 --- a/plugins/gradle/testSources/org/jetbrains/plugins/gradle/util/TestMovedJarsPostProcessor.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.plugins.gradle.util; - -import com.intellij.openapi.externalSystem.service.project.manage.JarDataService; -import com.intellij.openapi.project.Project; -import org.jetbrains.annotations.NotNull; -import com.intellij.openapi.externalSystem.service.project.change.MovedJarsPostProcessor; - -/** - * @author Denis Zhdanov - * @since 1/18/13 2:11 PM - */ -public class TestMovedJarsPostProcessor extends MovedJarsPostProcessor { - - public TestMovedJarsPostProcessor(@NotNull JarDataService manager) { - super(manager); - } - - @Override - public void doMerge(@NotNull Runnable mergeTask, @NotNull Project project) { - mergeTask.run(); - } -} diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index bdef39604a44..e5a32554f5ab 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -454,6 +454,8 @@ + +