mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 11:53:49 +07:00
IJ-CR-149796 IJPL-171716 Improve project path handling in untrusted project dialogs
Enhance null safety for project path names in dialog titles and UI elements. Adjust logic to handle cases where parent folders or file names are missing, ensuring better user experience and preventing potential null pointer exceptions. (cherry picked from commit 9c37e2d41b113e42ee4f11efb4097f20cb1faf85) # Conflicts: # community/platform/platform-impl/src/com/intellij/ide/trustedProjects/TrustedProjectStartupDialog.kt GitOrigin-RevId: 6ab20958aecbf89f6351ec9ad0b3022067146220
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c388c9cc0e
commit
5686a77d89
@@ -18,7 +18,7 @@ object ExternalSystemTrustedProjectDialog {
|
|||||||
return TrustedProjectsDialog.confirmOpeningOrLinkingUntrustedProject(
|
return TrustedProjectsDialog.confirmOpeningOrLinkingUntrustedProject(
|
||||||
projectRoot,
|
projectRoot,
|
||||||
project,
|
project,
|
||||||
title = IdeBundle.message("untrusted.project.link.dialog.title", systemId.readableName, projectRoot.fileName),
|
title = IdeBundle.message("untrusted.project.link.dialog.title", systemId.readableName, projectRoot.fileName ?: projectRoot.toString()),
|
||||||
cancelButtonText = IdeBundle.message("untrusted.project.link.dialog.cancel.button"))
|
cancelButtonText = IdeBundle.message("untrusted.project.link.dialog.cancel.button"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -132,33 +132,38 @@ internal class TrustedProjectStartupDialog(
|
|||||||
row {
|
row {
|
||||||
text(message)
|
text(message)
|
||||||
}
|
}
|
||||||
row {
|
if (getParentFolder() != null) {
|
||||||
val trimmedFolderName = StringUtil.shortenTextWithEllipsis(projectPath.parent.name, 40, 0, true)
|
row {
|
||||||
checkBox(IdeBundle.message("untrusted.project.warning.trust.location.checkbox", trimmedFolderName))
|
val trimmedFolderName = StringUtil.shortenTextWithEllipsis(getParentFolder()!!.name, 40, 0, true)
|
||||||
.bindSelected(trustAll)
|
checkBox(IdeBundle.message("untrusted.project.warning.trust.location.checkbox", trimmedFolderName))
|
||||||
.apply {
|
.bindSelected(trustAll)
|
||||||
component.toolTipText = null
|
.apply {
|
||||||
component.addMouseMotionListener(TooltipMouseAdapter { listOf(getParentFolder().pathString) })
|
component.toolTipText = null
|
||||||
}
|
component.addMouseMotionListener(TooltipMouseAdapter { listOf(getParentFolder()!!.pathString) })
|
||||||
.onChanged {
|
|
||||||
if (it.isSelected) {
|
|
||||||
windowsDefender.set(false)
|
|
||||||
}
|
}
|
||||||
|
.onChanged {
|
||||||
|
if (it.isSelected) {
|
||||||
|
windowsDefender.set(false)
|
||||||
|
}
|
||||||
|
|
||||||
if (trustAction != null) {
|
if (trustAction != null) {
|
||||||
val trustButton = getButton(trustAction!!)
|
val trustButton = getButton(trustAction!!)
|
||||||
val text = if (it.isSelected) {
|
val text = if (it.isSelected) {
|
||||||
val truncatedParentFolderName = StringUtil.shortenTextWithEllipsis(getTrustFolder(it.isSelected).name, 18, 0, true)
|
val truncatedParentFolderName = StringUtil.shortenTextWithEllipsis(getTrustFolder(it.isSelected).name, 18, 0, true)
|
||||||
IdeBundle.message("untrusted.project.dialog.trust.folder.button", truncatedParentFolderName)
|
IdeBundle.message("untrusted.project.dialog.trust.folder.button", truncatedParentFolderName)
|
||||||
} else trustButtonText
|
}
|
||||||
trustButton?.text = text
|
else trustButtonText
|
||||||
|
trustButton?.text = text
|
||||||
|
}
|
||||||
|
val trimmedFolderName = StringUtil.shortenTextWithEllipsis(getTrustFolder(it.isSelected).name, 18, 0, true)
|
||||||
|
windowsDefenderCheckBox?.component?.text = IdeBundle.message("untrusted.project.windows.defender.trust.location.checkbox", trimmedFolderName)
|
||||||
}
|
}
|
||||||
val trimmedFolderName = StringUtil.shortenTextWithEllipsis(getTrustFolder(it.isSelected).name, 18, 0, true)
|
}
|
||||||
windowsDefenderCheckBox?.component?.text = IdeBundle.message("untrusted.project.windows.defender.trust.location.checkbox", trimmedFolderName)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
row {
|
row {
|
||||||
val trimmedFolderName = StringUtil.shortenTextWithEllipsis(projectPath.name, 18, 0, true)
|
val trimmedFolderName = StringUtil.shortenTextWithEllipsis(projectPath.name.ifEmpty { projectPath.toString() }
|
||||||
|
|
||||||
|
, 18, 0, true)
|
||||||
windowsDefenderCheckBox = checkBox(IdeBundle.message("untrusted.project.windows.defender.trust.location.checkbox", trimmedFolderName))
|
windowsDefenderCheckBox = checkBox(IdeBundle.message("untrusted.project.windows.defender.trust.location.checkbox", trimmedFolderName))
|
||||||
.bindSelected(windowsDefender)
|
.bindSelected(windowsDefender)
|
||||||
.apply {
|
.apply {
|
||||||
@@ -208,10 +213,9 @@ internal class TrustedProjectStartupDialog(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@NlsSafe
|
private fun getTrustFolder(isTrustAll: Boolean): Path = if (isTrustAll) getParentFolder() ?: projectPath else projectPath
|
||||||
private fun getTrustFolder(isTrustAll: Boolean): Path = if (isTrustAll) getParentFolder() else projectPath
|
|
||||||
|
|
||||||
private fun getParentFolder(): Path = projectPath.parent
|
private fun getParentFolder(): Path? = projectPath.parent
|
||||||
|
|
||||||
override fun createActions(): Array<out Action?> {
|
override fun createActions(): Array<out Action?> {
|
||||||
val actions: MutableList<Action> = mutableListOf()
|
val actions: MutableList<Action> = mutableListOf()
|
||||||
|
|||||||
@@ -1479,7 +1479,7 @@ private suspend fun checkTrustedState(projectStoreBaseDir: Path): Boolean {
|
|||||||
return confirmOpeningOrLinkingUntrustedProject(
|
return confirmOpeningOrLinkingUntrustedProject(
|
||||||
projectRoot = projectStoreBaseDir,
|
projectRoot = projectStoreBaseDir,
|
||||||
project = null,
|
project = null,
|
||||||
title = IdeBundle.message("untrusted.project.open.dialog.title", projectStoreBaseDir.fileName)
|
title = IdeBundle.message("untrusted.project.open.dialog.title", projectStoreBaseDir.fileName ?: projectStoreBaseDir.toString())
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user