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 (-24 / +34 lines)
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() {
(-)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