sdedic commented on a change in pull request #2915:
URL: https://github.com/apache/netbeans/pull/2915#discussion_r620068032
##########
File path:
java/java.mx.project/src/org/netbeans/modules/java/mx/project/SuiteActionProvider.java
##########
@@ -139,27 +141,50 @@ public void invokeAction(String action, Lookup context)
throws IllegalArgumentEx
return;
}
ListeningDICookie ldic = ListeningDICookie.create(-1);
- Object obj = ldic.getArgs().get("port"); // NOI18N
DebuggerInfo di = DebuggerInfo.create(ListeningDICookie.ID,
ldic);
- DebuggerEngine[] engines = { null };
- RequestProcessor.getDefault().post(() -> {
- DebuggerEngine[] engs =
DebuggerManager.getDebuggerManager().startDebugging(di);
- engines[0] = engs[0];
+ ASYNC.post(() -> {
+ DebuggerManager.getDebuggerManager().startDebugging(di);
});
int port = ldic.getPortNumber();
- runMx(Bundle.MSG_Unittest(fo.getName()), "--attach", "" +
port, "unittest", fo.getName() + testSuffix); // NOI18N
+ running = runBuildAndMx(null,
Bundle.MSG_Unittest(fo.getName()), "--attach", "" + port, "unittest",
fo.getName() + testSuffix); // NOI18N
break;
default:
throw new UnsupportedOperationException(action);
}
+ if (running != null) {
+ ActionProgress progress = ActionProgress.start(context);
+ running.handle((exitCode, error) -> {
+ progress.finished(exitCode == 0 && error == null);
+ return null;
+ });
+ }
}
- private boolean runMx(String taskName, String... args) {
+ private CompletionStage<Integer> ensureBuilt(FileObject fo) {
+ if (fo != null) {
+ SuiteSources.Group grp = prj.getSources().findGroup(fo);
+ if (grp != null) {
+ final String name = grp.getDisplayName();
+ return runMx(Bundle.MSG_BuildOnly(prj.getName(), name),
"build", "--only", name); // NOI18N
Review comment:
Should it be `.getDisplayName()` or `.getName()` for the `--only`
argument ?
##########
File path:
java/java.mx.project/src/org/netbeans/modules/java/mx/project/SuiteActionProvider.java
##########
@@ -120,7 +120,7 @@ public void invokeAction(String action, Lookup context)
throws IllegalArgumentEx
Toolkit.getDefaultToolkit().beep();
return;
}
- runMx(Bundle.MSG_Unittest(fo.getName()), "unittest",
fo.getName() + testSuffix); // NOI18N
+ runBuildAndMx(null, Bundle.MSG_Unittest(fo.getName()),
"unittest", fo.getName() + testSuffix); // NOI18N
Review comment:
Q: Run Single executes 'unittest' ? Usually 'Run single' executes the
production code ?
##########
File path:
java/java.mx.project/src/org/netbeans/modules/java/mx/project/SuiteActionProvider.java
##########
@@ -139,27 +141,50 @@ public void invokeAction(String action, Lookup context)
throws IllegalArgumentEx
return;
}
ListeningDICookie ldic = ListeningDICookie.create(-1);
- Object obj = ldic.getArgs().get("port"); // NOI18N
DebuggerInfo di = DebuggerInfo.create(ListeningDICookie.ID,
ldic);
- DebuggerEngine[] engines = { null };
- RequestProcessor.getDefault().post(() -> {
- DebuggerEngine[] engs =
DebuggerManager.getDebuggerManager().startDebugging(di);
- engines[0] = engs[0];
+ ASYNC.post(() -> {
+ DebuggerManager.getDebuggerManager().startDebugging(di);
});
int port = ldic.getPortNumber();
- runMx(Bundle.MSG_Unittest(fo.getName()), "--attach", "" +
port, "unittest", fo.getName() + testSuffix); // NOI18N
+ running = runBuildAndMx(null,
Bundle.MSG_Unittest(fo.getName()), "--attach", "" + port, "unittest",
fo.getName() + testSuffix); // NOI18N
break;
default:
throw new UnsupportedOperationException(action);
}
+ if (running != null) {
+ ActionProgress progress = ActionProgress.start(context);
+ running.handle((exitCode, error) -> {
+ progress.finished(exitCode == 0 && error == null);
+ return null;
+ });
+ }
}
- private boolean runMx(String taskName, String... args) {
+ private CompletionStage<Integer> ensureBuilt(FileObject fo) {
+ if (fo != null) {
+ SuiteSources.Group grp = prj.getSources().findGroup(fo);
+ if (grp != null) {
+ final String name = grp.getDisplayName();
+ return runMx(Bundle.MSG_BuildOnly(prj.getName(), name),
"build", "--only", name); // NOI18N
+ }
+ }
+ return runMx(Bundle.MSG_Rebuild(prj.getName()), "build"); // NOI18N
+ }
+
+ private CompletionStage<Integer> runBuildAndMx(FileObject fo, String
taskName, String... args) {
+ return ensureBuilt(fo).thenCompose((exitCode) -> {
+ return runMx(taskName, args);
+ });
+ }
+
+ private CompletableFuture<Integer> runMx(String taskName, String... args) {
final File suiteDir = FileUtil.toFile(prj.getProjectDirectory());
if (!suiteDir.isDirectory()) {
Toolkit.getDefaultToolkit().beep();
- return true;
+ return CompletableFuture.completedFuture(-1);
Review comment:
The calling method (`invokeAction`) checks for `runMx() != null`; this
result could trigger `ActionProgress.start` - OK ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists