@@ -3,13 +3,13 @@ package com.github.cnrture.quickprojectwizard.common
33import com.github.cnrture.quickprojectwizard.common.file.FileWriter
44import com.github.cnrture.quickprojectwizard.common.file.ImportAnalyzer
55import com.github.cnrture.quickprojectwizard.common.file.LibraryDependencyFinder
6- import com.github.cnrture.quickprojectwizard.components.QPWMessageDialog
76import com.github.cnrture.quickprojectwizard.data.FeatureTemplate
87import com.github.cnrture.quickprojectwizard.data.ModuleTemplate
98import com.github.cnrture.quickprojectwizard.data.PluginListItem
109import com.github.cnrture.quickprojectwizard.service.AnalyticsService
1110import com.intellij.ide.BrowserUtil
1211import com.intellij.ide.starters.local.GeneratorTemplateFile
12+ import com.intellij.notification.NotificationDisplayType
1313import com.intellij.notification.NotificationGroupManager
1414import com.intellij.notification.NotificationType
1515import com.intellij.openapi.actionSystem.AnAction
@@ -67,17 +67,28 @@ object Utils {
6767 file = File (projectRoot, cleanSelectedPath),
6868 featureName = featureName,
6969 packageName = packagePath.plus(" .${featureName.lowercase()} " ),
70- showErrorDialog = { QPWMessageDialog (" Error: $it " ).show() },
70+ showErrorDialog = {
71+ showInfo(
72+ message = " Error creating feature: $it " ,
73+ type = NotificationType .ERROR
74+ )
75+ },
7176 showSuccessDialog = {
7277 analyticsService.track(" ${from} _feature_created" )
73- QPWMessageDialog (" Success" ).show()
78+ showInfo(
79+ message = " Feature '$featureName ' created successfully" ,
80+ type = NotificationType .INFORMATION
81+ )
7482 val currentlySelectedFile = project.getCurrentlySelectedFile(selectedSrc)
7583 listOf (currentlySelectedFile).refreshFileSystem()
7684 },
7785 selectedTemplate = selectedTemplate
7886 )
7987 } catch (e: Exception ) {
80- QPWMessageDialog (" Error: ${e.message} " ).show()
88+ showInfo(
89+ message = " Error creating feature: ${e.message} " ,
90+ type = NotificationType .ERROR
91+ )
8192 }
8293 }
8394
@@ -108,7 +119,10 @@ object Utils {
108119 if (settingsGradleFile != null ) {
109120 val moduleName = moduleName.trim()
110121 if (! moduleName.startsWith(" :" )) {
111- QPWMessageDialog (" Module name must start with ':' (e.g. ':home' or ':feature:home')" ).show()
122+ showInfo(
123+ message = " Module name must start with ':' (e.g. ':home' or ':feature:home')" ,
124+ type = NotificationType .ERROR
125+ )
112126 return emptyList()
113127 }
114128
@@ -131,10 +145,18 @@ object Utils {
131145 modulePathAsString = moduleName,
132146 name = name,
133147 moduleType = moduleType,
134- showErrorDialog = { QPWMessageDialog (it).show() },
148+ showErrorDialog = {
149+ showInfo(
150+ message = " Error creating module: $it " ,
151+ type = NotificationType .ERROR
152+ )
153+ },
135154 showSuccessDialog = {
136155 analyticsService.track(" ${from} _module_created" )
137- QPWMessageDialog (" Module '$moduleName ' created successfully" ).show()
156+ showInfo(
157+ message = " Module '$moduleName ' created successfully" ,
158+ type = NotificationType .INFORMATION
159+ )
138160
139161 val projectDir = File (project.basePath.orEmpty())
140162 VfsUtil .markDirtyAndRefresh(false , true , true , VfsUtil .findFileByIoFile(projectDir, true ))
@@ -169,11 +191,17 @@ object Utils {
169191 )
170192 return filesCreated
171193 } else {
172- QPWMessageDialog (" Couldn't find settings.gradle(.kts) file" ).show()
194+ showInfo(
195+ message = " Couldn't find settings.gradle(.kts) file" ,
196+ type = NotificationType .ERROR
197+ )
173198 return emptyList()
174199 }
175200 } catch (e: Exception ) {
176- QPWMessageDialog (" Error: ${e.message} " ).show()
201+ showInfo(
202+ message = " Error creating module: ${e.message} " ,
203+ type = NotificationType .ERROR
204+ )
177205 return emptyList()
178206 }
179207 }
@@ -189,7 +217,10 @@ object Utils {
189217
190218 try {
191219 if (! sourceDir.exists() || ! sourceDir.isDirectory) {
192- QPWMessageDialog (" Source directory does not exist or is not a directory" ).show()
220+ showInfo(
221+ message = " Source directory does not exist or is not a directory" ,
222+ type = NotificationType .ERROR
223+ )
193224 return
194225 }
195226
@@ -206,7 +237,10 @@ object Utils {
206237 }.toList()
207238
208239 if (sourceFiles.isEmpty()) {
209- QPWMessageDialog (" No source files found to move in ${sourceDir.absolutePath} " ).show()
240+ showInfo(
241+ message = " No source files found to move in ${sourceDir.absolutePath} " ,
242+ type = NotificationType .WARNING
243+ )
210244 return
211245 }
212246
@@ -276,10 +310,15 @@ object Utils {
276310 ApplicationManager .getApplication().invokeLater {
277311 openNewModule(project, modulePath, movedFiles)
278312 }
279-
280- QPWMessageDialog (" Moved ${movedFiles.size} files to new module" ).show()
313+ showInfo(
314+ message = " Files moved to new module: ${targetModulePath.replace(" :" , " /" )} " ,
315+ type = NotificationType .INFORMATION
316+ )
281317 } catch (e: Exception ) {
282- QPWMessageDialog (" Error moving files: ${e.message} " ).show()
318+ showInfo(
319+ message = " Error moving files: ${e.message} " ,
320+ type = NotificationType .ERROR
321+ )
283322 e.printStackTrace()
284323 }
285324 }
@@ -311,7 +350,10 @@ object Utils {
311350 val settingsFile = listOf (settingsGradleKtsPath, settingsGradlePath).firstOrNull {
312351 it.exists()
313352 } ? : run {
314- QPWMessageDialog (" Can't find settings.gradle(.kts) file" )
353+ showInfo(
354+ message = " Can't find settings.gradle(.kts) file in project: ${project.name} " ,
355+ type = NotificationType .ERROR
356+ )
315357 return null
316358 }
317359
@@ -626,13 +668,13 @@ object Utils {
626668 }
627669 }
628670
629- fun showInfo (title : String , message : String ) {
671+ fun showInfo (title : String? = null , message : String , type : NotificationType = NotificationType . INFORMATION ) {
630672 val notification = NotificationGroupManager .getInstance()
631673 .getNotificationGroup(" QPW Notification Group" )
632674 .createNotification(
633- title = title,
675+ title = title ? : " Quick Project Wizard " ,
634676 content = message,
635- type = NotificationType . INFORMATION ,
677+ type = type ,
636678 )
637679 notification.addAction(
638680 object : AnAction (" Contact Developer" ) {
0 commit comments