diff --git a/CHANGELOG.md b/CHANGELOG.md index c129a797..0cfca82b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -120,7 +120,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Suggesting installing dotnet `ef command` line tools if not installed (when opening solution that contains EF Core related projects) - Deleting used database -[Unreleased]: https://github.com/seclerp/rider-efcore/compare/v223.0.0...HEAD +[Unreleased]: https://github.com/seclerp/rider-efcore/compare/v223.1.0...HEAD [223.1.0]: https://github.com/seclerp/rider-efcore/compare/v223.0.0...HEAD [223.0.0]: https://github.com/seclerp/rider-efcore/compare/v222.2.0...v223.0.0 [222.2.0]: https://github.com/seclerp/rider-efcore/compare/v222.1.1...v222.2.0 diff --git a/protocol/src/main/kotlin/model/rider/RiderEfCoreModel.kt b/protocol/src/main/kotlin/model/rider/RiderEfCoreModel.kt index 8ba9624b..525b2917 100644 --- a/protocol/src/main/kotlin/model/rider/RiderEfCoreModel.kt +++ b/protocol/src/main/kotlin/model/rider/RiderEfCoreModel.kt @@ -24,7 +24,7 @@ object RiderEfCoreModel : Ext(SolutionModel.Solution) { } private val MigrationsIdentity = structdef { - field("projectName", string) + field("projectId", guid) field("dbContextClassFullName", string) } @@ -59,7 +59,7 @@ object RiderEfCoreModel : Ext(SolutionModel.Solution) { call("hasAvailableMigrations", MigrationsIdentity, bool) call("getAvailableMigrations", MigrationsIdentity, immutableList(MigrationInfo)) - call("getAvailableDbContexts", string, immutableList(DbContextInfo)) + call("getAvailableDbContexts", guid, immutableList(DbContextInfo)) callback("onMissingEfCoreToolsDetected", void, void) } diff --git a/src/dotnet/Rider.Plugins.EfCore/EfCoreSolutionComponent.cs b/src/dotnet/Rider.Plugins.EfCore/EfCoreSolutionComponent.cs index dc6e8de5..24cb2fb5 100644 --- a/src/dotnet/Rider.Plugins.EfCore/EfCoreSolutionComponent.cs +++ b/src/dotnet/Rider.Plugins.EfCore/EfCoreSolutionComponent.cs @@ -1,6 +1,6 @@ +using System; using System.Collections.Generic; using System.Linq; -using JetBrains.Collections.Viewable; using JetBrains.Core; using JetBrains.Lifetimes; using JetBrains.Platform.RdFramework.Impl; @@ -185,10 +185,10 @@ private RdTask HasAvailableMigrations(Lifetime lifetime, MigrationsIdentit { using (ReadLockCookie.Create()) { - var project = _solution.GetProjectByName(identity.ProjectName); + var project = _solution.GetProjectByGuid(identity.ProjectId); if (project is null) { - return RdTask.Faulted(new ProjectNotFoundException(identity.ProjectName)); + return RdTask.Faulted(new ProjectNotFoundException(identity.ProjectId)); } var hasMigrations = _migrationsProvider.HasMigrations(project, identity.DbContextClassFullName); @@ -201,11 +201,11 @@ private RdTask> GetAvailableMigrations(Lifetime lifetime, Mi { using (ReadLockCookie.Create()) { - var project = _solution.GetProjectByName(identity.ProjectName); + var project = _solution.GetProjectByGuid(identity.ProjectId); if (project is null) { - return RdTask>.Faulted(new ProjectNotFoundException(identity.ProjectName)); + return RdTask>.Faulted(new ProjectNotFoundException(identity.ProjectId)); } var foundDbContexts = _migrationsProvider.GetMigrations(project, identity.DbContextClassFullName).ToList(); @@ -214,15 +214,15 @@ private RdTask> GetAvailableMigrations(Lifetime lifetime, Mi } } - private RdTask> GetAvailableDbContexts(Lifetime lifetime, string projectName) + private RdTask> GetAvailableDbContexts(Lifetime lifetime, Guid projectId) { using (ReadLockCookie.Create()) { - var project = _solution.GetProjectByName(projectName); + var project = _solution.GetProjectByGuid(projectId); if (project is null) { - return RdTask>.Faulted(new ProjectNotFoundException(projectName)); + return RdTask>.Faulted(new ProjectNotFoundException(projectId)); } var foundDbContexts = _dbContextProvider.GetDbContexts(project).ToList(); diff --git a/src/dotnet/Rider.Plugins.EfCore/Exceptions/ProjectNotFoundException.cs b/src/dotnet/Rider.Plugins.EfCore/Exceptions/ProjectNotFoundException.cs index 6b9e180a..a9f232d2 100644 --- a/src/dotnet/Rider.Plugins.EfCore/Exceptions/ProjectNotFoundException.cs +++ b/src/dotnet/Rider.Plugins.EfCore/Exceptions/ProjectNotFoundException.cs @@ -4,7 +4,7 @@ namespace Rider.Plugins.EfCore.Exceptions { public class ProjectNotFoundException : Exception { - public ProjectNotFoundException(string projectName) : base($"Project with name {projectName} not found") + public ProjectNotFoundException(Guid projectId) : base($"Project with ID {projectId} not found") { } } diff --git a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/database/drop/DropDatabaseAction.kt b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/database/drop/DropDatabaseAction.kt index 0d87ba47..6c8f7f1f 100644 --- a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/database/drop/DropDatabaseAction.kt +++ b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/database/drop/DropDatabaseAction.kt @@ -4,12 +4,13 @@ import com.intellij.openapi.project.Project import me.seclerp.rider.plugins.efcore.cli.api.models.DotnetEfVersion import me.seclerp.rider.plugins.efcore.features.shared.BaseCommandAction import me.seclerp.rider.plugins.efcore.rd.RiderEfCoreModel +import java.util.UUID class DropDatabaseAction : BaseCommandAction("Database has been deleted") { override fun createDialog( intellijProject: Project, toolsVersion: DotnetEfVersion, model: RiderEfCoreModel, - currentDotnetProjectName: String? - ) = DropDatabaseDialogWrapper(toolsVersion, intellijProject, currentDotnetProjectName) + currentDotnetProjectId: UUID? + ) = DropDatabaseDialogWrapper(toolsVersion, intellijProject, currentDotnetProjectId) } \ No newline at end of file diff --git a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/database/drop/DropDatabaseDialogWrapper.kt b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/database/drop/DropDatabaseDialogWrapper.kt index 6b8c4691..e19aa765 100644 --- a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/database/drop/DropDatabaseDialogWrapper.kt +++ b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/database/drop/DropDatabaseDialogWrapper.kt @@ -8,17 +8,18 @@ import me.seclerp.rider.plugins.efcore.cli.api.DatabaseCommandFactory import me.seclerp.rider.plugins.efcore.cli.api.models.DotnetEfVersion import me.seclerp.rider.plugins.efcore.features.shared.dialog.CommonDialogWrapper import me.seclerp.rider.plugins.efcore.features.shared.dialog.CommonDataContext +import java.util.* class DropDatabaseDialogWrapper( toolsVersion: DotnetEfVersion, intellijProject: Project, - selectedProjectName: String?, + selectedProjectId: UUID?, ) : CommonDialogWrapper( CommonDataContext(intellijProject, false), toolsVersion, "Drop Database", intellijProject, - selectedProjectName, + selectedProjectId, false ) { private val databaseCommandFactory = intellijProject.service() diff --git a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/database/update/UpdateDatabaseAction.kt b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/database/update/UpdateDatabaseAction.kt index 64246eb3..4fb60faf 100644 --- a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/database/update/UpdateDatabaseAction.kt +++ b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/database/update/UpdateDatabaseAction.kt @@ -4,12 +4,13 @@ import com.intellij.openapi.project.Project import me.seclerp.rider.plugins.efcore.cli.api.models.DotnetEfVersion import me.seclerp.rider.plugins.efcore.features.shared.BaseCommandAction import me.seclerp.rider.plugins.efcore.rd.RiderEfCoreModel +import java.util.* class UpdateDatabaseAction : BaseCommandAction("Database has been updated") { override fun createDialog( intellijProject: Project, toolsVersion: DotnetEfVersion, model: RiderEfCoreModel, - currentDotnetProjectName: String? - ) = UpdateDatabaseDialogWrapper(toolsVersion, intellijProject, currentDotnetProjectName) + currentDotnetProjectId: UUID? + ) = UpdateDatabaseDialogWrapper(toolsVersion, intellijProject, currentDotnetProjectId) } \ No newline at end of file diff --git a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/database/update/UpdateDatabaseDialogWrapper.kt b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/database/update/UpdateDatabaseDialogWrapper.kt index 27eb3c70..f684ed5b 100644 --- a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/database/update/UpdateDatabaseDialogWrapper.kt +++ b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/database/update/UpdateDatabaseDialogWrapper.kt @@ -15,17 +15,18 @@ import me.seclerp.rider.plugins.efcore.cli.api.DatabaseCommandFactory import me.seclerp.rider.plugins.efcore.cli.api.models.DotnetEfVersion import me.seclerp.rider.plugins.efcore.features.shared.dialog.CommonDialogWrapper import me.seclerp.rider.plugins.efcore.ui.* +import java.util.* class UpdateDatabaseDialogWrapper( toolsVersion: DotnetEfVersion, intellijProject: Project, - selectedProjectName: String? + selectedProjectId: UUID? ) : CommonDialogWrapper( UpdateDatabaseDataContext(intellijProject), toolsVersion, "Update Database", intellijProject, - selectedProjectName, + selectedProjectId, true ) { diff --git a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/dbcontext/scaffold/ScaffoldDbContextAction.kt b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/dbcontext/scaffold/ScaffoldDbContextAction.kt index dac0985b..140ab7c8 100644 --- a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/dbcontext/scaffold/ScaffoldDbContextAction.kt +++ b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/dbcontext/scaffold/ScaffoldDbContextAction.kt @@ -4,12 +4,13 @@ import com.intellij.openapi.project.Project import me.seclerp.rider.plugins.efcore.cli.api.models.DotnetEfVersion import me.seclerp.rider.plugins.efcore.features.shared.BaseCommandAction import me.seclerp.rider.plugins.efcore.rd.RiderEfCoreModel +import java.util.* class ScaffoldDbContextAction : BaseCommandAction("DbContext has been scaffolded") { override fun createDialog( intellijProject: Project, toolsVersion: DotnetEfVersion, model: RiderEfCoreModel, - currentDotnetProjectName: String? - ) = ScaffoldDbContextDialogWrapper(toolsVersion, intellijProject, currentDotnetProjectName) + currentDotnetProjectId: UUID? + ) = ScaffoldDbContextDialogWrapper(toolsVersion, intellijProject, currentDotnetProjectId) } \ No newline at end of file diff --git a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/dbcontext/scaffold/ScaffoldDbContextDialogWrapper.kt b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/dbcontext/scaffold/ScaffoldDbContextDialogWrapper.kt index 6fcf0aa9..3dffdbf0 100644 --- a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/dbcontext/scaffold/ScaffoldDbContextDialogWrapper.kt +++ b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/dbcontext/scaffold/ScaffoldDbContextDialogWrapper.kt @@ -26,19 +26,20 @@ import me.seclerp.observables.ui.dsl.bindSelected import me.seclerp.observables.ui.dsl.bindText import me.seclerp.rider.plugins.efcore.ui.textFieldForRelativeFolder import java.io.File +import java.util.* import javax.swing.JComponent @Suppress("UnstableApiUsage") class ScaffoldDbContextDialogWrapper( toolsVersion: DotnetEfVersion, intellijProject: Project, - selectedProjectName: String?, + selectedProjectId: UUID?, ) : CommonDialogWrapper( ScaffoldDbContextDataContext(intellijProject), toolsVersion, "Scaffold DbContext", intellijProject, - selectedProjectName, + selectedProjectId, requireMigrationsInProject = false ) { val dbContextCommandFactory = intellijProject.service() diff --git a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/migrations/add/AddMigrationAction.kt b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/migrations/add/AddMigrationAction.kt index 7f5fcf84..d9bef539 100644 --- a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/migrations/add/AddMigrationAction.kt +++ b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/migrations/add/AddMigrationAction.kt @@ -4,12 +4,13 @@ import com.intellij.openapi.project.Project import me.seclerp.rider.plugins.efcore.cli.api.models.DotnetEfVersion import me.seclerp.rider.plugins.efcore.features.shared.BaseCommandAction import me.seclerp.rider.plugins.efcore.rd.RiderEfCoreModel +import java.util.* class AddMigrationAction : BaseCommandAction("New migration has been created") { override fun createDialog( intellijProject: Project, toolsVersion: DotnetEfVersion, model: RiderEfCoreModel, - currentDotnetProjectName: String? - ) = AddMigrationDialogWrapper(toolsVersion, intellijProject, currentDotnetProjectName) + currentDotnetProjectId: UUID? + ) = AddMigrationDialogWrapper(toolsVersion, intellijProject, currentDotnetProjectId) } \ No newline at end of file diff --git a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/migrations/add/AddMigrationDialogWrapper.kt b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/migrations/add/AddMigrationDialogWrapper.kt index d83dec30..17b17157 100644 --- a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/migrations/add/AddMigrationDialogWrapper.kt +++ b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/migrations/add/AddMigrationDialogWrapper.kt @@ -16,17 +16,18 @@ import me.seclerp.observables.ui.dsl.bindText import me.seclerp.rider.plugins.efcore.ui.AnyInputDocumentListener import me.seclerp.rider.plugins.efcore.ui.textFieldForRelativeFolder import java.io.File +import java.util.UUID class AddMigrationDialogWrapper( toolsVersion: DotnetEfVersion, intellijProject: Project, - selectedProjectName: String?, + selectedProjectId: UUID?, ) : CommonDialogWrapper( AddMigrationDataContext(intellijProject), toolsVersion, "Add Migration", intellijProject, - selectedProjectName + selectedProjectId ) { val migrationsCommandFactory = intellijProject.service() diff --git a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/migrations/remove/RemoveLastMigrationAction.kt b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/migrations/remove/RemoveLastMigrationAction.kt index 3b1900cf..19b4886f 100644 --- a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/migrations/remove/RemoveLastMigrationAction.kt +++ b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/migrations/remove/RemoveLastMigrationAction.kt @@ -4,12 +4,13 @@ import com.intellij.openapi.project.Project import me.seclerp.rider.plugins.efcore.cli.api.models.DotnetEfVersion import me.seclerp.rider.plugins.efcore.features.shared.BaseCommandAction import me.seclerp.rider.plugins.efcore.rd.RiderEfCoreModel +import java.util.* class RemoveLastMigrationAction : BaseCommandAction("Last migration has been removed") { override fun createDialog( intellijProject: Project, toolsVersion: DotnetEfVersion, model: RiderEfCoreModel, - currentDotnetProjectName: String? - ) = RemoveLastMigrationDialogWrapper(toolsVersion, intellijProject, currentDotnetProjectName) + currentDotnetProjectId: UUID? + ) = RemoveLastMigrationDialogWrapper(toolsVersion, intellijProject, currentDotnetProjectId) } \ No newline at end of file diff --git a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/migrations/remove/RemoveLastMigrationDialogWrapper.kt b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/migrations/remove/RemoveLastMigrationDialogWrapper.kt index 7f496676..96fae38f 100644 --- a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/migrations/remove/RemoveLastMigrationDialogWrapper.kt +++ b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/migrations/remove/RemoveLastMigrationDialogWrapper.kt @@ -7,17 +7,18 @@ import me.seclerp.rider.plugins.efcore.cli.api.MigrationsCommandFactory import me.seclerp.rider.plugins.efcore.cli.api.models.DotnetEfVersion import me.seclerp.rider.plugins.efcore.cli.execution.CliCommandResult import me.seclerp.rider.plugins.efcore.features.shared.dialog.CommonDialogWrapper +import java.util.* class RemoveLastMigrationDialogWrapper( toolsVersion: DotnetEfVersion, intellijProject: Project, - selectedProjectName: String?, + selectedProjectId: UUID?, ) : CommonDialogWrapper( RemoveLastMigrationDataContext(intellijProject), toolsVersion, "Remove Last Migration", intellijProject, - selectedProjectName, + selectedProjectId, true ) { val migrationsCommandFactory = intellijProject.service() diff --git a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/migrations/script/GenerateScriptAction.kt b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/migrations/script/GenerateScriptAction.kt index 1dc30d95..487470a2 100644 --- a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/migrations/script/GenerateScriptAction.kt +++ b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/migrations/script/GenerateScriptAction.kt @@ -3,14 +3,14 @@ package me.seclerp.rider.plugins.efcore.features.migrations.script import com.intellij.openapi.project.Project import me.seclerp.rider.plugins.efcore.cli.api.models.DotnetEfVersion import me.seclerp.rider.plugins.efcore.features.shared.BaseCommandAction -import me.seclerp.rider.plugins.efcore.features.shared.dialog.CommonDialogWrapper import me.seclerp.rider.plugins.efcore.rd.RiderEfCoreModel +import java.util.* class GenerateScriptAction : BaseCommandAction("Script has been generated") { override fun createDialog( intellijProject: Project, toolsVersion: DotnetEfVersion, model: RiderEfCoreModel, - currentDotnetProjectName: String? - ) = GenerateScriptDialogWrapper(toolsVersion, intellijProject, currentDotnetProjectName) + currentDotnetProjectId: UUID? + ) = GenerateScriptDialogWrapper(toolsVersion, intellijProject, currentDotnetProjectId) } \ No newline at end of file diff --git a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/migrations/script/GenerateScriptDialogWrapper.kt b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/migrations/script/GenerateScriptDialogWrapper.kt index de30217c..9439ec0b 100644 --- a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/migrations/script/GenerateScriptDialogWrapper.kt +++ b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/migrations/script/GenerateScriptDialogWrapper.kt @@ -15,17 +15,18 @@ import me.seclerp.rider.plugins.efcore.cli.api.MigrationsCommandFactory import me.seclerp.rider.plugins.efcore.cli.api.models.DotnetEfVersion import me.seclerp.rider.plugins.efcore.features.shared.dialog.CommonDialogWrapper import me.seclerp.rider.plugins.efcore.ui.items.MigrationItem +import java.util.* class GenerateScriptDialogWrapper( toolsVersion: DotnetEfVersion, intellijProject: Project, - selectedProjectName: String? + selectedProjectId: UUID? ) : CommonDialogWrapper( GenerateScriptDataContext(intellijProject), toolsVersion, "Generate SQL Script", intellijProject, - selectedProjectName, + selectedProjectId, requireMigrationsInProject = true ) { val migrationsCommandFactory = intellijProject.service() diff --git a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/shared/AnActionEventEx.kt b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/shared/AnActionEventEx.kt index 19a6fca4..bcbfad04 100644 --- a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/shared/AnActionEventEx.kt +++ b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/shared/AnActionEventEx.kt @@ -10,6 +10,7 @@ import com.jetbrains.rider.model.RdProjectDescriptor import com.jetbrains.rider.model.RdUnloadProjectDescriptor import com.jetbrains.rider.projectView.workspace.ProjectModelEntity import com.jetbrains.rider.projectView.workspace.getProjectModelEntities +import java.util.* fun AnActionEvent.isEfCoreActionContext(): Boolean { if (project == null) return false @@ -29,10 +30,12 @@ fun AnActionEvent.isEfCoreActionContext(): Boolean { return true } -fun AnActionEvent.getDotnetProjectName(): String? { - val actionFile = getData(PlatformDataKeys.VIRTUAL_FILE) ?: return "" +fun AnActionEvent.getDotnetProjectId(): UUID? { + val actionFile = getData(PlatformDataKeys.VIRTUAL_FILE) ?: return null - return getFileProject(project!!, actionFile)?.descriptor?.name + return getFileProject(project!!, actionFile)?.descriptor?.let { + (it as RdProjectDescriptor).originalGuid + } } @Suppress("UnstableApiUsage") diff --git a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/shared/BaseCommandAction.kt b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/shared/BaseCommandAction.kt index cffd8f37..d1326952 100644 --- a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/shared/BaseCommandAction.kt +++ b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/shared/BaseCommandAction.kt @@ -21,6 +21,7 @@ import me.seclerp.rider.plugins.efcore.cli.execution.PreferredCommandExecutorPro import me.seclerp.rider.plugins.efcore.features.eftools.InstallDotnetEfAction import me.seclerp.rider.plugins.efcore.features.shared.dialog.BaseDialogWrapper import me.seclerp.rider.plugins.efcore.rd.ToolKind +import java.util.UUID abstract class BaseCommandAction( private val actionPerformedText: String @@ -53,12 +54,12 @@ abstract class BaseCommandAction( intellijProject: Project, toolsVersion: DotnetEfVersion, model: RiderEfCoreModel, - currentDotnetProjectName: String?): BaseDialogWrapper + currentDotnetProjectId: UUID?): BaseDialogWrapper private fun openDialog(actionEvent: AnActionEvent, efCoreVersion: DotnetEfVersion) { val intellijProject = actionEvent.project!! val model = getEfCoreRiderModel(actionEvent) - val currentDotnetProjectName = actionEvent.getDotnetProjectName() + val currentDotnetProjectName = actionEvent.getDotnetProjectId() val dialog = createDialog(intellijProject, efCoreVersion, model, currentDotnetProjectName) if (dialog.showAndGet()) { diff --git a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/shared/ObservableMigrations.kt b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/shared/ObservableMigrations.kt index a6101d86..ae2f489d 100644 --- a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/shared/ObservableMigrations.kt +++ b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/shared/ObservableMigrations.kt @@ -16,10 +16,10 @@ class ObservableMigrations( fun initBinding() { this.bind(dbContext) { if (it != null) { - val migrationsProjectName = migrationsProject.value!!.name + val migrationsProjectId = migrationsProject.value!!.id val dbContextName = it.fullName val migrations = intellijProject.solution.riderEfCoreModel.getAvailableMigrations.runUnderProgress( - MigrationsIdentity(migrationsProjectName, dbContextName), intellijProject, "Loading available migrations...", + MigrationsIdentity(migrationsProjectId, dbContextName), intellijProject, "Loading available migrations...", isCancelable = true, throwFault = true ) diff --git a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/shared/dialog/CommonDataContext.kt b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/shared/dialog/CommonDataContext.kt index dbe95717..fe3979c2 100644 --- a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/shared/dialog/CommonDataContext.kt +++ b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/shared/dialog/CommonDataContext.kt @@ -34,7 +34,7 @@ open class CommonDataContext( if (requireDbContext) { availableDbContexts.bind(migrationsProject) { beModel.getAvailableDbContexts.runUnderProgress( - it!!.name, intellijProject, "Loading DbContext classes...", + it!!.id, intellijProject, "Loading DbContext classes...", isCancelable = true, throwFault = true )?.toMutableList() ?: mutableListOf() diff --git a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/shared/dialog/CommonDialogValidator.kt b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/shared/dialog/CommonDialogValidator.kt index 2188d679..67b0a205 100644 --- a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/shared/dialog/CommonDialogValidator.kt +++ b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/shared/dialog/CommonDialogValidator.kt @@ -23,7 +23,7 @@ class CommonDialogValidator( null else { val migrationsIdentity = MigrationsIdentity( - it.item.displayName, + it.item.data.id, dataCtx.dbContext.value!!.fullName) val hasMigrations = beModel.hasAvailableMigrations.runUnderProgress( diff --git a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/shared/dialog/CommonDialogWrapper.kt b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/shared/dialog/CommonDialogWrapper.kt index dbccfe7c..8d3dc67d 100644 --- a/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/shared/dialog/CommonDialogWrapper.kt +++ b/src/rider/main/kotlin/me/seclerp/rider/plugins/efcore/features/shared/dialog/CommonDialogWrapper.kt @@ -27,6 +27,7 @@ import me.seclerp.observables.ui.dsl.iconComboBox import me.seclerp.rider.plugins.efcore.ui.items.* import me.seclerp.rider.plugins.efcore.ui.simpleExpandableTextField import java.awt.event.ActionEvent +import java.util.* import javax.swing.AbstractAction import javax.swing.Action import javax.swing.JComponent @@ -37,7 +38,7 @@ abstract class CommonDialogWrapper( protected val efCoreVersion: DotnetEfVersion, dialogTitle: String, protected val intellijProject: Project, - private val selectedProjectName: String?, + private val selectedProjectId: UUID?, requireMigrationsInProject: Boolean = false ) : BaseDialogWrapper() { @@ -59,7 +60,7 @@ abstract class CommonDialogWrapper( private val targetFrameworksView = observable(null).withLogger("targetFrameworksView") private val buildConfigurationView = observable(null).withLogger("buildConfigurationView") - private val isSolutionLevelMode = selectedProjectName == null + private val isSolutionLevelMode = selectedProjectId == null // // Validation @@ -180,7 +181,7 @@ abstract class CommonDialogWrapper( val startupProjects = dataCtx.availableStartupProjects val selectedDotnetProject = - migrationsProjects.find { it.name == selectedProjectName } + migrationsProjects.find { it.id == selectedProjectId } val (preferredMigrationsProject, preferredStartupProject) = preferredProjectsManager.getProjectPair(selectedDotnetProject?.id, migrationsProjects, startupProjects)