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

(-)a/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/api/NativeProcessBuilder.java (-2 / +23 lines)
Lines 58-63 Link Here
58
import org.netbeans.modules.nativeexecution.TerminalLocalNativeProcess;
58
import org.netbeans.modules.nativeexecution.TerminalLocalNativeProcess;
59
import org.netbeans.modules.nativeexecution.api.pty.PtySupport;
59
import org.netbeans.modules.nativeexecution.api.pty.PtySupport;
60
import org.netbeans.modules.nativeexecution.api.util.ConnectionManager;
60
import org.netbeans.modules.nativeexecution.api.util.ConnectionManager;
61
import org.netbeans.modules.nativeexecution.api.util.ConnectionManager.CancellationException;
61
import org.netbeans.modules.nativeexecution.api.util.ExternalTerminal;
62
import org.netbeans.modules.nativeexecution.api.util.ExternalTerminal;
62
import org.netbeans.modules.nativeexecution.api.util.ExternalTerminalProvider;
63
import org.netbeans.modules.nativeexecution.api.util.ExternalTerminalProvider;
63
import org.netbeans.modules.nativeexecution.api.util.MacroMap;
64
import org.netbeans.modules.nativeexecution.api.util.MacroMap;
Lines 65-70 Link Here
65
import org.netbeans.modules.nativeexecution.api.util.ShellValidationSupport;
66
import org.netbeans.modules.nativeexecution.api.util.ShellValidationSupport;
66
import org.netbeans.modules.nativeexecution.api.util.ShellValidationSupport.ShellValidationStatus;
67
import org.netbeans.modules.nativeexecution.api.util.ShellValidationSupport.ShellValidationStatus;
67
import org.netbeans.modules.nativeexecution.api.util.WindowsSupport;
68
import org.netbeans.modules.nativeexecution.api.util.WindowsSupport;
69
import org.openide.util.Exceptions;
70
import org.openide.util.UserQuestionException;
68
71
69
/**
72
/**
70
 * Utility class for the {@link NativeProcess external native process} creation.
73
 * Utility class for the {@link NativeProcess external native process} creation.
Lines 164-182 Link Here
164
     * @return new {@link NativeProcess} based on the properties configured
167
     * @return new {@link NativeProcess} based on the properties configured
165
     *             in this builder
168
     *             in this builder
166
     * @throws IOException if the process could not be created
169
     * @throws IOException if the process could not be created
170
     * @throws UserQuestionException in case the system is not yet connected
167
     */
171
     */
172
    @NbBundle.Messages({
173
        "#{0} - display name of execution environment",
174
        "EXC_NotConnectedQuestion=No connection to {0}. Connect now?"
175
    })
168
    @Override
176
    @Override
169
    public NativeProcess call() throws IOException {
177
    public NativeProcess call() throws IOException {
170
        AbstractNativeProcess process = null;
178
        AbstractNativeProcess process = null;
171
179
172
        ExecutionEnvironment execEnv = info.getExecutionEnvironment();
180
        final ExecutionEnvironment execEnv = info.getExecutionEnvironment();
173
181
174
        if (info.getCommand() == null) {
182
        if (info.getCommand() == null) {
175
            throw new IllegalStateException("No executable nor command line is specified"); // NOI18N
183
            throw new IllegalStateException("No executable nor command line is specified"); // NOI18N
176
        }
184
        }
177
185
178
        if (!ConnectionManager.getInstance().isConnectedTo(execEnv)) {
186
        if (!ConnectionManager.getInstance().isConnectedTo(execEnv)) {
179
            throw new IOException("No connection to " + execEnv.getDisplayName()); // NOI18N
187
            throw new UserQuestionException("No connection to " + execEnv.getDisplayName()) {
188
                @Override
189
                public void confirmed() throws IOException {
190
                    try {
191
                        ConnectionManager.getInstance().connectTo(execEnv);
192
                    } catch (CancellationException ex) {
193
                        throw new IOException(ex);
194
                    }
195
                }
196
                @Override
197
                public String getLocalizedMessage() {
198
                    return Bundle.EXC_NotConnectedQuestion(execEnv.getDisplayName());
199
                }
200
            };
180
        }
201
        }
181
202
182
        if (info.isPtyMode() && PtySupport.isSupportedFor(info.getExecutionEnvironment())) {
203
        if (info.isPtyMode() && PtySupport.isSupportedFor(info.getExecutionEnvironment())) {
(-)a/dlight.nativeexecution/test/unit/src/org/netbeans/modules/nativeexecution/api/NativeProcessBuilderTest.java (+22 lines)
Lines 65-70 Link Here
65
import org.netbeans.modules.nativeexecution.test.NativeExecutionBaseTestSuite;
65
import org.netbeans.modules.nativeexecution.test.NativeExecutionBaseTestSuite;
66
import org.openide.util.Exceptions;
66
import org.openide.util.Exceptions;
67
import org.openide.util.RequestProcessor;
67
import org.openide.util.RequestProcessor;
68
import org.openide.util.UserQuestionException;
68
69
69
public class NativeProcessBuilderTest extends NativeExecutionBaseTestCase {
70
public class NativeProcessBuilderTest extends NativeExecutionBaseTestCase {
70
71
Lines 259-264 Link Here
259
    public void testSetCommandLine() throws Exception {
260
    public void testSetCommandLine() throws Exception {
260
        doTestSetCommandLine(getTestExecutionEnvironment());
261
        doTestSetCommandLine(getTestExecutionEnvironment());
261
    }
262
    }
263
    
264
    public void testAsksForconnection() {
265
        ExecutionEnvironment ee = ExecutionEnvironmentFactory.createNew("never", "existed.com");
266
        NativeProcessBuilder b = NativeProcessBuilder.newProcessBuilder(ee);
267
        b.setExecutable("ade");
268
        b.setArguments("lsviews");
269
        try {
270
            b.call();
271
            fail("The previous call should thrown an exception");
272
        } catch (UserQuestionException ex) {
273
            // OK, expected
274
            assertEquals(
275
                "Localized message as expected",
276
                Bundle.EXC_NotConnectedQuestion(ee.getDisplayName()), 
277
                ex.getLocalizedMessage()
278
            );
279
            assertEquals("No connection to never@existed.com", ex.getMessage());
280
        } catch (IOException ex) {
281
            fail("we should not get IOException: " + ex);
282
        }
283
    }
262
284
263
    private void doTestSetCommandLine(ExecutionEnvironment execEnv) throws Exception {
285
    private void doTestSetCommandLine(ExecutionEnvironment execEnv) throws Exception {
264
        HostInfo hostinfo = HostInfoUtils.getHostInfo(execEnv);
286
        HostInfo hostinfo = HostInfoUtils.getHostInfo(execEnv);
(-)a/dlight.remote.impl/nbproject/project.properties (-1 / +1 lines)
Lines 1-7 Link Here
1
is.autoload=true
1
is.autoload=true
2
javac.source=1.6
2
javac.source=1.6
3
javac.compilerargs=-Xlint -Xlint:-serial
3
javac.compilerargs=-Xlint -Xlint:-serial
4
spec.version.base=1.14.0
4
spec.version.base=1.15.0
5
5
6
test.config.stableBTD.includes=**/*Test.class
6
test.config.stableBTD.includes=**/*Test.class
7
test.config.stableBTD.excludes=**/RemoteFSTCKTest.class
7
test.config.stableBTD.excludes=**/RemoteFSTCKTest.class
(-)a/dlight.remote.impl/nbproject/project.xml (-1 / +1 lines)
Lines 44-50 Link Here
44
                    <build-prerequisite/>
44
                    <build-prerequisite/>
45
                    <compile-dependency/>
45
                    <compile-dependency/>
46
                    <run-dependency>
46
                    <run-dependency>
47
                        <specification-version>1.9.4</specification-version>
47
                        <specification-version>1.15</specification-version>
48
                    </run-dependency>
48
                    </run-dependency>
49
                </dependency>
49
                </dependency>
50
                <dependency>
50
                <dependency>
(-)a/dlight.remote/nbproject/project.properties (-1 / +1 lines)
Lines 1-5 Link Here
1
is.autoload=true
1
is.autoload=true
2
javac.source=1.6
2
javac.source=1.6
3
javac.compilerargs=-Xlint -Xlint:-serial
3
javac.compilerargs=-Xlint -Xlint:-serial
4
spec.version.base=1.14.0
4
spec.version.base=1.15.0
5
5
(-)a/extexecution/apichanges.xml (+16 lines)
Lines 117-122 Link Here
117
    <changes>
117
    <changes>
118
118
119
        <change>
119
        <change>
120
            <api name="extexecution_spi"/>
121
            <summary>Advice to throw UserQuestionException</summary>
122
            <version major="1" minor="34"/>
123
            <date day="21" month="9" year="2012"/>
124
            <author login="jtulach"/>
125
            <compatibility addition="yes"/>
126
            <description>
127
                Providers of <code>ProcessBuilderImplementation</code> are
128
                advised to throw <code>UserQuestionException</code> in case
129
                they need some interaction with user.
130
            </description>
131
            <class package="org.netbeans.spi.extexecution" name="ProcessBuilderImplementation"/>
132
            <class package="org.netbeans.api.extexecution" name="ProcessBuilder"/>
133
            <issue number="217874"/>
134
        </change>
135
        <change>
120
            <api name="extexecution_spi_open"/>
136
            <api name="extexecution_spi_open"/>
121
            <summary>SPI to allow to split the API and implementation</summary>
137
            <summary>SPI to allow to split the API and implementation</summary>
122
            <version major="1" minor="33"/>
138
            <version major="1" minor="33"/>
(-)a/extexecution/manifest.mf (-1 / +1 lines)
Lines 2-7 Link Here
2
AutoUpdate-Show-In-Client: false
2
AutoUpdate-Show-In-Client: false
3
OpenIDE-Module: org.netbeans.modules.extexecution/2
3
OpenIDE-Module: org.netbeans.modules.extexecution/2
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/extexecution/resources/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/extexecution/resources/Bundle.properties
5
OpenIDE-Module-Specification-Version: 1.33
5
OpenIDE-Module-Specification-Version: 1.34
6
OpenIDE-Module-Recommends: org.netbeans.spi.extexecution.open.OptionOpenHandler, org.netbeans.spi.extexecution.open.FileOpenHandler, org.netbeans.spi.extexecution.open.HttpOpenHandler
6
OpenIDE-Module-Recommends: org.netbeans.spi.extexecution.open.OptionOpenHandler, org.netbeans.spi.extexecution.open.FileOpenHandler, org.netbeans.spi.extexecution.open.HttpOpenHandler
7
7
(-)a/extexecution/src/org/netbeans/api/extexecution/ProcessBuilder.java (+9 lines)
Lines 54-59 Link Here
54
import org.netbeans.spi.extexecution.ProcessBuilderImplementation;
54
import org.netbeans.spi.extexecution.ProcessBuilderImplementation;
55
import org.openide.util.NbBundle;
55
import org.openide.util.NbBundle;
56
import org.openide.util.Parameters;
56
import org.openide.util.Parameters;
57
import org.openide.util.UserQuestionException;
57
58
58
/**
59
/**
59
 * Abstraction of process builders. You can freely configure the parameters
60
 * Abstraction of process builders. You can freely configure the parameters
Lines 228-233 Link Here
228
     * <p>
229
     * <p>
229
     * Actual behavior depends on the builder implementation, but it should
230
     * Actual behavior depends on the builder implementation, but it should
230
     * respect all the properties configured on this builder.
231
     * respect all the properties configured on this builder.
232
     * <p>
233
     * Since version 1.34 implementors of this method are advised to throw
234
     * a {@link UserQuestionException} in case the execution cannot be
235
     * performed and requires additional user confirmation, or configuration. 
236
     * Callers of this method may check for this exception and handle it
237
     * appropriately.
231
     *
238
     *
232
     * @see ProcessBuilderImplementation
239
     * @see ProcessBuilderImplementation
233
     * @return the new {@link Process} based on the properties configured
240
     * @return the new {@link Process} based on the properties configured
Lines 235-240 Link Here
235
     * @throws IOException if the process could not be created
242
     * @throws IOException if the process could not be created
236
     * @throws IllegalStateException if there is no executable configured
243
     * @throws IllegalStateException if there is no executable configured
237
     *             by {@link #setExecutable(java.lang.String)}
244
     *             by {@link #setExecutable(java.lang.String)}
245
     * @throws UserQuestionException if the execution cannot be performed
246
     *     without permission from the user
238
     */
247
     */
239
    @NonNull
248
    @NonNull
240
    @Override
249
    @Override
(-)a/extexecution/src/org/netbeans/spi/extexecution/ProcessBuilderImplementation.java (+5 lines)
Lines 46-51 Link Here
46
import java.util.Map;
46
import java.util.Map;
47
import org.netbeans.api.annotations.common.NonNull;
47
import org.netbeans.api.annotations.common.NonNull;
48
import org.netbeans.api.annotations.common.NullAllowed;
48
import org.netbeans.api.annotations.common.NullAllowed;
49
import org.openide.util.UserQuestionException;
49
50
50
/**
51
/**
51
 * The interface representing the implementation
52
 * The interface representing the implementation
Lines 80-85 Link Here
80
     * @return a process created with specified parameters and environment
81
     * @return a process created with specified parameters and environment
81
     *             configuration
82
     *             configuration
82
     * @throws IOException IOException if the process could not be created
83
     * @throws IOException IOException if the process could not be created
84
     * @throws UserQuestionException in case there is a need to interact with
85
     *    user, don't be afraid to throw a subclass of 
86
     *    {@link UserQuestionException} with overriden {@link UserQuestionException#confirmed()}
87
     *    method.
83
     */
88
     */
84
    @NonNull
89
    @NonNull
85
    Process createProcess(@NonNull String executable, @NullAllowed String workingDirectory, @NonNull List<String> arguments,
90
    Process createProcess(@NonNull String executable, @NullAllowed String workingDirectory, @NonNull List<String> arguments,
(-)a/remotefs.versioning/nbproject/project.xml (-1 / +1 lines)
Lines 19-25 Link Here
19
                    <compile-dependency/>
19
                    <compile-dependency/>
20
                    <run-dependency>
20
                    <run-dependency>
21
                        <release-version>2</release-version>
21
                        <release-version>2</release-version>
22
                        <specification-version>1.28</specification-version>
22
                        <specification-version>1.34</specification-version>
23
                    </run-dependency>
23
                    </run-dependency>
24
                </dependency>
24
                </dependency>
25
                <dependency>
25
                <dependency>

Return to bug 217874