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/MakeActionProviderImpl.java (-16 / +33 lines)
Lines 137-142 Link Here
137
import org.netbeans.modules.nativeexecution.api.util.ShellValidationSupport.ShellValidationStatus;
137
import org.netbeans.modules.nativeexecution.api.util.ShellValidationSupport.ShellValidationStatus;
138
import org.netbeans.modules.nativeexecution.api.util.WindowsSupport;
138
import org.netbeans.modules.nativeexecution.api.util.WindowsSupport;
139
import org.netbeans.modules.remote.spi.FileSystemProvider;
139
import org.netbeans.modules.remote.spi.FileSystemProvider;
140
import org.netbeans.spi.project.ActionProgress;
140
import org.openide.LifecycleManager;
141
import org.openide.LifecycleManager;
141
import org.openide.filesystems.FileObject;
142
import org.openide.filesystems.FileObject;
142
import org.openide.filesystems.FileSystem;
143
import org.openide.filesystems.FileSystem;
Lines 203-208 Link Here
203
    private static final String DEBUG_TEST_STEP = "debug-test"; // NOI18N
204
    private static final String DEBUG_TEST_STEP = "debug-test"; // NOI18N
204
    private static final String DEBUG_STEPINTO_TEST_STEP = "debug-stepinto-test"; // NOI18N
205
    private static final String DEBUG_STEPINTO_TEST_STEP = "debug-stepinto-test"; // NOI18N
205
    private static final RequestProcessor RP = new RequestProcessor("Make Action RP", 1);// NOI18N
206
    private static final RequestProcessor RP = new RequestProcessor("Make Action RP", 1);// NOI18N
207
    private static final boolean PARALLEL_POST = "true".equals(System.getProperty("org.netbeans.modules.cnd.makeproject.parallel-build", "false"));    
206
208
207
    public MakeActionProviderImpl(MakeProject project) {
209
    public MakeActionProviderImpl(MakeProject project) {
208
        this.project = project;
210
        this.project = project;
Lines 312-335 Link Here
312
            confs.add(activeConf);
314
            confs.add(activeConf);
313
        }
315
        }
314
        final String finalCommand = command;
316
        final String finalCommand = command;
317
        ActionProgress progress;
318
        if (PARALLEL_POST) {
319
            progress = null;
320
        } else {
321
            progress = ActionProgress.start(context);
322
        }        
315
323
316
        CancellableTask actionWorker = new CancellableTask() {
324
        CancellableTask actionWorker = new CancellableTask(progress) {
317
325
318
            @Override
326
            @Override
319
            protected void runImpl() {
327
            protected void runImpl() {
320
                final ArrayList<ProjectActionEvent> actionEvents = new ArrayList<>();
328
                final ArrayList<ProjectActionEvent> actionEvents = new ArrayList<>();
321
                for (MakeConfiguration conf : confs) {
329
                for (MakeConfiguration conf : confs) {
322
                    addAction(actionEvents, pd, conf, finalCommand, context, cancelled);
330
                    if (!addAction(actionEvents, pd, conf, finalCommand, context, getCancelled())) {
331
                        if (!getCancelled().isCanceled()) {
332
                            getCancelled().getActionProgress().finished(false);
333
                        }
334
                        return;
335
                    }
323
                }
336
                }
324
                // Execute actions
337
                // Execute actions
325
                if (actionEvents.size() > 0 && !cancelled.isCanceled()) {
338
                if (!getCancelled().isCanceled()) {
326
                    RP.post(new NamedRunnable("Make Project Action Worker") { //NOI18N
339
                    if (actionEvents.size() > 0) {
327
340
                        RP.post(new NamedRunnable("Make Project Action Worker") { //NOI18N
328
                        @Override
341
                            @Override
329
                        protected void runImpl() {
342
                            protected void runImpl() {
330
                            ProjectActionSupport.getInstance().fireActionPerformed(actionEvents.toArray(new ProjectActionEvent[actionEvents.size()]));
343
                                ProjectActionSupport.getInstance().fireActionPerformed(actionEvents.toArray(new ProjectActionEvent[actionEvents.size()]),null, getCancelled().getActionProgress());
331
                        }
344
                            }
332
                    });
345
                        });
346
                    } else {
347
                        getCancelled().getActionProgress().finished(false);
348
                    }
333
                }
349
                }
334
            }
350
            }
335
        };
351
        };
Lines 344-355 Link Here
344
    }
360
    }
345
361
346
    public void invokeCustomAction(final MakeConfigurationDescriptor pd, final MakeConfiguration conf, final ProjectActionHandler customProjectActionHandler) {
362
    public void invokeCustomAction(final MakeConfigurationDescriptor pd, final MakeConfiguration conf, final ProjectActionHandler customProjectActionHandler) {
347
        CancellableTask actionWorker = new CancellableTask() {
363
        CancellableTask actionWorker = new CancellableTask(null) {
348
364
349
            @Override
365
            @Override
350
            protected void runImpl() {
366
            protected void runImpl() {
351
                ArrayList<ProjectActionEvent> actionEvents = new ArrayList<>();
367
                ArrayList<ProjectActionEvent> actionEvents = new ArrayList<>();
352
                addAction(actionEvents, pd, conf, MakeActionProviderImpl.COMMAND_CUSTOM_ACTION, null, cancelled);
368
                addAction(actionEvents, pd, conf, MakeActionProviderImpl.COMMAND_CUSTOM_ACTION, null, getCancelled());
353
                ProjectActionSupport.getInstance().fireActionPerformed(
369
                ProjectActionSupport.getInstance().fireActionPerformed(
354
                        actionEvents.toArray(new ProjectActionEvent[actionEvents.size()]),
370
                        actionEvents.toArray(new ProjectActionEvent[actionEvents.size()]),
355
                        customProjectActionHandler);
371
                        customProjectActionHandler);
Lines 380-386 Link Here
380
                }
396
                }
381
            }
397
            }
382
            // start validation phase
398
            // start validation phase
383
            wrapper = new CancellableTask() {
399
            wrapper = new CancellableTask(actionWorker.getCancelled().getActionProgress()) {
384
400
385
                @Override
401
                @Override
386
                public boolean cancel() {
402
                public boolean cancel() {
Lines 419-430 Link Here
419
                NbBundle.getMessage(MakeActionProviderImpl.class, "MSG_Validate_Host", record.getDisplayName()));
435
                NbBundle.getMessage(MakeActionProviderImpl.class, "MSG_Validate_Host", record.getDisplayName()));
420
    }
436
    }
421
437
422
    private void addAction(ArrayList<ProjectActionEvent> actionEvents,
438
    private boolean addAction(ArrayList<ProjectActionEvent> actionEvents,
423
            MakeConfigurationDescriptor pd, MakeConfiguration conf, String command, Lookup context,
439
            MakeConfigurationDescriptor pd, MakeConfiguration conf, String command, Lookup context,
424
            CanceledState cancelled) throws IllegalArgumentException {
440
            CanceledState cancelled) throws IllegalArgumentException {
425
441
426
        if (cancelled.isCanceled()) {
442
        if (cancelled.isCanceled()) {
427
            return;
443
            return false;
428
        }
444
        }
429
445
430
        AtomicBoolean validated = new AtomicBoolean(false);
446
        AtomicBoolean validated = new AtomicBoolean(false);
Lines 432-438 Link Here
432
448
433
        String[] targetNames = getTargetNames(command, conf, context);
449
        String[] targetNames = getTargetNames(command, conf, context);
434
        if (targetNames == null || targetNames.length == 0) {
450
        if (targetNames == null || targetNames.length == 0) {
435
            return;
451
            return false;
436
        }
452
        }
437
453
438
        for (int i = 0; i < targetNames.length; i++) {
454
        for (int i = 0; i < targetNames.length; i++) {
Lines 454-459 Link Here
454
                }
470
                }
455
            }
471
            }
456
        }
472
        }
473
        return true;
457
    }
474
    }
458
475
459
    private boolean addTarget(String targetName, ArrayList<ProjectActionEvent> actionEvents,
476
    private boolean addTarget(String targetName, ArrayList<ProjectActionEvent> actionEvents,
(-)a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/ProjectActionSupport.java (-4 / +15 lines)
Lines 58-64 Link Here
58
import java.util.concurrent.atomic.AtomicReference;
58
import java.util.concurrent.atomic.AtomicReference;
59
import java.util.logging.Level;
59
import java.util.logging.Level;
60
import java.util.logging.Logger;
60
import java.util.logging.Logger;
61
import javax.swing.Action;
62
import org.netbeans.api.progress.ProgressHandle;
61
import org.netbeans.api.progress.ProgressHandle;
63
import org.netbeans.api.project.Project;
62
import org.netbeans.api.project.Project;
64
import org.netbeans.api.project.ProjectUtils;
63
import org.netbeans.api.project.ProjectUtils;
Lines 98-103 Link Here
98
import org.netbeans.modules.nativeexecution.api.util.ProcessUtils;
97
import org.netbeans.modules.nativeexecution.api.util.ProcessUtils;
99
import org.netbeans.modules.nativeexecution.api.util.ProcessUtils.ExitStatus;
98
import org.netbeans.modules.nativeexecution.api.util.ProcessUtils.ExitStatus;
100
import org.netbeans.modules.remote.spi.FileSystemProvider;
99
import org.netbeans.modules.remote.spi.FileSystemProvider;
100
import org.netbeans.spi.project.ActionProgress;
101
import org.openide.LifecycleManager;
101
import org.openide.LifecycleManager;
102
import org.openide.filesystems.FileObject;
102
import org.openide.filesystems.FileObject;
103
import org.openide.filesystems.FileSystem;
103
import org.openide.filesystems.FileSystem;
Lines 107-113 Link Here
107
import org.openide.util.RequestProcessor;
107
import org.openide.util.RequestProcessor;
108
import org.openide.util.Utilities;
108
import org.openide.util.Utilities;
109
import org.openide.windows.IOProvider;
109
import org.openide.windows.IOProvider;
110
import org.openide.windows.InputOutput;
111
110
112
/**
111
/**
113
 * Most of the code here came from DefaultProjectActionHandler as result of
112
 * Most of the code here came from DefaultProjectActionHandler as result of
Lines 241-249 Link Here
241
    }
240
    }
242
241
243
    public void fireActionPerformed(ProjectActionEvent[] paes, ProjectActionHandler preferredHandler) {
242
    public void fireActionPerformed(ProjectActionEvent[] paes, ProjectActionHandler preferredHandler) {
244
        submitTask(new EventsProcessorImpl(paes, preferredHandler));
243
        fireActionPerformed(paes, null, null);
245
    }
244
    }
246
245
246
    public void fireActionPerformed(ProjectActionEvent[] paes, ProjectActionHandler preferredHandler, ActionProgress actionProgress) {
247
        submitTask(new EventsProcessorImpl(paes, preferredHandler, actionProgress));
248
     }
247
    private static void submitTask(final EventsProcessorImpl eventsProcessor) {
249
    private static void submitTask(final EventsProcessorImpl eventsProcessor) {
248
        tasksProcessor.post(eventsProcessor);
250
        tasksProcessor.post(eventsProcessor);
249
    }
251
    }
Lines 330-342 Link Here
330
        private final ProjectActionHandler customHandler;
332
        private final ProjectActionHandler customHandler;
331
        private final FileOperationsNotifier fon;
333
        private final FileOperationsNotifier fon;
332
        private final EventsProcessorActions epa;
334
        private final EventsProcessorActions epa;
335
        private final ActionProgress actionProgress;
333
336
334
        public EventsProcessorImpl(ProjectActionEvent[] paes, ProjectActionHandler customHandler) {
337
        public EventsProcessorImpl(ProjectActionEvent[] paes, ProjectActionHandler customHandler, ActionProgress actionProgress) {
335
            this.paes = paes;
338
            this.paes = paes;
336
            this.customHandler = customHandler;
339
            this.customHandler = customHandler;
337
            epa = EventsProcessorActions.getEventsProcessorActionsFactory().getEventsProcessorActions(this);
340
            epa = EventsProcessorActions.getEventsProcessorActionsFactory().getEventsProcessorActions(this);
338
            fon = getFileOperationsNotifier(paes);
341
            fon = getFileOperationsNotifier(paes);
339
            tabs = IOTabsController.getDefault().openTabsGroup(getTabName(paes), MakeOptions.getInstance().getReuse());
342
            tabs = IOTabsController.getDefault().openTabsGroup(getTabName(paes), MakeOptions.getInstance().getReuse());
343
            this.actionProgress = actionProgress;
340
        }
344
        }
341
345
342
        @Override
346
        @Override
Lines 402-413 Link Here
402
406
403
            final AtomicInteger currentEventIndex = new AtomicInteger(-1);
407
            final AtomicInteger currentEventIndex = new AtomicInteger(-1);
404
            final AtomicReference<InputOutputTab> currentIORef = new AtomicReference<>(null);
408
            final AtomicReference<InputOutputTab> currentIORef = new AtomicReference<>(null);
409
            final AtomicBoolean result = new AtomicBoolean(true);
405
410
406
            try {
411
            try {
407
                for (final ProjectActionEvent currentEvent : paes) {
412
                for (final ProjectActionEvent currentEvent : paes) {
408
                    currentEventIndex.incrementAndGet();
413
                    currentEventIndex.incrementAndGet();
409
414
410
                    if (!ProjectActionSupport.checkProject(currentEvent)) {
415
                    if (!ProjectActionSupport.checkProject(currentEvent)) {
416
                        result.set(false);
411
                        return;
417
                        return;
412
                    }
418
                    }
413
419
Lines 425-430 Link Here
425
431
426
                    if ((isRunAction || type == PredefinedType.CHECK_EXECUTABLE)) {
432
                    if ((isRunAction || type == PredefinedType.CHECK_EXECUTABLE)) {
427
                        if (!checkExecutable(currentEvent)) {
433
                        if (!checkExecutable(currentEvent)) {
434
                            result.set(false);
428
                            return;
435
                            return;
429
                        }
436
                        }
430
                    }
437
                    }
Lines 518-523 Link Here
518
                            try {
525
                            try {
519
                                epa.setEnableStopAction(false);
526
                                epa.setEnableStopAction(false);
520
                                stepFailed.set(rc != 0);
527
                                stepFailed.set(rc != 0);
528
                                result.set(rc == 0);
521
                                if (epa.getAdditional() != null) {
529
                                if (epa.getAdditional() != null) {
522
                                    epa.getAdditional().forEach((action) -> {
530
                                    epa.getAdditional().forEach((action) -> {
523
                                        try {
531
                                        try {
Lines 570-575 Link Here
570
                epa.setEnableRerunModAction(true);
578
                epa.setEnableRerunModAction(true);
571
                epa.setEnableStopAction(false);
579
                epa.setEnableStopAction(false);
572
                fon.finishAll();
580
                fon.finishAll();
581
                if (actionProgress != null) {
582
                    actionProgress.finished(result.get());
583
                }
573
            }
584
            }
574
        }
585
        }
575
586
(-)a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/uiapi/LongOperation.java (-3 / +20 lines)
Lines 40-45 Link Here
40
package org.netbeans.modules.cnd.makeproject.uiapi;
40
package org.netbeans.modules.cnd.makeproject.uiapi;
41
41
42
import java.util.concurrent.atomic.AtomicBoolean;
42
import java.util.concurrent.atomic.AtomicBoolean;
43
import org.netbeans.spi.project.ActionProgress;
43
import org.openide.util.Cancellable;
44
import org.openide.util.Cancellable;
44
import org.openide.util.Lookup;
45
import org.openide.util.Lookup;
45
46
Lines 51-62 Link Here
51
    public static final class CanceledState {
52
    public static final class CanceledState {
52
        private final AtomicBoolean cancelled = new AtomicBoolean(false);
53
        private final AtomicBoolean cancelled = new AtomicBoolean(false);
53
        private final AtomicBoolean interruptable = new AtomicBoolean(true);
54
        private final AtomicBoolean interruptable = new AtomicBoolean(true);
55
        private final ActionProgress actionProgress;
54
        
56
        
55
        private CanceledState() {
57
        private CanceledState(ActionProgress actionProgress) {
58
            this.actionProgress = actionProgress;
56
        }
59
        }
57
        
60
        
58
        public synchronized void cancel() {
61
        public synchronized void cancel() {
59
            cancelled.set(true);
62
            cancelled.set(true);
63
            if (actionProgress != null) {
64
                actionProgress.finished(false);
65
            }
60
        }
66
        }
61
        
67
        
62
        public synchronized boolean isCanceled() {
68
        public synchronized boolean isCanceled() {
Lines 70-79 Link Here
70
        public synchronized boolean isInterruptable(){
76
        public synchronized boolean isInterruptable(){
71
            return interruptable.get();
77
            return interruptable.get();
72
        }
78
        }
79
80
        public ActionProgress getActionProgress() {
81
            return actionProgress;
82
        }
73
    }
83
    }
74
    
84
    
75
    public abstract static class CancellableTask implements Runnable, Cancellable {
85
    public abstract static class CancellableTask implements Runnable, Cancellable {
86
        private volatile Thread thread;
87
        private final CanceledState cancelled;
76
88
89
        public CancellableTask(ActionProgress actionProgress) {
90
            cancelled = new CanceledState(actionProgress);
91
        }
92
 
77
        protected abstract void runImpl();
93
        protected abstract void runImpl();
78
        
94
        
79
        @Override
95
        @Override
Lines 93-100 Link Here
93
            return true;
109
            return true;
94
        }
110
        }
95
111
96
        private volatile Thread thread;
112
        public CanceledState getCancelled() {
97
        protected final CanceledState cancelled = new CanceledState();
113
            return cancelled;
114
        }
98
    }
115
    }
99
    
116
    
100
    public abstract void executeLongOperation(CancellableTask task, String title, String message);
117
    public abstract void executeLongOperation(CancellableTask task, String title, String message);

Return to bug 242340