mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
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. GitOrigin-RevId: 9c37e2d41b113e42ee4f11efb4097f20cb1faf85
This commit is contained in:
committed by
intellij-monorepo-bot
parent
6b3968283f
commit
f073bcc86d
+1
-1
@@ -18,7 +18,7 @@ object ExternalSystemTrustedProjectDialog {
|
||||
return TrustedProjectsDialog.confirmOpeningOrLinkingUntrustedProject(
|
||||
projectRoot,
|
||||
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"))
|
||||
}
|
||||
|
||||
|
||||
+29
-24
@@ -135,33 +135,38 @@ internal class TrustedProjectStartupDialog(
|
||||
row {
|
||||
text(message)
|
||||
}
|
||||
row {
|
||||
val trimmedFolderName = StringUtil.shortenTextWithEllipsis(projectPath.parent.name, 40, 0, true)
|
||||
checkBox(IdeBundle.message("untrusted.project.warning.trust.location.checkbox", trimmedFolderName))
|
||||
.bindSelected(trustAll)
|
||||
.apply {
|
||||
component.toolTipText = null
|
||||
component.addMouseMotionListener(TooltipMouseAdapter { listOf(getParentFolder().pathString) })
|
||||
}
|
||||
.onChanged {
|
||||
if (it.isSelected) {
|
||||
windowsDefender.set(false)
|
||||
if (getParentFolder() != null) {
|
||||
row {
|
||||
val trimmedFolderName = StringUtil.shortenTextWithEllipsis(getParentFolder()!!.name, 40, 0, true)
|
||||
checkBox(IdeBundle.message("untrusted.project.warning.trust.location.checkbox", trimmedFolderName))
|
||||
.bindSelected(trustAll)
|
||||
.apply {
|
||||
component.toolTipText = null
|
||||
component.addMouseMotionListener(TooltipMouseAdapter { listOf(getParentFolder()!!.pathString) })
|
||||
}
|
||||
.onChanged {
|
||||
if (it.isSelected) {
|
||||
windowsDefender.set(false)
|
||||
}
|
||||
|
||||
if (trustAction != null) {
|
||||
val trustButton = getButton(trustAction!!)
|
||||
val text = if (it.isSelected) {
|
||||
val truncatedParentFolderName = StringUtil.shortenTextWithEllipsis(getTrustFolder(it.isSelected).name, 18, 0, true)
|
||||
IdeBundle.message("untrusted.project.dialog.trust.folder.button", truncatedParentFolderName)
|
||||
} else trustButtonText
|
||||
trustButton?.text = text
|
||||
if (trustAction != null) {
|
||||
val trustButton = getButton(trustAction!!)
|
||||
val text = if (it.isSelected) {
|
||||
val truncatedParentFolderName = StringUtil.shortenTextWithEllipsis(getTrustFolder(it.isSelected).name, 18, 0, true)
|
||||
IdeBundle.message("untrusted.project.dialog.trust.folder.button", truncatedParentFolderName)
|
||||
}
|
||||
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 {
|
||||
val trimmedFolderName = StringUtil.shortenTextWithEllipsis(projectPath.name, 18, 0, true)
|
||||
val trimmedFolderName = StringUtil.shortenTextWithEllipsis(projectPath.name.ifEmpty { projectPath.toString() }
|
||||
|
||||
, 18, 0, true)
|
||||
val idePaths = pathsToExclude.asSequence().filter { it != projectPath }.joinToString(separator = "<br>")
|
||||
windowsDefenderCheckBox = checkBox(IdeBundle.message("untrusted.project.windows.defender.trust.location.checkbox", trimmedFolderName))
|
||||
.bindSelected(windowsDefender)
|
||||
@@ -212,9 +217,9 @@ internal class TrustedProjectStartupDialog(
|
||||
}
|
||||
}
|
||||
|
||||
private fun getTrustFolder(isTrustAll: Boolean): Path = if (isTrustAll) getParentFolder() else projectPath
|
||||
private fun getTrustFolder(isTrustAll: Boolean): Path = if (isTrustAll) getParentFolder() ?: projectPath else projectPath
|
||||
|
||||
private fun getParentFolder(): Path = projectPath.parent
|
||||
private fun getParentFolder(): Path? = projectPath.parent
|
||||
|
||||
override fun createActions(): Array<out Action?> {
|
||||
val actions: MutableList<Action> = mutableListOf()
|
||||
|
||||
@@ -1487,7 +1487,7 @@ private suspend fun checkTrustedState(projectStoreBaseDir: Path): Boolean {
|
||||
return confirmOpeningOrLinkingUntrustedProject(
|
||||
projectRoot = projectStoreBaseDir,
|
||||
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