Lines 124-130
Link Here
|
124 |
import org.netbeans.modules.cnd.spi.toolchain.CompilerSetFactory; |
124 |
import org.netbeans.modules.cnd.spi.toolchain.CompilerSetFactory; |
125 |
import org.netbeans.modules.cnd.utils.CndPathUtilities; |
125 |
import org.netbeans.modules.cnd.utils.CndPathUtilities; |
126 |
import org.netbeans.modules.cnd.utils.CndUtils; |
126 |
import org.netbeans.modules.cnd.utils.CndUtils; |
127 |
import org.netbeans.modules.cnd.utils.NamedRunnable; |
|
|
128 |
import org.netbeans.modules.cnd.utils.OSSComponentUsages; |
127 |
import org.netbeans.modules.cnd.utils.OSSComponentUsages; |
129 |
import org.netbeans.modules.cnd.utils.cache.CndFileUtils; |
128 |
import org.netbeans.modules.cnd.utils.cache.CndFileUtils; |
130 |
import org.netbeans.modules.cnd.utils.ui.ModalMessageDlg; |
129 |
import org.netbeans.modules.cnd.utils.ui.ModalMessageDlg; |
Lines 141-146
Link Here
|
141 |
import org.netbeans.modules.nativeexecution.api.util.ShellValidationSupport.ShellValidationStatus; |
140 |
import org.netbeans.modules.nativeexecution.api.util.ShellValidationSupport.ShellValidationStatus; |
142 |
import org.netbeans.modules.nativeexecution.api.util.WindowsSupport; |
141 |
import org.netbeans.modules.nativeexecution.api.util.WindowsSupport; |
143 |
import org.netbeans.modules.remote.spi.FileSystemProvider; |
142 |
import org.netbeans.modules.remote.spi.FileSystemProvider; |
|
|
143 |
import org.netbeans.spi.project.ActionProgress; |
144 |
import org.netbeans.spi.project.ActionProvider; |
144 |
import org.netbeans.spi.project.ActionProvider; |
145 |
import org.openide.DialogDescriptor; |
145 |
import org.openide.DialogDescriptor; |
146 |
import org.openide.DialogDisplayer; |
146 |
import org.openide.DialogDisplayer; |
Lines 155-161
Link Here
|
155 |
import org.openide.util.Exceptions; |
155 |
import org.openide.util.Exceptions; |
156 |
import org.openide.util.Lookup; |
156 |
import org.openide.util.Lookup; |
157 |
import org.openide.util.NbBundle; |
157 |
import org.openide.util.NbBundle; |
158 |
import org.openide.util.RequestProcessor; |
|
|
159 |
import org.openide.util.Utilities; |
158 |
import org.openide.util.Utilities; |
160 |
import org.openide.util.actions.SystemAction; |
159 |
import org.openide.util.actions.SystemAction; |
161 |
import org.openide.util.lookup.Lookups; |
160 |
import org.openide.util.lookup.Lookups; |
Lines 222-228
Link Here
|
222 |
private static final String TEST_SINGLE_STEP = "test-single"; // NOI18N |
221 |
private static final String TEST_SINGLE_STEP = "test-single"; // NOI18N |
223 |
private static final String DEBUG_TEST_STEP = "debug-test"; // NOI18N |
222 |
private static final String DEBUG_TEST_STEP = "debug-test"; // NOI18N |
224 |
private static final String DEBUG_STEPINTO_TEST_STEP = "debug-stepinto-test"; // NOI18N |
223 |
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 |
|
224 |
|
227 |
public MakeActionProvider(MakeProject project) { |
225 |
public MakeActionProvider(MakeProject project) { |
228 |
this.project = project; |
226 |
this.project = project; |
Lines 333-355
Link Here
|
333 |
} |
331 |
} |
334 |
final String finalCommand = command; |
332 |
final String finalCommand = command; |
335 |
|
333 |
|
336 |
CancellableTask actionWorker = new CancellableTask() { |
334 |
CancellableTask actionWorker = new CancellableTask(ActionProgress.start(context)) { |
337 |
|
335 |
|
338 |
@Override |
336 |
@Override |
339 |
protected void runImpl() { |
337 |
protected void runImpl() { |
340 |
final ArrayList<ProjectActionEvent> actionEvents = new ArrayList<>(); |
338 |
final ArrayList<ProjectActionEvent> actionEvents = new ArrayList<>(); |
341 |
for (MakeConfiguration conf : confs) { |
339 |
for (MakeConfiguration conf : confs) { |
342 |
addAction(actionEvents, pd, conf, finalCommand, context, cancelled); |
340 |
if (!addAction(actionEvents, pd, conf, finalCommand, context, cancelled)) { |
|
|
341 |
if (!cancelled.isCanceled()) { |
342 |
cancelled.actionProgress.finished(false); |
343 |
} |
344 |
return; |
345 |
} |
343 |
} |
346 |
} |
344 |
// Execute actions |
347 |
// Execute actions |
345 |
if (actionEvents.size() > 0 && !cancelled.isCanceled()) { |
348 |
if (!cancelled.isCanceled()) { |
346 |
RP.post(new NamedRunnable("Make Project Action Worker") { //NOI18N |
349 |
if (actionEvents.size() > 0) { |
347 |
|
350 |
ProjectActionSupport.getInstance().fireActionPerformed(actionEvents.toArray(new ProjectActionEvent[actionEvents.size()]),null, cancelled.actionProgress); |
348 |
@Override |
351 |
} else { |
349 |
protected void runImpl() { |
352 |
cancelled.actionProgress.finished(false); |
350 |
ProjectActionSupport.getInstance().fireActionPerformed(actionEvents.toArray(new ProjectActionEvent[actionEvents.size()])); |
353 |
} |
351 |
} |
|
|
352 |
}); |
353 |
} |
354 |
} |
354 |
} |
355 |
} |
355 |
}; |
356 |
}; |
Lines 364-370
Link Here
|
364 |
} |
365 |
} |
365 |
|
366 |
|
366 |
public void invokeCustomAction(final MakeConfigurationDescriptor pd, final MakeConfiguration conf, final ProjectActionHandler customProjectActionHandler) { |
367 |
public void invokeCustomAction(final MakeConfigurationDescriptor pd, final MakeConfiguration conf, final ProjectActionHandler customProjectActionHandler) { |
367 |
CancellableTask actionWorker = new CancellableTask() { |
368 |
CancellableTask actionWorker = new CancellableTask(null) { |
368 |
|
369 |
|
369 |
@Override |
370 |
@Override |
370 |
protected void runImpl() { |
371 |
protected void runImpl() { |
Lines 400-406
Link Here
|
400 |
} |
401 |
} |
401 |
} |
402 |
} |
402 |
// start validation phase |
403 |
// start validation phase |
403 |
wrapper = new CancellableTask() { |
404 |
wrapper = new CancellableTask(actionWorker.cancelled.actionProgress) { |
404 |
|
405 |
|
405 |
@Override |
406 |
@Override |
406 |
public boolean cancel() { |
407 |
public boolean cancel() { |
Lines 451-462
Link Here
|
451 |
} |
452 |
} |
452 |
} |
453 |
} |
453 |
|
454 |
|
454 |
private void addAction(ArrayList<ProjectActionEvent> actionEvents, |
455 |
private boolean addAction(ArrayList<ProjectActionEvent> actionEvents, |
455 |
MakeConfigurationDescriptor pd, MakeConfiguration conf, String command, Lookup context, |
456 |
MakeConfigurationDescriptor pd, MakeConfiguration conf, String command, Lookup context, |
456 |
CanceledState cancelled) throws IllegalArgumentException { |
457 |
CanceledState cancelled) throws IllegalArgumentException { |
457 |
|
458 |
|
458 |
if (cancelled.isCanceled()) { |
459 |
if (cancelled.isCanceled()) { |
459 |
return; |
460 |
return false; |
460 |
} |
461 |
} |
461 |
|
462 |
|
462 |
AtomicBoolean validated = new AtomicBoolean(false); |
463 |
AtomicBoolean validated = new AtomicBoolean(false); |
Lines 464-470
Link Here
|
464 |
|
465 |
|
465 |
String[] targetNames = getTargetNames(command, conf, context); |
466 |
String[] targetNames = getTargetNames(command, conf, context); |
466 |
if (targetNames == null || targetNames.length == 0) { |
467 |
if (targetNames == null || targetNames.length == 0) { |
467 |
return; |
468 |
return false; |
468 |
} |
469 |
} |
469 |
|
470 |
|
470 |
for (int i = 0; i < targetNames.length; i++) { |
471 |
for (int i = 0; i < targetNames.length; i++) { |
Lines 477-491
Link Here
|
477 |
if (delegate != null) { |
478 |
if (delegate != null) { |
478 |
for (String target : delegate) { |
479 |
for (String target : delegate) { |
479 |
if (!addTarget(target, actionEvents, pd, conf, context, cancelled, validated)) { |
480 |
if (!addTarget(target, actionEvents, pd, conf, context, cancelled, validated)) { |
480 |
break; |
481 |
return false; |
481 |
} |
482 |
} |
482 |
} |
483 |
} |
483 |
} else { |
484 |
} else { |
484 |
if (!addTarget(targetName, actionEvents, pd, conf, context, cancelled, validated)) { |
485 |
if (!addTarget(targetName, actionEvents, pd, conf, context, cancelled, validated)) { |
485 |
break; |
486 |
return false; |
486 |
} |
487 |
} |
487 |
} |
488 |
} |
488 |
} |
489 |
} |
|
|
490 |
return true; |
489 |
} |
491 |
} |
490 |
|
492 |
|
491 |
private boolean addTarget(String targetName, ArrayList<ProjectActionEvent> actionEvents, |
493 |
private boolean addTarget(String targetName, ArrayList<ProjectActionEvent> actionEvents, |
Lines 1948-1953
Link Here
|
1948 |
} |
1950 |
} |
1949 |
|
1951 |
|
1950 |
private abstract static class CancellableTask implements Runnable, Cancellable { |
1952 |
private abstract static class CancellableTask implements Runnable, Cancellable { |
|
|
1953 |
private volatile Thread thread; |
1954 |
protected final CanceledState cancelled; |
1955 |
|
1956 |
CancellableTask(ActionProgress actionProgress) { |
1957 |
cancelled = new CanceledState(actionProgress); |
1958 |
} |
1951 |
|
1959 |
|
1952 |
protected abstract void runImpl(); |
1960 |
protected abstract void runImpl(); |
1953 |
|
1961 |
|
Lines 1967-1986
Link Here
|
1967 |
} |
1975 |
} |
1968 |
return true; |
1976 |
return true; |
1969 |
} |
1977 |
} |
1970 |
|
|
|
1971 |
private volatile Thread thread; |
1972 |
protected final CanceledState cancelled = new CanceledState(); |
1973 |
} |
1978 |
} |
1974 |
|
1979 |
|
1975 |
private static final class CanceledState { |
1980 |
private static final class CanceledState { |
1976 |
private final AtomicBoolean cancelled = new AtomicBoolean(false); |
1981 |
private final AtomicBoolean cancelled = new AtomicBoolean(false); |
1977 |
private final AtomicBoolean interruptable = new AtomicBoolean(true); |
1982 |
private final AtomicBoolean interruptable = new AtomicBoolean(true); |
|
|
1983 |
final ActionProgress actionProgress; |
1978 |
|
1984 |
|
1979 |
private CanceledState() { |
1985 |
private CanceledState(ActionProgress actionProgress) { |
|
|
1986 |
this.actionProgress = actionProgress; |
1980 |
} |
1987 |
} |
1981 |
|
1988 |
|
1982 |
public synchronized void cancel() { |
1989 |
public synchronized void cancel() { |
1983 |
cancelled.set(true); |
1990 |
cancelled.set(true); |
|
|
1991 |
if (actionProgress != null) { |
1992 |
actionProgress.finished(false); |
1993 |
} |
1984 |
} |
1994 |
} |
1985 |
|
1995 |
|
1986 |
public synchronized boolean isCanceled() { |
1996 |
public synchronized boolean isCanceled() { |