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 211005
Collapse All | Expand All

(-)a/maven/manifest.mf (-1 / +1 lines)
Lines 1-6 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.modules.maven/2
2
OpenIDE-Module: org.netbeans.modules.maven/2
3
OpenIDE-Module-Specification-Version: 2.46
3
OpenIDE-Module-Specification-Version: 2.47
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/maven/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/maven/Bundle.properties
5
OpenIDE-Module-Layer: org/netbeans/modules/maven/layer.xml
5
OpenIDE-Module-Layer: org/netbeans/modules/maven/layer.xml
6
AutoUpdate-Show-In-Client: false
6
AutoUpdate-Show-In-Client: false
(-)a/maven/nbproject/project.xml (-1 / +1 lines)
Lines 222-228 Link Here
222
                    <build-prerequisite/>
222
                    <build-prerequisite/>
223
                    <compile-dependency/>
223
                    <compile-dependency/>
224
                    <run-dependency>
224
                    <run-dependency>
225
                        <specification-version>1.0</specification-version>
225
                        <specification-version>1.1</specification-version>
226
                    </run-dependency>
226
                    </run-dependency>
227
                </dependency>
227
                </dependency>
228
                <dependency>
228
                <dependency>
(-)a/maven/src/org/netbeans/modules/maven/api/execute/RunUtils.java (-10 / +1 lines)
Lines 55-61 Link Here
55
import org.netbeans.modules.maven.execute.MavenExecutor;
55
import org.netbeans.modules.maven.execute.MavenExecutor;
56
import org.netbeans.modules.maven.indexer.api.RepositoryIndexer;
56
import org.netbeans.modules.maven.indexer.api.RepositoryIndexer;
57
import org.netbeans.modules.maven.indexer.api.RepositoryPreferences;
57
import org.netbeans.modules.maven.indexer.api.RepositoryPreferences;
58
import org.netbeans.modules.project.indexingbridge.IndexingBridge;
59
import org.netbeans.spi.project.AuxiliaryProperties;
58
import org.netbeans.spi.project.AuxiliaryProperties;
60
import org.openide.LifecycleManager;
59
import org.openide.LifecycleManager;
61
import org.openide.execution.ExecutionEngine;
60
import org.openide.execution.ExecutionEngine;
Lines 138-152 Link Here
138
    }
137
    }
139
    
138
    
140
    private static ExecutorTask executeMavenImpl(String runtimeName, final MavenExecutor exec) {
139
    private static ExecutorTask executeMavenImpl(String runtimeName, final MavenExecutor exec) {
141
        ExecutorTask task =  ExecutionEngine.getDefault().execute(runtimeName, new Runnable() {
140
        ExecutorTask task =  ExecutionEngine.getDefault().execute(runtimeName, exec, exec.getInputOutput());
142
            @Override public void run() {
143
                IndexingBridge.getDefault().runProtected(new Runnable() {
144
                    @Override public void run() {
145
                        exec.run();
146
                    }
147
                });
148
            }
149
        }, exec.getInputOutput());
150
        exec.setTask(task);
141
        exec.setTask(task);
151
        return task;
142
        return task;
152
    }
143
    }
(-)a/maven/src/org/netbeans/modules/maven/execute/AbstractOutputHandler.java (+18 lines)
Lines 50-55 Link Here
50
import java.util.Iterator;
50
import java.util.Iterator;
51
import java.util.List;
51
import java.util.List;
52
import java.util.Set;
52
import java.util.Set;
53
import java.util.concurrent.atomic.AtomicBoolean;
53
import org.netbeans.api.progress.ProgressHandle;
54
import org.netbeans.api.progress.ProgressHandle;
54
import org.netbeans.modules.maven.api.execute.RunConfig;
55
import org.netbeans.modules.maven.api.execute.RunConfig;
55
import org.netbeans.modules.maven.api.output.ContextOutputProcessorFactory;
56
import org.netbeans.modules.maven.api.output.ContextOutputProcessorFactory;
Lines 58-63 Link Here
58
import org.netbeans.modules.maven.api.output.OutputProcessorFactory;
59
import org.netbeans.modules.maven.api.output.OutputProcessorFactory;
59
import org.netbeans.modules.maven.api.output.OutputVisitor;
60
import org.netbeans.modules.maven.api.output.OutputVisitor;
60
import org.netbeans.api.project.Project;
61
import org.netbeans.api.project.Project;
62
import org.netbeans.modules.project.indexingbridge.IndexingBridge;
61
import org.openide.util.Exceptions;
63
import org.openide.util.Exceptions;
62
import org.openide.util.Lookup;
64
import org.openide.util.Lookup;
63
import org.openide.util.RequestProcessor;
65
import org.openide.util.RequestProcessor;
Lines 80-85 Link Here
80
    protected Set<OutputProcessor> currentProcessors;
82
    protected Set<OutputProcessor> currentProcessors;
81
    protected Set<NotifyFinishOutputProcessor> toFinishProcessors;
83
    protected Set<NotifyFinishOutputProcessor> toFinishProcessors;
82
    protected OutputVisitor visitor;
84
    protected OutputVisitor visitor;
85
    private final AtomicBoolean protectedMode = new AtomicBoolean(); // #211005
83
    private RequestProcessor.Task sleepTask;
86
    private RequestProcessor.Task sleepTask;
84
    private static final int SLEEP_DELAY = 5000;
87
    private static final int SLEEP_DELAY = 5000;
85
88
Lines 91-98 Link Here
91
        sleepTask = new RequestProcessor(AbstractOutputHandler.class).create(new Runnable() {
94
        sleepTask = new RequestProcessor(AbstractOutputHandler.class).create(new Runnable() {
92
            public @Override void run() {
95
            public @Override void run() {
93
                hand.suspend("");
96
                hand.suspend("");
97
                exitProtectedMode();
94
            }
98
            }
95
        });
99
        });
100
        enterProtectedMode();
101
    }
102
103
    private void enterProtectedMode() {
104
        if (protectedMode.compareAndSet(false, true)) {
105
            IndexingBridge.getDefault().enterProtectedMode();
106
        }
107
    }
108
    private void exitProtectedMode() {
109
        if (protectedMode.compareAndSet(true, false)) {
110
            IndexingBridge.getDefault().exitProtectedMode();
111
        }
96
    }
112
    }
97
113
98
    protected abstract InputOutput getIO();
114
    protected abstract InputOutput getIO();
Lines 101-106 Link Here
101
        RequestProcessor.Task task = sleepTask;
117
        RequestProcessor.Task task = sleepTask;
102
        if (task != null) {
118
        if (task != null) {
103
            task.schedule(SLEEP_DELAY);
119
            task.schedule(SLEEP_DELAY);
120
            enterProtectedMode();
104
        }
121
        }
105
    }
122
    }
106
123
Lines 110-115 Link Here
110
        if (task != null) {
127
        if (task != null) {
111
            task.cancel();
128
            task.cancel();
112
            sleepTask = null;
129
            sleepTask = null;
130
            exitProtectedMode();
113
        }
131
        }
114
    }
132
    }
115
    
133
    
(-)a/o.apache.tools.ant.module/nbproject/project.properties (-1 / +1 lines)
Lines 42-48 Link Here
42
42
43
javac.compilerargs=-Xlint:unchecked
43
javac.compilerargs=-Xlint:unchecked
44
javac.source=1.6
44
javac.source=1.6
45
spec.version.base=3.54.0
45
spec.version.base=3.55.0
46
compile.ant.jar=${ant.core.lib}
46
compile.ant.jar=${ant.core.lib}
47
src-bridge.cp.extra=build/classes:${compile.ant.jar}
47
src-bridge.cp.extra=build/classes:${compile.ant.jar}
48
extra.module.files=\
48
extra.module.files=\
(-)a/o.apache.tools.ant.module/nbproject/project.xml (-1 / +1 lines)
Lines 98-104 Link Here
98
                    <build-prerequisite/>
98
                    <build-prerequisite/>
99
                    <compile-dependency/>
99
                    <compile-dependency/>
100
                    <run-dependency>
100
                    <run-dependency>
101
                        <specification-version>1.0</specification-version>
101
                        <specification-version>1.1</specification-version>
102
                    </run-dependency>
102
                    </run-dependency>
103
                </dependency>
103
                </dependency>
104
                <dependency>
104
                <dependency>
(-)a/o.apache.tools.ant.module/src-bridge/org/apache/tools/ant/module/bridge/impl/NbBuildLogger.java (+18 lines)
Lines 62-67 Link Here
62
import java.util.Locale;
62
import java.util.Locale;
63
import java.util.Map;
63
import java.util.Map;
64
import java.util.Set;
64
import java.util.Set;
65
import java.util.concurrent.atomic.AtomicBoolean;
65
import java.util.logging.Level;
66
import java.util.logging.Level;
66
import java.util.logging.Logger;
67
import java.util.logging.Logger;
67
import java.util.regex.Matcher;
68
import java.util.regex.Matcher;
Lines 83-88 Link Here
83
import org.apache.tools.ant.module.spi.AntSession;
84
import org.apache.tools.ant.module.spi.AntSession;
84
import org.apache.tools.ant.module.spi.TaskStructure;
85
import org.apache.tools.ant.module.spi.TaskStructure;
85
import org.netbeans.api.progress.ProgressHandle;
86
import org.netbeans.api.progress.ProgressHandle;
87
import org.netbeans.modules.project.indexingbridge.IndexingBridge;
86
import org.openide.awt.StatusDisplayer;
88
import org.openide.awt.StatusDisplayer;
87
import org.openide.util.Lookup;
89
import org.openide.util.Lookup;
88
import org.openide.util.NbBundle;
90
import org.openide.util.NbBundle;
Lines 119-127 Link Here
119
    private final Runnable interestingOutputCallback;
121
    private final Runnable interestingOutputCallback;
120
    private final ProgressHandle handle;
122
    private final ProgressHandle handle;
121
    private boolean insideRunTask = false; // #95201
123
    private boolean insideRunTask = false; // #95201
124
    private final AtomicBoolean protectedMode = new AtomicBoolean(); // #211005
122
    private final RequestProcessor.Task sleepTask = new RequestProcessor(NbBuildLogger.class.getName(), 1, false, false).create(new Runnable() {
125
    private final RequestProcessor.Task sleepTask = new RequestProcessor(NbBuildLogger.class.getName(), 1, false, false).create(new Runnable() {
123
        public @Override void run() {
126
        public @Override void run() {
124
            handle.suspend(insideRunTask ? NbBundle.getMessage(NbBuildLogger.class, "MSG_sleep_running") : "");
127
            handle.suspend(insideRunTask ? NbBundle.getMessage(NbBuildLogger.class, "MSG_sleep_running") : "");
128
            exitProtectedMode();
125
        }
129
        }
126
    });
130
    });
127
    private static final int SLEEP_DELAY = 5000;
131
    private static final int SLEEP_DELAY = 5000;
Lines 189-194 Link Here
189
        this.interestingOutputCallback = interestingOutputCallback;
193
        this.interestingOutputCallback = interestingOutputCallback;
190
        this.handle = handle;
194
        this.handle = handle;
191
        LOG.log(Level.FINE, "---- Initializing build of {0} \"{1}\" at verbosity {2} ----", new Object[] {origScript, displayName, verbosity});
195
        LOG.log(Level.FINE, "---- Initializing build of {0} \"{1}\" at verbosity {2} ----", new Object[] {origScript, displayName, verbosity});
196
        enterProtectedMode();
197
    }
198
199
    private void enterProtectedMode() {
200
        if (protectedMode.compareAndSet(false, true)) {
201
            IndexingBridge.getDefault().enterProtectedMode();
202
        }
203
    }
204
    private void exitProtectedMode() {
205
        if (protectedMode.compareAndSet(true, false)) {
206
            IndexingBridge.getDefault().exitProtectedMode();
207
        }
192
    }
208
    }
193
    
209
    
194
    /** Try to stop running at the next safe point. */
210
    /** Try to stop running at the next safe point. */
Lines 204-209 Link Here
204
        }
220
        }
205
        if (running) {
221
        if (running) {
206
            handle.switchToIndeterminate();
222
            handle.switchToIndeterminate();
223
            enterProtectedMode();
207
            sleepTask.schedule(SLEEP_DELAY);
224
            sleepTask.schedule(SLEEP_DELAY);
208
        }
225
        }
209
    }
226
    }
Lines 219-224 Link Here
219
        err.close();
236
        err.close();
220
        handle.finish();
237
        handle.finish();
221
        sleepTask.cancel();
238
        sleepTask.cancel();
239
        exitProtectedMode();
222
    }
240
    }
223
241
224
    private void verifyRunning() {
242
    private void verifyRunning() {
(-)a/o.apache.tools.ant.module/src/org/apache/tools/ant/module/run/TargetExecutor.java (-6 / +1 lines)
Lines 75-81 Link Here
75
import org.netbeans.api.progress.ProgressHandle;
75
import org.netbeans.api.progress.ProgressHandle;
76
import org.netbeans.api.progress.ProgressHandleFactory;
76
import org.netbeans.api.progress.ProgressHandleFactory;
77
import org.netbeans.modules.options.java.api.JavaOptions;
77
import org.netbeans.modules.options.java.api.JavaOptions;
78
import org.netbeans.modules.project.indexingbridge.IndexingBridge;
79
import org.openide.ErrorManager;
78
import org.openide.ErrorManager;
80
import org.openide.LifecycleManager;
79
import org.openide.LifecycleManager;
81
import org.openide.awt.Actions;
80
import org.openide.awt.Actions;
Lines 539-549 Link Here
539
        for (RerunAction ra : ras) {
538
        for (RerunAction ra : ras) {
540
            setEnabledEQ(ra, false);
539
            setEnabledEQ(ra, false);
541
        }
540
        }
542
        IndexingBridge.getDefault().runProtected(new Runnable() {
541
        ok = AntBridge.getInterface().run(buildFile, targetNames, in.get(), out, err, properties, verbosity, displayName, interestingOutputCallback, handle, io);
543
            @Override public void run() {
544
                ok = AntBridge.getInterface().run(buildFile, targetNames, in.get(), out, err, properties, verbosity, displayName, interestingOutputCallback, handle, io);
545
            }
546
        });
547
        
542
        
548
        } finally {
543
        } finally {
549
            if (io != null) {
544
            if (io != null) {
(-)a/parsing.api/nbproject/project.properties (-1 / +1 lines)
Lines 3-9 Link Here
3
javac.source=1.6
3
javac.source=1.6
4
javadoc.apichanges=${basedir}/apichanges.xml
4
javadoc.apichanges=${basedir}/apichanges.xml
5
javadoc.arch=${basedir}/arch.xml
5
javadoc.arch=${basedir}/arch.xml
6
spec.version.base=1.52.0
6
spec.version.base=1.53.0
7
7
8
test.config.stableBTD.includes=**/*Test.class
8
test.config.stableBTD.includes=**/*Test.class
9
test.config.stableBTD.excludes=\
9
test.config.stableBTD.excludes=\
(-)a/parsing.api/nbproject/project.xml (-1 / +1 lines)
Lines 118-124 Link Here
118
                    <build-prerequisite/>
118
                    <build-prerequisite/>
119
                    <compile-dependency/>
119
                    <compile-dependency/>
120
                    <run-dependency>
120
                    <run-dependency>
121
                        <specification-version>1.0</specification-version>
121
                        <specification-version>1.1</specification-version>
122
                    </run-dependency>
122
                    </run-dependency>
123
                </dependency>
123
                </dependency>
124
                <dependency>
124
                <dependency>
(-)a/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/IndexingBridgeImpl.java (-57 lines)
Lines 1-57 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2012 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.parsing.impl.indexing;
44
45
import java.util.concurrent.Callable;
46
import org.netbeans.modules.parsing.api.indexing.IndexingManager;
47
import org.netbeans.modules.project.indexingbridge.IndexingBridge;
48
import org.openide.util.lookup.ServiceProvider;
49
50
@ServiceProvider(service=IndexingBridge.class)
51
public class IndexingBridgeImpl extends IndexingBridge {
52
53
    @Override public <T> T runProtected(Callable<T> operation) throws Exception {
54
        return IndexingManager.getDefault().runProtected(operation);
55
    }
56
57
}
(-)a/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/RepositoryUpdater.java (-8 / +21 lines)
Lines 111-116 Link Here
111
import org.netbeans.modules.parsing.spi.ParseException;
111
import org.netbeans.modules.parsing.spi.ParseException;
112
import org.netbeans.modules.parsing.spi.Parser;
112
import org.netbeans.modules.parsing.spi.Parser;
113
import org.netbeans.modules.parsing.spi.indexing.*;
113
import org.netbeans.modules.parsing.spi.indexing.*;
114
import org.netbeans.modules.project.indexingbridge.IndexingBridge;
114
import org.openide.filesystems.FileChangeAdapter;
115
import org.openide.filesystems.FileChangeAdapter;
115
import org.openide.filesystems.FileChangeListener;
116
import org.openide.filesystems.FileChangeListener;
116
import org.openide.filesystems.FileEvent;
117
import org.openide.filesystems.FileEvent;
Lines 4945-4960 Link Here
4945
            }
4946
            }
4946
        }
4947
        }
4947
4948
4948
        public void enterProtectedMode() {
4949
        public void enterProtectedMode(@NullAllowed Long id) {
4949
            synchronized (todo) {
4950
            synchronized (todo) {
4950
                protectedOwners.add(Thread.currentThread().getId());
4951
                protectedOwners.add(id);
4951
                if (LOGGER.isLoggable(Level.FINE)) {
4952
                if (LOGGER.isLoggable(Level.FINE)) {
4952
                    LOGGER.log(Level.FINE, "Entering protected mode: {0}", protectedOwners.size()); //NOI18N
4953
                    // Call toString() now since exitProtectedMode might run before the log handler formats the record:
4954
                    LOGGER.log(Level.FINE, "Entering protected mode: {0}", protectedOwners.toString()); //NOI18N
4953
                }
4955
                }
4954
            }
4956
            }
4955
        }
4957
        }
4956
4958
4957
        public void exitProtectedMode(Runnable followupTask) {
4959
        public void exitProtectedMode(@NullAllowed Long id, @NullAllowed Runnable followupTask) {
4958
            synchronized (todo) {
4960
            synchronized (todo) {
4959
                if (protectedOwners.isEmpty()) {
4961
                if (protectedOwners.isEmpty()) {
4960
                    throw new IllegalStateException("Calling exitProtectedMode without enterProtectedMode"); //NOI18N
4962
                    throw new IllegalStateException("Calling exitProtectedMode without enterProtectedMode"); //NOI18N
Lines 4967-4975 Link Here
4967
                    }
4969
                    }
4968
                    followupTasks.add(followupTask);
4970
                    followupTasks.add(followupTask);
4969
                }
4971
                }
4970
                protectedOwners.remove(Thread.currentThread().getId());
4972
                protectedOwners.remove(id);
4971
                if (LOGGER.isLoggable(Level.FINE)) {
4973
                if (LOGGER.isLoggable(Level.FINE)) {
4972
                    LOGGER.log(Level.FINE, "Exiting protected mode: {0}", protectedOwners.size()); //NOI18N
4974
                    LOGGER.log(Level.FINE, "Exiting protected mode: {0}", protectedOwners.toString()); //NOI18N
4973
                }
4975
                }
4974
4976
4975
                if (protectedOwners.isEmpty()) {
4977
                if (protectedOwners.isEmpty()) {
Lines 5194-5199 Link Here
5194
                return w;
5196
                return w;
5195
            }
5197
            }
5196
        }
5198
        }
5199
5200
        @ServiceProvider(service=IndexingBridge.class)
5201
        public static class IndexingBridgeImpl extends IndexingBridge {
5202
            @Override public void enterProtectedMode() {
5203
                RepositoryUpdater.getDefault().getWorker().enterProtectedMode(null);
5204
            }
5205
            @Override public void exitProtectedMode() {
5206
                RepositoryUpdater.getDefault().getWorker().exitProtectedMode(null, null);
5207
            }
5208
        }
5209
5197
    } // End of Task class
5210
    } // End of Task class
5198
5211
5199
    private static final class DependenciesContext {
5212
    private static final class DependenciesContext {
Lines 5343-5354 Link Here
5343
5356
5344
        @Override
5357
        @Override
5345
        public void enterProtectedMode() {
5358
        public void enterProtectedMode() {
5346
            getWorker().enterProtectedMode();
5359
            getWorker().enterProtectedMode(Thread.currentThread().getId());
5347
        }
5360
        }
5348
5361
5349
        @Override
5362
        @Override
5350
        public void exitProtectedMode(Runnable followUpTask) {
5363
        public void exitProtectedMode(Runnable followUpTask) {
5351
            getWorker().exitProtectedMode(followUpTask);
5364
            getWorker().exitProtectedMode(Thread.currentThread().getId(), followUpTask);
5352
        }
5365
        }
5353
5366
5354
        @Override
5367
        @Override
(-)a/project.indexingbridge/manifest.mf (-1 / +1 lines)
Lines 1-5 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.modules.project.indexingbridge
2
OpenIDE-Module: org.netbeans.modules.project.indexingbridge
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/project/indexingbridge/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/project/indexingbridge/Bundle.properties
4
OpenIDE-Module-Specification-Version: 1.0
4
OpenIDE-Module-Specification-Version: 1.1
5
5
(-)a/project.indexingbridge/src/org/netbeans/modules/project/indexingbridge/IndexingBridge.java (-20 / +18 lines)
Lines 42-80 Link Here
42
42
43
package org.netbeans.modules.project.indexingbridge;
43
package org.netbeans.modules.project.indexingbridge;
44
44
45
import java.util.concurrent.Callable;
46
import org.openide.util.Lookup;
45
import org.openide.util.Lookup;
47
46
48
/**
47
/**
49
 * @see org.netbeans.modules.parsing.api.indexing.IndexingManager
48
 * Allows parser indexing to be temporarily suppressed.
49
 * Unlike {@code org.netbeans.modules.parsing.api.indexing.IndexingManager}
50
 * this is not block-scoped. Every call to {@link #enterProtectedMode} must
51
 * eventually be matched by exactly one call to {@link #exitProtectedMode}.
52
 * It is irrelevant which thread makes each call. It is permissible to make
53
 * multiple enter calls so long as an equal number of exit calls are eventually
54
 * made as well.
50
 */
55
 */
51
public abstract class IndexingBridge {
56
public abstract class IndexingBridge {
52
57
53
    protected IndexingBridge() {}
58
    protected IndexingBridge() {}
54
59
55
    public abstract <T> T runProtected(Callable<T> operation) throws Exception;
60
    /**
61
     * Begin suppression of indexing.
62
     */
63
    public abstract void enterProtectedMode();
56
64
57
    public final void runProtected(final Runnable operation) {
65
    /**
58
        try {
66
     * End suppression of indexing.
59
            runProtected(new Callable<Void>() {
67
     * Indexing may resume if this is the last matching call.
60
                @Override public Void call() throws Exception {
68
     */
61
                    operation.run();
69
    public abstract void exitProtectedMode();
62
                    return null;
63
                }
64
            });
65
        } catch (RuntimeException x) {
66
            throw x;
67
        } catch (Exception x) {
68
            throw new AssertionError(x);
69
        }
70
    }
71
70
72
    public static IndexingBridge getDefault() {
71
    public static IndexingBridge getDefault() {
73
        IndexingBridge b = Lookup.getDefault().lookup(IndexingBridge.class);
72
        IndexingBridge b = Lookup.getDefault().lookup(IndexingBridge.class);
74
        return b != null ? b : new IndexingBridge() {
73
        return b != null ? b : new IndexingBridge() {
75
            @Override public <T> T runProtected(Callable<T> operation) throws Exception {
74
            @Override public void enterProtectedMode() {}
76
                return operation.call();
75
            @Override public void exitProtectedMode() {}
77
            }
78
        };
76
        };
79
    }
77
    }
80
78
(-)a/projectui/nbproject/project.properties (-1 / +1 lines)
Lines 42-48 Link Here
42
42
43
javac.compilerargs=-Xlint:unchecked
43
javac.compilerargs=-Xlint:unchecked
44
javac.source=1.6
44
javac.source=1.6
45
spec.version.base=1.32.0
45
spec.version.base=1.33.0
46
46
47
javadoc.arch=${basedir}/arch.xml
47
javadoc.arch=${basedir}/arch.xml
48
javadoc.apichanges=${basedir}/apichanges.xml
48
javadoc.apichanges=${basedir}/apichanges.xml
(-)a/projectui/nbproject/project.xml (-1 / +1 lines)
Lines 99-105 Link Here
99
                    <build-prerequisite/>
99
                    <build-prerequisite/>
100
                    <compile-dependency/>
100
                    <compile-dependency/>
101
                    <run-dependency>
101
                    <run-dependency>
102
                        <specification-version>1.0</specification-version>
102
                        <specification-version>1.1</specification-version>
103
                    </run-dependency>
103
                    </run-dependency>
104
                </dependency>
104
                </dependency>
105
                <dependency>
105
                <dependency>
(-)a/projectui/src/org/netbeans/modules/project/ui/groups/Group.java (-4 / +5 lines)
Lines 396-403 Link Here
396
        toOpen.removeAll(oldOpen);
396
        toOpen.removeAll(oldOpen);
397
        assert !toClose.contains(null) : toClose;
397
        assert !toClose.contains(null) : toClose;
398
        assert !toOpen.contains(null) : toOpen;
398
        assert !toOpen.contains(null) : toOpen;
399
        IndexingBridge.getDefault().runProtected(new Runnable() {
399
        IndexingBridge.getDefault().enterProtectedMode();
400
            @Override public void run() {
400
        try {
401
        h.progress(Group_progress_closing(toClose.size()), 110);
401
        h.progress(Group_progress_closing(toClose.size()), 110);
402
        opl.close(toClose.toArray(new Project[toClose.size()]), false);
402
        opl.close(toClose.toArray(new Project[toClose.size()]), false);
403
        h.switchToIndeterminate();
403
        h.switchToIndeterminate();
Lines 406-413 Link Here
406
        if (g != null) {
406
        if (g != null) {
407
            opl.setMainProject(g.getMainProject());
407
            opl.setMainProject(g.getMainProject());
408
        }
408
        }
409
            }
409
        } finally {
410
        });
410
                IndexingBridge.getDefault().exitProtectedMode();
411
        }
411
        } finally {
412
        } finally {
412
            ProjectUtilities.WaitCursor.hide();
413
            ProjectUtilities.WaitCursor.hide();
413
            h.finish();
414
            h.finish();

Return to bug 211005