diff -r c7881f2e2e05 groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/plugins/GrailsPluginsManager.java --- a/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/plugins/GrailsPluginsManager.java Fri Aug 01 14:50:09 2008 +0200 +++ b/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/plugins/GrailsPluginsManager.java Mon Aug 04 11:38:12 2008 +0200 @@ -45,7 +45,6 @@ import java.io.File; import java.io.InputStream; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -55,6 +54,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; +import java.util.prefs.Preferences; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.zip.ZipEntry; @@ -77,6 +77,7 @@ import org.openide.util.Exceptions; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; +import org.openide.util.NbPreferences; import org.openide.xml.XMLUtil; import org.w3c.dom.Document; import org.w3c.dom.Node; @@ -88,6 +89,16 @@ */ public class GrailsPluginsManager { + private static final String HTTP_PROXY_HOST = "http.proxyHost"; //NOI18N + private static final String HTTP_PROXY_PORT = "http.proxyPort"; //NOI18N + private static final String HTTP_PROXY_USER = "http.proxyUser"; //NOI18N + private static final String HTTP_PROXY_PASSWORD = "http.proxyPassword"; //NOI18N + private static final String NB_USE_PROXY_AUTHENTICATION = "useProxyAuthentication"; // NOI18N + private static final String NB_HTTP_PROXY_HOST = "proxyHttpHost"; //NOI18N + private static final String NB_HTTP_PROXY_PORT = "proxyHttpPort"; //NOI18N + private static final String NB_PROXY_USERNAME = "proxyAuthenticationUsername"; // NOI18N + private static final String NB_PROXY_PASSWORD = "proxyAuthenticationPassword"; // NOI18N + private final GrailsProject project; private GrailsPluginsManager(GrailsProject project) { @@ -103,9 +114,10 @@ final ProjectInformation inf = project.getLookup().lookup(ProjectInformation.class); final String displayName = inf.getDisplayName() + " (" + command + ")"; // NOI18N - + + loadHttpProxyProperties(); final Callable callable = ExecutionSupport.getInstance().createSimpleCommand( - command, GrailsProjectConfig.forProject(project)); + command, GrailsProjectConfig.forProject(project)); final PluginProcessor processor = new PluginProcessor(); ExecutionDescriptor descriptor = new ExecutionDescriptor().frontWindow(true); @@ -113,7 +125,7 @@ public InputProcessor newInputProcessor() { return InputProcessors.bridge(processor); } - }); + }); ExecutionService service = ExecutionService.newService(callable, descriptor, displayName); try { @@ -194,6 +206,7 @@ } }); + loadHttpProxyProperties(); Callable runner = getInstallPluginCallable(plugin, buttons[1], dlg); final Future result = executor.submit(runner); @@ -224,7 +237,7 @@ String[] args = plugin.getPath() == null ? new String[] {plugin.getName(), plugin.getVersion()} : new String[] {plugin.getPath()}; - + Callable callable = ExecutionSupport.getInstance().createSimpleCommand( command, GrailsProjectConfig.forProject(project), args); ExecutionDescriptor descriptor = new ExecutionDescriptor().frontWindow(true) @@ -323,6 +336,28 @@ } return plugin; } + + //WARN: This method overrides the default System proxy properties. + private void loadHttpProxyProperties() { + Preferences prefs = NbPreferences.root().node("org/netbeans/core"); // NOI18N + + final String host = prefs.get(NB_HTTP_PROXY_HOST, System.getProperty(HTTP_PROXY_HOST)); + if (host == null) { + return; + } + System.setProperty(HTTP_PROXY_HOST, host); + + final String port = prefs.get(NB_HTTP_PROXY_PORT, System.getProperty(HTTP_PROXY_PORT)); + if (port != null) { + System.setProperty(HTTP_PROXY_PORT, port); + } + + final boolean useAuth = prefs.getBoolean(NB_USE_PROXY_AUTHENTICATION, false); + if (useAuth) { + System.setProperty(HTTP_PROXY_USER, prefs.get(NB_PROXY_USERNAME, "")); + System.setProperty(HTTP_PROXY_PASSWORD, prefs.get(NB_PROXY_PASSWORD, "")); + } + } private GrailsPlugin getPluginFromInputStream(InputStream inputStream, String path) throws Exception { final Document doc = XMLUtil.parse(new InputSource(inputStream), false, false, null, null); @@ -340,7 +375,7 @@ } return new GrailsPlugin(name, version, description, path); } - + private static class PluginProcessor implements LineProcessor { private final List plugins = Collections.synchronizedList(new ArrayList());