11package org .yanhuang .plugins .intellij .exportjar .ui ;
22
3+ import com .intellij .openapi .application .Application ;
4+ import com .intellij .openapi .application .ApplicationManager ;
35import com .intellij .openapi .compiler .CompileStatusNotification ;
46import com .intellij .openapi .compiler .CompilerManager ;
57import com .intellij .openapi .fileChooser .FileChooser ;
1416import com .intellij .ui .TitledSeparator ;
1517import com .intellij .ui .content .MessageView ;
1618import com .intellij .util .Consumer ;
17- import com .intellij .util .WaitForProgressToShow ;
1819import com .intellij .util .ui .UIUtil ;
1920import com .intellij .util .ui .components .BorderLayoutPanel ;
2021import org .jetbrains .annotations .NotNull ;
@@ -226,10 +227,11 @@ public void doExport(VirtualFile[] exportFiles) {
226227 if (isEmpty (exportFiles )) {
227228 return ;
228229 }
230+ final Application app = ApplicationManager .getApplication ();
229231 final Module [] modules = CommonUtils .findModule (project , exportFiles );
230232 String selectedOutputJarFullPath = (String ) this .outPutJarFileComboBox .getModel ().getSelectedItem ();
231233 if (selectedOutputJarFullPath == null || selectedOutputJarFullPath .trim ().length () == 0 ) {
232- WaitForProgressToShow . runOrInvokeAndWaitAboveProgress (() -> showErrorDialog (project , "The selected output path should not empty" , Constants .actionName ));
234+ app . invokeAndWait (() -> showErrorDialog (project , "The selected output path should not empty" , Constants .actionName ));
233235 return ;
234236 }
235237 Path exportJarFullPath = Paths .get (selectedOutputJarFullPath .trim ());
@@ -241,7 +243,7 @@ public void doExport(VirtualFile[] exportFiles) {
241243 exportJarFullPath = exportJarParentPath .resolve (exportJarFullPath );
242244 }
243245 if (!Files .exists (exportJarParentPath )) {
244- WaitForProgressToShow . runOrInvokeAndWaitAboveProgress (() -> showErrorDialog (project , "The selected output path is not exists" , Constants .actionName ));
246+ app . invokeAndWait (() -> showErrorDialog (project , "The selected output path is not exists" , Constants .actionName ));
245247 } else {
246248 String exportJarName = exportJarFullPath .getFileName ().toString ();
247249 if (!exportJarName .endsWith (".jar" )) {
@@ -250,9 +252,8 @@ public void doExport(VirtualFile[] exportFiles) {
250252 if (Files .exists (exportJarFullPath )) {
251253 final int [] result = new int [1 ];
252254 final Path finalJarPath = exportJarFullPath ;
253- WaitForProgressToShow .runOrInvokeAndWaitAboveProgress (
254- () -> result [0 ] = Messages .showYesNoDialog (project , finalJarPath + " already exists, replace it? " ,
255- Constants .actionName , getWarningIcon ()));
255+ app .invokeAndWait (() -> result [0 ] = Messages .showYesNoDialog (project , finalJarPath + " already exists, replace it? " ,
256+ Constants .actionName , getWarningIcon ()));
256257 if (result [0 ] == Messages .NO ) {
257258 return ;
258259 }
@@ -262,17 +263,16 @@ public void doExport(VirtualFile[] exportFiles) {
262263 final CompileStatusNotification packager = new ExportPacker (project , exportFiles , exportJarFullPath ,
263264 exportJavaFileCheckBox .isSelected (), exportClassFileCheckBox .isSelected (),
264265 exportTestFileCheckBox .isSelected ());
265- WaitForProgressToShow .runOrInvokeAndWaitAboveProgress (() ->
266- CompilerManager .getInstance (project ).make (project , null == modules ? new Module [0 ] : modules , packager ));
266+ app .invokeAndWait (() -> CompilerManager .getInstance (project ).make (project , null == modules ? new Module [0 ] : modules , packager ));
267267 }
268268 } else {
269- WaitForProgressToShow . runOrInvokeAndWaitAboveProgress (() -> showErrorDialog (project , "Please specify export jar file name" , Constants .actionName ));
269+ app . invokeAndWait (() -> showErrorDialog (project , "Please specify export jar file name" , Constants .actionName ));
270270 }
271271 }
272272
273273 private boolean isEmpty (VirtualFile [] exportFiles ) {
274274 if (exportFiles == null || exportFiles .length == 0 ) {
275- WaitForProgressToShow . runOrInvokeAndWaitAboveProgress (() -> showErrorDialog (project , "Export files is empty, please select them first" , Constants .actionName ));
275+ ApplicationManager . getApplication (). invokeAndWait (() -> showErrorDialog (project , "Export files is empty, please select them first" , Constants .actionName ));
276276 return true ;
277277 }
278278 return false ;
0 commit comments