本文整理汇总了Java中org.eclipse.core.net.proxy.IProxyService.isProxiesEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java IProxyService.isProxiesEnabled方法的具体用法?Java IProxyService.isProxiesEnabled怎么用?Java IProxyService.isProxiesEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.core.net.proxy.IProxyService
的用法示例。
在下文中一共展示了IProxyService.isProxiesEnabled方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: proxySettings
import org.eclipse.core.net.proxy.IProxyService; //导入方法依赖的package包/类
/**
* This will return a list of arguments for proxy settings (if we have any, otherwise an empty list).
*
* @param env
* The environment map. Passed in so we can flag passwords to obfuscate (in other words, we may modify
* the map)
*/
private List<String> proxySettings(Map<String, String> env)
{
IProxyService service = JSCorePlugin.getDefault().getProxyService();
if (service == null || !service.isProxiesEnabled())
{
return Collections.emptyList();
}
List<String> proxyArgs = new ArrayList<String>(4);
IProxyData httpData = service.getProxyData(IProxyData.HTTP_PROXY_TYPE);
if (httpData != null && httpData.getHost() != null)
{
CollectionsUtil.addToList(proxyArgs, "--proxy", buildProxyURL(httpData, env)); //$NON-NLS-1$
}
IProxyData httpsData = service.getProxyData(IProxyData.HTTPS_PROXY_TYPE);
if (httpsData != null && httpsData.getHost() != null)
{
CollectionsUtil.addToList(proxyArgs, "--https-proxy", buildProxyURL(httpsData, env)); //$NON-NLS-1$
}
return proxyArgs;
}
示例2: run
import org.eclipse.core.net.proxy.IProxyService; //导入方法依赖的package包/类
public void run() throws CoreException {
IProxyService proxyService = getProxyService();
originalSystemProxiesEnabled = proxyService.isSystemProxiesEnabled();
originalProxiesEnabled = proxyService.isProxiesEnabled();
originalData = proxyService.getProxyData();
try {
// set new proxy
proxyService.setSystemProxiesEnabled(false);
proxyService.setProxiesEnabled(enableProxies);
IProxyData[] data = proxyService.getProxyData();
IProxyData matchedData = null;
for (IProxyData singleData : data) {
if (singleData.getType().equals(proxyDataType)) {
matchedData = singleData;
break;
}
}
if (matchedData == null) {
throw new CoreException(CloudFoundryPlugin.getErrorStatus("No matched proxy data type found for: "
+ proxyDataType));
}
matchedData.setHost(host);
matchedData.setPort(port);
proxyService.setProxyData(data);
handleProxyChange();
}
finally {
// restore proxy settings
proxyService.setSystemProxiesEnabled(originalSystemProxiesEnabled);
proxyService.setProxiesEnabled(originalProxiesEnabled);
proxyService.setProxyData(originalData);
}
}
示例3: getProxyData
import org.eclipse.core.net.proxy.IProxyService; //导入方法依赖的package包/类
private IProxyData getProxyData(URI uri) {
IProxyService proxyService = getProxyService();
if (proxyService != null && proxyService.isProxiesEnabled()) {
if (!proxyService.isSystemProxiesEnabled()) {
IProxyData[] proxies = proxyService.select(uri);
if (proxies.length > 0) {
return proxies[0];
}
}
}
return null;
}
示例4: getProxy
import org.eclipse.core.net.proxy.IProxyService; //导入方法依赖的package包/类
public static HttpProxyConfiguration getProxy(URL url) {
// URL must be set and have a valid protocol in order to determine
// which proxy to use
if (url == null || url.getProtocol() == null) {
return null;
}
// In certain cases, the activator would have stopped and the plugin may
// no longer be available. Usually onl happens on shutdown.
DockerFoundryPlugin plugin = DockerFoundryPlugin.getDefault();
if (plugin != null) {
IProxyService proxyService = plugin.getProxyService();
// Only set proxies IF proxies are enabled (i.e a user has selected
// MANUAL provider configuration in network preferences. If it is
// direct,
// then skip proxy settings.
if (proxyService != null && proxyService.isProxiesEnabled()) {
IProxyData[] existingProxies = proxyService.getProxyData();
if (existingProxies != null) {
// Now determine the protocol to obtain the correct proxy
// type
String normalisedURLProtocol = getNormalisedProtocol(url.getProtocol());
// Resolve the correct proxy data type based on the URL
// protocol
String[] proxyDataTypes = { IProxyData.HTTP_PROXY_TYPE, IProxyData.HTTPS_PROXY_TYPE,
IProxyData.SOCKS_PROXY_TYPE };
String matchedProxyData = null;
for (String proxyDataType : proxyDataTypes) {
String normalised = getNormalisedProtocol(proxyDataType);
if (normalised.equals(normalisedURLProtocol)) {
matchedProxyData = proxyDataType;
break;
}
}
if (matchedProxyData != null) {
for (IProxyData data : existingProxies) {
if (matchedProxyData.equals(data.getType())) {
int proxyPort = data.getPort();
String proxyHost = data.getHost();
String user = data.getUserId();
String password = data.getPassword();
return proxyHost != null ? new HttpProxyConfiguration(proxyHost, proxyPort,
data.isRequiresAuthentication(), user, password) : null;
}
}
}
}
}
}
return null;
}
示例5: isProxiesEnabled
import org.eclipse.core.net.proxy.IProxyService; //导入方法依赖的package包/类
private boolean isProxiesEnabled() {
IProxyService proxyService = getProxyService();
if (proxyService != null && proxyService.isProxiesEnabled())
return true;
return false;
}