Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Intellij Community
Commits
de4b5be3
Commit
de4b5be3
authored
7 years ago
by
Alexander Koshevoy
Browse files
Options
Download
Email Patches
Plain Diff
PY-29597 showProcessExecutionErrorDialog() method refactoring
parent
db6d4035
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
python/src/com/jetbrains/python/sdk/add/PyAddSdkDialog.kt
+1
-1
python/src/com/jetbrains/python/sdk/add/PyAddSdkDialog.kt
python/src/com/jetbrains/python/sdk/add/wizardUIUtil.kt
+31
-25
python/src/com/jetbrains/python/sdk/add/wizardUIUtil.kt
with
32 additions
and
26 deletions
+32
-26
python/src/com/jetbrains/python/sdk/add/PyAddSdkDialog.kt
+
1
-
1
View file @
de4b5be3
...
...
@@ -285,7 +285,7 @@ class PyAddSdkDialog private constructor(private val project: Project?,
Messages
.
showErrorDialog
(
e
.
localizedMessage
,
"Error"
)
}
else
{
showExecutionErrorDialog
(
project
,
cause
)
show
Process
ExecutionErrorDialog
(
project
,
cause
)
}
return
}
...
...
This diff is collapsed.
Click to expand it.
python/src/com/jetbrains/python/sdk/add/wizardUIUtil.kt
+
31
-
25
View file @
de4b5be3
...
...
@@ -72,35 +72,28 @@ internal fun show(panel: JPanel, stepContent: Component) {
(
panel
.
layout
as
CardLayout
).
show
(
panel
,
stepContentName
)
}
fun
showExecutionErrorDialog
(
project
:
Project
?,
e
:
PyExecutionException
)
{
val
errorMessage
=
JBLabel
(
"<html>${e.command} could not complete successfully. "
+
"Please see the command's output for information about resolving this problem.</html>"
,
Messages
.
getErrorIcon
(),
SwingConstants
.
LEFT
)
val
formBuilder
=
FormBuilder
().
addComponent
(
errorMessage
)
val
commandOutputTextField
=
JTextPane
().
apply
{
val
stdoutStyle
=
addStyle
(
"stdoutStyle"
,
null
)
StyleConstants
.
setFontFamily
(
stdoutStyle
,
Font
.
MONOSPACED
)
val
stderrStyle
=
addStyle
(
"stderrStyle"
,
stdoutStyle
)
StyleConstants
.
setForeground
(
stderrStyle
,
JBColor
.
RED
)
document
.
apply
{
e
.
stdout
.
let
{
if
(
it
.
isNotEmpty
())
insertString
(
length
,
it
+
"\n"
,
stdoutStyle
)
}
e
.
stderr
.
let
{
if
(
it
.
isNotEmpty
())
insertString
(
length
,
it
+
"\n"
,
stderrStyle
)
}
insertString
(
length
,
"Process finished with exit code ${e.exitCode}"
,
stdoutStyle
)
}
internal
fun
showProcessExecutionErrorDialog
(
project
:
Project
?,
e
:
PyExecutionException
)
{
val
errorMessageText
=
"${e.command} could not complete successfully. "
+
"Please see the command's output for information about resolving this problem."
// HTML format for text in `JBLabel` enables text wrapping
val
errorMessageLabel
=
JBLabel
(
UIUtil
.
toHtml
(
errorMessageText
),
Messages
.
getErrorIcon
(),
SwingConstants
.
LEFT
)
val
commandOutputTextPane
=
JTextPane
().
apply
{
appendProcessOutput
(
e
.
stdout
,
e
.
stderr
,
e
.
exitCode
)
background
=
JBColor
.
WHITE
isEditable
=
false
}
formBuilder
.
addComponentFillVertically
(
BorderLayoutPanel
().
apply
{
val
commandOutputPanel
=
BorderLayoutPanel
().
apply
{
border
=
IdeBorderFactory
.
createTitledBorder
(
"Command output"
,
false
)
addToCenter
(
JBScrollPane
(
commandOutputTextField
,
VERTICAL_SCROLLBAR_AS_NEEDED
,
HORIZONTAL_SCROLLBAR_NEVER
))
},
UIUtil
.
DEFAULT_VGAP
)
addToCenter
(
JBScrollPane
(
commandOutputTextPane
,
VERTICAL_SCROLLBAR_AS_NEEDED
,
HORIZONTAL_SCROLLBAR_NEVER
))
}
val
formBuilder
=
FormBuilder
()
.
addComponent
(
errorMessageLabel
)
.
addComponentFillVertically
(
commandOutputPanel
,
UIUtil
.
DEFAULT_VGAP
)
object
:
DialogWrapper
(
project
)
{
init
{
...
...
@@ -110,8 +103,21 @@ fun showExecutionErrorDialog(project: Project?, e: PyExecutionException) {
override
fun
createActions
():
Array
<
Action
>
=
arrayOf
(
okAction
)
override
fun
createCenterPanel
():
JComponent
{
return
formBuilder
.
panel
.
apply
{
preferredSize
=
Dimension
(
600
,
300
)
}
override
fun
createCenterPanel
():
JComponent
=
formBuilder
.
panel
.
apply
{
preferredSize
=
Dimension
(
600
,
300
)
}
}.
showAndGet
()
}
private
fun
JTextPane
.
appendProcessOutput
(
stdout
:
String
,
stderr
:
String
,
exitCode
:
Int
)
{
val
stdoutStyle
=
addStyle
(
null
,
null
)
StyleConstants
.
setFontFamily
(
stdoutStyle
,
Font
.
MONOSPACED
)
val
stderrStyle
=
addStyle
(
null
,
stdoutStyle
)
StyleConstants
.
setForeground
(
stderrStyle
,
JBColor
.
RED
)
document
.
apply
{
arrayOf
(
stdout
to
stdoutStyle
,
stderr
to
stderrStyle
).
forEach
{
(
std
,
style
)
->
if
(
std
.
isNotEmpty
())
insertString
(
length
,
std
+
"\n"
,
style
)
}
insertString
(
length
,
"Process finished with exit code $exitCode"
,
stdoutStyle
)
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help