Skip to content

Commit 9fc74cf

Browse files
committed
added exception dialog
1 parent 900def2 commit 9fc74cf

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

src/main/kotlin/org/tabooproject/development/ProjectBuilder.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class ProjectBuilder : AbstractNewProjectWizardBuilder() {
4747
val directory = project.basePath!!
4848
Template.downloadAndUnzipFile(directory)
4949
},
50-
"Downloading template files", true, project
50+
"Downloading template files", false, project
5151
)
5252
}
5353
}
@@ -59,6 +59,7 @@ class ProjectBuilder : AbstractNewProjectWizardBuilder() {
5959
}
6060

6161
override fun cleanup() {
62+
super.cleanup()
6263
ConfigurationPropertiesStep.refreshTemporaryData()
6364
OptionalPropertiesStep.refreshTemporaryData()
6465
}

src/main/kotlin/org/tabooproject/development/step/ConfigurationPropertiesStep.kt

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,23 @@ package org.tabooproject.development.step
33
import ai.grazie.utils.capitalize
44
import com.intellij.ide.util.projectWizard.ModuleWizardStep
55
import com.intellij.ide.util.projectWizard.WizardContext
6+
import com.intellij.ide.wizard.AbstractWizard
7+
import com.intellij.openapi.application.ApplicationManager
68
import com.intellij.openapi.progress.ProgressManager
9+
import com.intellij.openapi.ui.DialogBuilder
10+
import com.intellij.openapi.ui.ex.MultiLineLabel
711
import com.intellij.openapi.util.ThrowableComputable
812
import com.intellij.ui.dsl.builder.columns
913
import com.intellij.ui.dsl.builder.panel
14+
import com.intellij.util.xml.ui.MultiLineTextPanel
1015
import kotlinx.coroutines.DelicateCoroutinesApi
1116
import kotlinx.coroutines.GlobalScope
1217
import kotlinx.coroutines.coroutineScope
1318
import kotlinx.coroutines.launch
1419
import org.tabooproject.development.component.CheckModulePanel
1520
import org.tabooproject.development.util.ResourceLoader
1621
import org.tabooproject.development.util.ResourceLoader.loadModules
22+
import java.lang.reflect.Method
1723
import javax.swing.JComponent
1824
import javax.swing.JTextField
1925

@@ -132,13 +138,35 @@ class ConfigurationPropertiesStep(val context: WizardContext) : ModuleWizardStep
132138
}
133139
}
134140

141+
private val doPreviousActionMethod: Method by lazy {
142+
AbstractWizard::class.java.getDeclaredMethod("doPreviousAction").apply {
143+
isAccessible = true
144+
}
145+
}
146+
135147
@OptIn(DelicateCoroutinesApi::class)
136148
override fun _init() {
137149
if (inited) return
138150

139151
ProgressManager.getInstance().runProcessWithProgressSynchronously(
140152
ThrowableComputable {
141-
loadModules()
153+
try {
154+
loadModules()
155+
} catch (e: Exception) {
156+
val wizard = context.getUserData(AbstractWizard.KEY)
157+
doPreviousActionMethod.invoke(wizard)
158+
159+
ApplicationManager.getApplication().invokeLater {
160+
DialogBuilder().apply {
161+
setTitle("Download module list failed")
162+
setCenterPanel(MultiLineLabel(e.message).apply {
163+
164+
})
165+
addCancelAction().setText("Cancel")
166+
}.show()
167+
}
168+
throw e
169+
}
142170
},
143171
"Downloading modules list", false, context.project
144172
)

0 commit comments

Comments
 (0)