This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 242340
Collapse All | Expand All

(-)a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/MakeActionProvider.java (-20 / +46 lines)
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() {
(-)a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/ProjectActionSupport.java (-3 / +17 lines)
Lines 101-106 Link Here
101
import org.netbeans.modules.nativeexecution.api.util.ProcessUtils;
101
import org.netbeans.modules.nativeexecution.api.util.ProcessUtils;
102
import org.netbeans.modules.nativeexecution.api.util.ProcessUtils.ExitStatus;
102
import org.netbeans.modules.nativeexecution.api.util.ProcessUtils.ExitStatus;
103
import org.netbeans.modules.remote.spi.FileSystemProvider;
103
import org.netbeans.modules.remote.spi.FileSystemProvider;
104
import org.netbeans.spi.project.ActionProgress;
104
import org.openide.DialogDescriptor;
105
import org.openide.DialogDescriptor;
105
import org.openide.DialogDisplayer;
106
import org.openide.DialogDisplayer;
106
import org.openide.LifecycleManager;
107
import org.openide.LifecycleManager;
Lines 254-260 Link Here
254
    }
255
    }
255
256
256
    public void fireActionPerformed(ProjectActionEvent[] paes, ProjectActionHandler preferredHandler) {
257
    public void fireActionPerformed(ProjectActionEvent[] paes, ProjectActionHandler preferredHandler) {
257
        submitTask(new EventsProcessor(paes, preferredHandler));
258
        fireActionPerformed(paes, null, null);
259
    }
260
261
    public void fireActionPerformed(ProjectActionEvent[] paes, ProjectActionHandler preferredHandler, ActionProgress actionProgress) {
262
        submitTask(new EventsProcessor(paes, preferredHandler, actionProgress));
258
    }
263
    }
259
264
260
    private static void submitTask(final EventsProcessor eventsProcessor) {
265
    private static void submitTask(final EventsProcessor eventsProcessor) {
Lines 347-358 Link Here
347
        private List<BuildAction> additional;
352
        private List<BuildAction> additional;
348
        private final ProjectActionHandler customHandler;
353
        private final ProjectActionHandler customHandler;
349
        private final FileOperationsNotifier fon;
354
        private final FileOperationsNotifier fon;
355
        private final ActionProgress actionProgress;
350
356
351
        public EventsProcessor(ProjectActionEvent[] paes, ProjectActionHandler customHandler) {
357
        public EventsProcessor(ProjectActionEvent[] paes, ProjectActionHandler customHandler, ActionProgress actionProgress) {
352
            this.paes = paes;
358
            this.paes = paes;
353
            this.customHandler = customHandler;
359
            this.customHandler = customHandler;
354
            fon = getFileOperationsNotifier(paes);
360
            fon = getFileOperationsNotifier(paes);
355
            tabs = IOTabsController.getDefault().openTabsGroup(getTabName(paes), MakeOptions.getInstance().getReuse());
361
            tabs = IOTabsController.getDefault().openTabsGroup(getTabName(paes), MakeOptions.getInstance().getReuse());
362
            this.actionProgress = actionProgress;
356
        }
363
        }
357
364
358
        private Action[] getActions(String name) {
365
        private Action[] getActions(String name) {
Lines 442-453 Link Here
442
449
443
            final AtomicInteger currentEventIndex = new AtomicInteger(-1);
450
            final AtomicInteger currentEventIndex = new AtomicInteger(-1);
444
            final AtomicReference<InputOutputTab> currentIORef = new AtomicReference<>(null);
451
            final AtomicReference<InputOutputTab> currentIORef = new AtomicReference<>(null);
445
452
            final AtomicBoolean result = new AtomicBoolean(true);
453
            
446
            try {
454
            try {
447
                for (final ProjectActionEvent currentEvent : paes) {
455
                for (final ProjectActionEvent currentEvent : paes) {
448
                    currentEventIndex.incrementAndGet();
456
                    currentEventIndex.incrementAndGet();
449
457
450
                    if (!ProjectActionSupport.checkProject(currentEvent)) {
458
                    if (!ProjectActionSupport.checkProject(currentEvent)) {
459
                        result.set(false);
451
                        return;
460
                        return;
452
                    }
461
                    }
453
462
Lines 464-469 Link Here
464
473
465
                    if ((isRunAction || type == PredefinedType.CHECK_EXECUTABLE)) {
474
                    if ((isRunAction || type == PredefinedType.CHECK_EXECUTABLE)) {
466
                        if (!checkExecutable(currentEvent)) {
475
                        if (!checkExecutable(currentEvent)) {
476
                            result.set(false);
467
                            return;
477
                            return;
468
                        }
478
                        }
469
                    }
479
                    }
Lines 573-578 Link Here
573
                            try {
583
                            try {
574
                                stopAction.setEnabled(false);
584
                                stopAction.setEnabled(false);
575
                                stepFailed.set(rc != 0);
585
                                stepFailed.set(rc != 0);
586
                                result.set(rc == 0);
576
                                if (additional != null) {
587
                                if (additional != null) {
577
                                    for (Action action : additional) {
588
                                    for (Action action : additional) {
578
                                        try {
589
                                        try {
Lines 625-630 Link Here
625
                rerunModAction.setEnabled(true);
636
                rerunModAction.setEnabled(true);
626
                stopAction.setEnabled(false);
637
                stopAction.setEnabled(false);
627
                fon.finishAll();
638
                fon.finishAll();
639
                if (actionProgress != null) {
640
                    actionProgress.finished(result.get());
641
                }
628
            }
642
            }
629
        }
643
        }
630
644

Return to bug 242340