Lines 141-146
Link Here
|
141 |
import org.netbeans.modules.nativeexecution.api.util.ShellValidationSupport.ShellValidationStatus; |
141 |
import org.netbeans.modules.nativeexecution.api.util.ShellValidationSupport.ShellValidationStatus; |
142 |
import org.netbeans.modules.nativeexecution.api.util.WindowsSupport; |
142 |
import org.netbeans.modules.nativeexecution.api.util.WindowsSupport; |
143 |
import org.netbeans.modules.remote.spi.FileSystemProvider; |
143 |
import org.netbeans.modules.remote.spi.FileSystemProvider; |
|
|
144 |
import org.netbeans.spi.project.ActionProgress; |
144 |
import org.netbeans.spi.project.ActionProvider; |
145 |
import org.netbeans.spi.project.ActionProvider; |
145 |
import org.openide.DialogDescriptor; |
146 |
import org.openide.DialogDescriptor; |
146 |
import org.openide.DialogDisplayer; |
147 |
import org.openide.DialogDisplayer; |
Lines 223-228
Link Here
|
223 |
private static final String DEBUG_TEST_STEP = "debug-test"; // NOI18N |
224 |
private static final String DEBUG_TEST_STEP = "debug-test"; // NOI18N |
224 |
private static final String DEBUG_STEPINTO_TEST_STEP = "debug-stepinto-test"; // NOI18N |
225 |
private static final String DEBUG_STEPINTO_TEST_STEP = "debug-stepinto-test"; // NOI18N |
225 |
private static final RequestProcessor RP = new RequestProcessor("Make Action RP", 1);// NOI18N |
226 |
private static final RequestProcessor RP = new RequestProcessor("Make Action RP", 1);// NOI18N |
|
|
227 |
private static final boolean PARALLEL_POST = "true".equals(System.getProperty("org.netbeans.modules.cnd.makeproject.parallel-build", "false")); |
226 |
|
228 |
|
227 |
public MakeActionProvider(MakeProject project) { |
229 |
public MakeActionProvider(MakeProject project) { |
228 |
this.project = project; |
230 |
this.project = project; |
Lines 332-355
Link Here
|
332 |
confs.add(activeConf); |
334 |
confs.add(activeConf); |
333 |
} |
335 |
} |
334 |
final String finalCommand = command; |
336 |
final String finalCommand = command; |
|
|
337 |
ActionProgress progress; |
338 |
if (PARALLEL_POST) { |
339 |
progress = null; |
340 |
} else { |
341 |
progress = ActionProgress.start(context); |
342 |
} |
335 |
|
343 |
|
336 |
CancellableTask actionWorker = new CancellableTask() { |
344 |
CancellableTask actionWorker = new CancellableTask(progress) { |
337 |
|
345 |
|
338 |
@Override |
346 |
@Override |
339 |
protected void runImpl() { |
347 |
protected void runImpl() { |
340 |
final ArrayList<ProjectActionEvent> actionEvents = new ArrayList<>(); |
348 |
final ArrayList<ProjectActionEvent> actionEvents = new ArrayList<>(); |
341 |
for (MakeConfiguration conf : confs) { |
349 |
for (MakeConfiguration conf : confs) { |
342 |
addAction(actionEvents, pd, conf, finalCommand, context, cancelled); |
350 |
if (!addAction(actionEvents, pd, conf, finalCommand, context, cancelled)) { |
|
|
351 |
if (!cancelled.isCanceled()) { |
352 |
cancelled.actionProgress.finished(false); |
353 |
} |
354 |
return; |
355 |
} |
343 |
} |
356 |
} |
344 |
// Execute actions |
357 |
// Execute actions |
345 |
if (actionEvents.size() > 0 && !cancelled.isCanceled()) { |
358 |
if (!cancelled.isCanceled()) { |
346 |
RP.post(new NamedRunnable("Make Project Action Worker") { //NOI18N |
359 |
if (actionEvents.size() > 0) { |
|
|
360 |
RP.post(new NamedRunnable("Make Project Action Worker") { //NOI18N |
347 |
|
361 |
|
348 |
@Override |
362 |
@Override |
349 |
protected void runImpl() { |
363 |
protected void runImpl() { |
350 |
ProjectActionSupport.getInstance().fireActionPerformed(actionEvents.toArray(new ProjectActionEvent[actionEvents.size()])); |
364 |
ProjectActionSupport.getInstance().fireActionPerformed(actionEvents.toArray(new ProjectActionEvent[actionEvents.size()]),null, cancelled.actionProgress); |
351 |
} |
365 |
} |
352 |
}); |
366 |
}); |
|
|
367 |
} else { |
368 |
cancelled.actionProgress.finished(false); |
369 |
} |
353 |
} |
370 |
} |
354 |
} |
371 |
} |
355 |
}; |
372 |
}; |
Lines 364-370
Link Here
|
364 |
} |
381 |
} |
365 |
|
382 |
|
366 |
public void invokeCustomAction(final MakeConfigurationDescriptor pd, final MakeConfiguration conf, final ProjectActionHandler customProjectActionHandler) { |
383 |
public void invokeCustomAction(final MakeConfigurationDescriptor pd, final MakeConfiguration conf, final ProjectActionHandler customProjectActionHandler) { |
367 |
CancellableTask actionWorker = new CancellableTask() { |
384 |
CancellableTask actionWorker = new CancellableTask(null) { |
368 |
|
385 |
|
369 |
@Override |
386 |
@Override |
370 |
protected void runImpl() { |
387 |
protected void runImpl() { |
Lines 400-406
Link Here
|
400 |
} |
417 |
} |
401 |
} |
418 |
} |
402 |
// start validation phase |
419 |
// start validation phase |
403 |
wrapper = new CancellableTask() { |
420 |
wrapper = new CancellableTask(actionWorker.cancelled.actionProgress) { |
404 |
|
421 |
|
405 |
@Override |
422 |
@Override |
406 |
public boolean cancel() { |
423 |
public boolean cancel() { |
Lines 451-462
Link Here
|
451 |
} |
468 |
} |
452 |
} |
469 |
} |
453 |
|
470 |
|
454 |
private void addAction(ArrayList<ProjectActionEvent> actionEvents, |
471 |
private boolean addAction(ArrayList<ProjectActionEvent> actionEvents, |
455 |
MakeConfigurationDescriptor pd, MakeConfiguration conf, String command, Lookup context, |
472 |
MakeConfigurationDescriptor pd, MakeConfiguration conf, String command, Lookup context, |
456 |
CanceledState cancelled) throws IllegalArgumentException { |
473 |
CanceledState cancelled) throws IllegalArgumentException { |
457 |
|
474 |
|
458 |
if (cancelled.isCanceled()) { |
475 |
if (cancelled.isCanceled()) { |
459 |
return; |
476 |
return false; |
460 |
} |
477 |
} |
461 |
|
478 |
|
462 |
AtomicBoolean validated = new AtomicBoolean(false); |
479 |
AtomicBoolean validated = new AtomicBoolean(false); |
Lines 464-470
Link Here
|
464 |
|
481 |
|
465 |
String[] targetNames = getTargetNames(command, conf, context); |
482 |
String[] targetNames = getTargetNames(command, conf, context); |
466 |
if (targetNames == null || targetNames.length == 0) { |
483 |
if (targetNames == null || targetNames.length == 0) { |
467 |
return; |
484 |
return false; |
468 |
} |
485 |
} |
469 |
|
486 |
|
470 |
for (int i = 0; i < targetNames.length; i++) { |
487 |
for (int i = 0; i < targetNames.length; i++) { |
Lines 477-491
Link Here
|
477 |
if (delegate != null) { |
494 |
if (delegate != null) { |
478 |
for (String target : delegate) { |
495 |
for (String target : delegate) { |
479 |
if (!addTarget(target, actionEvents, pd, conf, context, cancelled, validated)) { |
496 |
if (!addTarget(target, actionEvents, pd, conf, context, cancelled, validated)) { |
480 |
break; |
497 |
return false; |
481 |
} |
498 |
} |
482 |
} |
499 |
} |
483 |
} else { |
500 |
} else { |
484 |
if (!addTarget(targetName, actionEvents, pd, conf, context, cancelled, validated)) { |
501 |
if (!addTarget(targetName, actionEvents, pd, conf, context, cancelled, validated)) { |
485 |
break; |
502 |
return false; |
486 |
} |
503 |
} |
487 |
} |
504 |
} |
488 |
} |
505 |
} |
|
|
506 |
return true; |
489 |
} |
507 |
} |
490 |
|
508 |
|
491 |
private boolean addTarget(String targetName, ArrayList<ProjectActionEvent> actionEvents, |
509 |
private boolean addTarget(String targetName, ArrayList<ProjectActionEvent> actionEvents, |
Lines 1948-1953
Link Here
|
1948 |
} |
1966 |
} |
1949 |
|
1967 |
|
1950 |
private abstract static class CancellableTask implements Runnable, Cancellable { |
1968 |
private abstract static class CancellableTask implements Runnable, Cancellable { |
|
|
1969 |
private volatile Thread thread; |
1970 |
protected final CanceledState cancelled; |
1971 |
|
1972 |
CancellableTask(ActionProgress actionProgress) { |
1973 |
cancelled = new CanceledState(actionProgress); |
1974 |
} |
1951 |
|
1975 |
|
1952 |
protected abstract void runImpl(); |
1976 |
protected abstract void runImpl(); |
1953 |
|
1977 |
|
Lines 1967-1986
Link Here
|
1967 |
} |
1991 |
} |
1968 |
return true; |
1992 |
return true; |
1969 |
} |
1993 |
} |
1970 |
|
|
|
1971 |
private volatile Thread thread; |
1972 |
protected final CanceledState cancelled = new CanceledState(); |
1973 |
} |
1994 |
} |
1974 |
|
1995 |
|
1975 |
private static final class CanceledState { |
1996 |
private static final class CanceledState { |
1976 |
private final AtomicBoolean cancelled = new AtomicBoolean(false); |
1997 |
private final AtomicBoolean cancelled = new AtomicBoolean(false); |
1977 |
private final AtomicBoolean interruptable = new AtomicBoolean(true); |
1998 |
private final AtomicBoolean interruptable = new AtomicBoolean(true); |
|
|
1999 |
final ActionProgress actionProgress; |
1978 |
|
2000 |
|
1979 |
private CanceledState() { |
2001 |
private CanceledState(ActionProgress actionProgress) { |
|
|
2002 |
this.actionProgress = actionProgress; |
1980 |
} |
2003 |
} |
1981 |
|
2004 |
|
1982 |
public synchronized void cancel() { |
2005 |
public synchronized void cancel() { |
1983 |
cancelled.set(true); |
2006 |
cancelled.set(true); |
|
|
2007 |
if (actionProgress != null) { |
2008 |
actionProgress.finished(false); |
2009 |
} |
1984 |
} |
2010 |
} |
1985 |
|
2011 |
|
1986 |
public synchronized boolean isCanceled() { |
2012 |
public synchronized boolean isCanceled() { |