diff -r 2ffb0b254787 dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/api/NativeProcessBuilder.java --- a/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/api/NativeProcessBuilder.java Wed Sep 19 11:32:54 2012 +0200 +++ b/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/api/NativeProcessBuilder.java Wed Sep 19 16:09:20 2012 +0200 @@ -58,6 +58,7 @@ import org.netbeans.modules.nativeexecution.TerminalLocalNativeProcess; import org.netbeans.modules.nativeexecution.api.pty.PtySupport; import org.netbeans.modules.nativeexecution.api.util.ConnectionManager; +import org.netbeans.modules.nativeexecution.api.util.ConnectionManager.CancellationException; import org.netbeans.modules.nativeexecution.api.util.ExternalTerminal; import org.netbeans.modules.nativeexecution.api.util.ExternalTerminalProvider; import org.netbeans.modules.nativeexecution.api.util.MacroMap; @@ -65,6 +66,8 @@ import org.netbeans.modules.nativeexecution.api.util.ShellValidationSupport; import org.netbeans.modules.nativeexecution.api.util.ShellValidationSupport.ShellValidationStatus; import org.netbeans.modules.nativeexecution.api.util.WindowsSupport; +import org.openide.util.Exceptions; +import org.openide.util.UserQuestionException; /** * Utility class for the {@link NativeProcess external native process} creation. @@ -164,19 +167,37 @@ * @return new {@link NativeProcess} based on the properties configured * in this builder * @throws IOException if the process could not be created + * @throws UserQuestionException in case the system is not yet connected */ + @NbBundle.Messages({ + "#{0} - display name of execution environment", + "EXC_NotConnectedQuestion=No connection to {0}. Connect now?" + }) @Override public NativeProcess call() throws IOException { AbstractNativeProcess process = null; - ExecutionEnvironment execEnv = info.getExecutionEnvironment(); + final ExecutionEnvironment execEnv = info.getExecutionEnvironment(); if (info.getCommand() == null) { throw new IllegalStateException("No executable nor command line is specified"); // NOI18N } if (!ConnectionManager.getInstance().isConnectedTo(execEnv)) { - throw new IOException("No connection to " + execEnv.getDisplayName()); // NOI18N + throw new UserQuestionException("No connection to " + execEnv.getDisplayName()) { + @Override + public void confirmed() throws IOException { + try { + ConnectionManager.getInstance().connectTo(execEnv); + } catch (CancellationException ex) { + throw new IOException(ex); + } + } + @Override + public String getLocalizedMessage() { + return Bundle.EXC_NotConnectedQuestion(execEnv.getDisplayName()); + } + }; } if (info.isPtyMode() && PtySupport.isSupportedFor(info.getExecutionEnvironment())) { diff -r 2ffb0b254787 dlight.nativeexecution/test/unit/src/org/netbeans/modules/nativeexecution/api/NativeProcessBuilderTest.java --- a/dlight.nativeexecution/test/unit/src/org/netbeans/modules/nativeexecution/api/NativeProcessBuilderTest.java Wed Sep 19 11:32:54 2012 +0200 +++ b/dlight.nativeexecution/test/unit/src/org/netbeans/modules/nativeexecution/api/NativeProcessBuilderTest.java Wed Sep 19 16:09:20 2012 +0200 @@ -65,6 +65,7 @@ import org.netbeans.modules.nativeexecution.test.NativeExecutionBaseTestSuite; import org.openide.util.Exceptions; import org.openide.util.RequestProcessor; +import org.openide.util.UserQuestionException; public class NativeProcessBuilderTest extends NativeExecutionBaseTestCase { @@ -259,6 +260,27 @@ public void testSetCommandLine() throws Exception { doTestSetCommandLine(getTestExecutionEnvironment()); } + + public void testAsksForconnection() { + ExecutionEnvironment ee = ExecutionEnvironmentFactory.createNew("never", "existed.com"); + NativeProcessBuilder b = NativeProcessBuilder.newProcessBuilder(ee); + b.setExecutable("ade"); + b.setArguments("lsviews"); + try { + b.call(); + fail("The previous call should thrown an exception"); + } catch (UserQuestionException ex) { + // OK, expected + assertEquals( + "Localized message as expected", + Bundle.EXC_NotConnectedQuestion(ee.getDisplayName()), + ex.getLocalizedMessage() + ); + assertEquals("No connection to never@existed.com", ex.getMessage()); + } catch (IOException ex) { + fail("we should not get IOException: " + ex); + } + } private void doTestSetCommandLine(ExecutionEnvironment execEnv) throws Exception { HostInfo hostinfo = HostInfoUtils.getHostInfo(execEnv); diff -r 2ffb0b254787 dlight.remote.impl/nbproject/project.properties --- a/dlight.remote.impl/nbproject/project.properties Wed Sep 19 11:32:54 2012 +0200 +++ b/dlight.remote.impl/nbproject/project.properties Wed Sep 19 16:09:20 2012 +0200 @@ -1,7 +1,7 @@ is.autoload=true javac.source=1.6 javac.compilerargs=-Xlint -Xlint:-serial -spec.version.base=1.14.0 +spec.version.base=1.15.0 test.config.stableBTD.includes=**/*Test.class test.config.stableBTD.excludes=**/RemoteFSTCKTest.class diff -r 2ffb0b254787 dlight.remote.impl/nbproject/project.xml --- a/dlight.remote.impl/nbproject/project.xml Wed Sep 19 11:32:54 2012 +0200 +++ b/dlight.remote.impl/nbproject/project.xml Wed Sep 19 16:09:20 2012 +0200 @@ -44,7 +44,7 @@ - 1.9.4 + 1.15 diff -r 2ffb0b254787 dlight.remote/nbproject/project.properties --- a/dlight.remote/nbproject/project.properties Wed Sep 19 11:32:54 2012 +0200 +++ b/dlight.remote/nbproject/project.properties Wed Sep 19 16:09:20 2012 +0200 @@ -1,5 +1,5 @@ is.autoload=true javac.source=1.6 javac.compilerargs=-Xlint -Xlint:-serial -spec.version.base=1.14.0 +spec.version.base=1.15.0 diff -r 2ffb0b254787 extexecution/apichanges.xml --- a/extexecution/apichanges.xml Wed Sep 19 11:32:54 2012 +0200 +++ b/extexecution/apichanges.xml Wed Sep 19 16:09:20 2012 +0200 @@ -117,6 +117,22 @@ + + Advice to throw UserQuestionException + + + + + + Providers of ProcessBuilderImplementation are + advised to throw UserQuestionException in case + they need some interaction with user. + + + + + + SPI to allow to split the API and implementation diff -r 2ffb0b254787 extexecution/manifest.mf --- a/extexecution/manifest.mf Wed Sep 19 11:32:54 2012 +0200 +++ b/extexecution/manifest.mf Wed Sep 19 16:09:20 2012 +0200 @@ -2,6 +2,6 @@ AutoUpdate-Show-In-Client: false OpenIDE-Module: org.netbeans.modules.extexecution/2 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/extexecution/resources/Bundle.properties -OpenIDE-Module-Specification-Version: 1.33 +OpenIDE-Module-Specification-Version: 1.34 OpenIDE-Module-Recommends: org.netbeans.spi.extexecution.open.OptionOpenHandler, org.netbeans.spi.extexecution.open.FileOpenHandler, org.netbeans.spi.extexecution.open.HttpOpenHandler diff -r 2ffb0b254787 extexecution/src/org/netbeans/api/extexecution/ProcessBuilder.java --- a/extexecution/src/org/netbeans/api/extexecution/ProcessBuilder.java Wed Sep 19 11:32:54 2012 +0200 +++ b/extexecution/src/org/netbeans/api/extexecution/ProcessBuilder.java Wed Sep 19 16:09:20 2012 +0200 @@ -54,6 +54,7 @@ import org.netbeans.spi.extexecution.ProcessBuilderImplementation; import org.openide.util.NbBundle; import org.openide.util.Parameters; +import org.openide.util.UserQuestionException; /** * Abstraction of process builders. You can freely configure the parameters @@ -228,6 +229,12 @@ *

* Actual behavior depends on the builder implementation, but it should * respect all the properties configured on this builder. + *

+ * Since version 1.34 implementors of this method are advised to throw + * a {@link UserQuestionException} in case the execution cannot be + * performed and requires additional user confirmation, or configuration. + * Callers of this method may check for this exception and handle it + * appropriately. * * @see ProcessBuilderImplementation * @return the new {@link Process} based on the properties configured @@ -235,6 +242,8 @@ * @throws IOException if the process could not be created * @throws IllegalStateException if there is no executable configured * by {@link #setExecutable(java.lang.String)} + * @throws UserQuestionException if the execution cannot be performed + * without permission from the user */ @NonNull @Override diff -r 2ffb0b254787 extexecution/src/org/netbeans/spi/extexecution/ProcessBuilderImplementation.java --- a/extexecution/src/org/netbeans/spi/extexecution/ProcessBuilderImplementation.java Wed Sep 19 11:32:54 2012 +0200 +++ b/extexecution/src/org/netbeans/spi/extexecution/ProcessBuilderImplementation.java Wed Sep 19 16:09:20 2012 +0200 @@ -46,6 +46,7 @@ import java.util.Map; import org.netbeans.api.annotations.common.NonNull; import org.netbeans.api.annotations.common.NullAllowed; +import org.openide.util.UserQuestionException; /** * The interface representing the implementation @@ -80,6 +81,10 @@ * @return a process created with specified parameters and environment * configuration * @throws IOException IOException if the process could not be created + * @throws UserQuestionException in case there is a need to interact with + * user, don't be afraid to throw a subclass of + * {@link UserQuestionException} with overriden {@link UserQuestionException#confirmed()} + * method. */ @NonNull Process createProcess(@NonNull String executable, @NullAllowed String workingDirectory, @NonNull List arguments, diff -r 2ffb0b254787 remotefs.versioning/nbproject/project.xml --- a/remotefs.versioning/nbproject/project.xml Wed Sep 19 11:32:54 2012 +0200 +++ b/remotefs.versioning/nbproject/project.xml Wed Sep 19 16:09:20 2012 +0200 @@ -19,7 +19,7 @@ 2 - 1.28 + 1.34