Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 36408 Details for
Bug 102654
(PatchAttached) Proxy support for pserver connections
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
proxy support for pserver
cvs.core-ui.patch (text/plain), 32.03 KB, created by
Atsuhiko Yamanaka
on 2006-03-16 09:29:04 EST
(
hide
)
Description:
proxy support for pserver
Filename:
MIME Type:
Creator:
Atsuhiko Yamanaka
Created:
2006-03-16 09:29:04 EST
Size:
32.03 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.team.cvs.core >Index: src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java,v >retrieving revision 1.104 >diff -u -r1.104 CVSProviderPlugin.java >--- src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java 1 Nov 2005 18:05:37 -0000 1.104 >+++ src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java 16 Mar 2006 10:19:40 -0000 >@@ -11,8 +11,9 @@ > package org.eclipse.team.internal.ccvs.core; > > import java.io.*; >-import java.util.ArrayList; >-import java.util.List; >+import java.net.MalformedURLException; >+import java.net.URL; >+import java.util.*; > > import org.eclipse.core.resources.*; > import org.eclipse.core.runtime.*; >@@ -105,7 +106,33 @@ > private boolean crash; > > private boolean autoShareOnImport; >+ private boolean useProxy; > >+ public static final String PROXY_TYPE_HTTP = "HTTP"; //$NON-NLS-1$ >+ public static final String PROXY_TYPE_SOCKS5 = "SOCKS5"; //$NON-NLS-1$ >+ public static final String HTTP_DEFAULT_PORT = "80"; //$NON-NLS-1$ >+ public static final String SOCKS5_DEFAULT_PORT = "1080"; //$NON-NLS-1$ >+ >+ private String proxyType; >+ private String proxyHost; >+ private String proxyPort; >+ private boolean useProxyAuth; >+ >+ private static final String INFO_PROXY_USER = "org.eclipse.team.cvs.core.proxy.user"; //$NON-NLS-1$ >+ private static final String INFO_PROXY_PASS = "org.eclipse.team.cvs.core.proxy.pass"; //$NON-NLS-1$ >+ >+ private static final URL FAKE_URL; >+ static { >+ URL temp = null; >+ try { >+ temp = new URL("http://org.eclipse.team.cvs.proxy.auth");//$NON-NLS-1$ >+ } catch (MalformedURLException e) { >+ // Should never fail >+ } >+ FAKE_URL = temp; >+ } >+ >+ > public synchronized CVSWorkspaceSubscriber getCVSWorkspaceSubscriber() { > if (cvsWorkspaceSubscriber == null) { > cvsWorkspaceSubscriber = new CVSWorkspaceSubscriber( >@@ -598,4 +625,82 @@ > public boolean isWatchOnEdit() { > return getPluginPreferences().getBoolean(CVSProviderPlugin.ENABLE_WATCH_ON_EDIT); > } >+ >+ // proxy configuration >+ >+ public void setUseProxy(boolean useProxy) { >+ this.useProxy = useProxy; >+ } >+ >+ public boolean isUseProxy() { >+ return this.useProxy; >+ } >+ >+ public void setProxyType(String proxyType) { >+ this.proxyType = proxyType; >+ } >+ >+ public String getProxyType() { >+ return this.proxyType; >+ } >+ >+ public void setProxyHost(String proxyHost) { >+ this.proxyHost = proxyHost; >+ } >+ >+ public String getProxyHost() { >+ return this.proxyHost; >+ } >+ >+ public void setProxyPort(String proxyPort) { >+ this.proxyPort = proxyPort; >+ } >+ >+ public String getProxyPort() { >+ return this.proxyPort; >+ } >+ >+ public void setUseProxyAuth(boolean useProxyAuth) { >+ this.useProxyAuth = useProxyAuth; >+ } >+ >+ public boolean isUseProxyAuth() { >+ return this.useProxyAuth; >+ } >+ >+ public String getProxyUser() { >+ Object user = getAuthInfo().get(INFO_PROXY_USER); >+ return user==null ? "" : (String) user; //$NON-NLS-1$ >+ } >+ >+ public String getProxyPassword() { >+ Object pass = getAuthInfo().get(INFO_PROXY_PASS); >+ return pass==null ? "" : (String) pass; //$NON-NLS-1$ >+ } >+ >+ private Map getAuthInfo() { >+ // Retrieve username and password from keyring. >+ Map authInfo = Platform.getAuthorizationInfo(FAKE_URL, "proxy", ""); //$NON-NLS-1$ //$NON-NLS-2$ >+ return authInfo!=null ? authInfo : Collections.EMPTY_MAP; >+ } >+ >+ public void setProxyAuth(String proxyUser, String proxyPass) { >+ Map authInfo = getAuthInfo(); >+ if (authInfo.size()==0) { >+ authInfo = new java.util.HashMap(4); >+ } >+ if (proxyUser != null) { >+ authInfo.put(INFO_PROXY_USER, proxyUser); >+ } >+ if (proxyPass != null) { >+ authInfo.put(INFO_PROXY_PASS, proxyPass); >+ } >+ try { >+ Platform.addAuthorizationInfo(FAKE_URL, "proxy", "", authInfo); //$NON-NLS-1$ //$NON-NLS-2$ >+ } catch (CoreException e) { >+ // We should probably wrap the CoreException here! >+ CVSProviderPlugin.log(e); >+ } >+ } >+ > } >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.cvs.core/META-INF/MANIFEST.MF,v >retrieving revision 1.11 >diff -u -r1.11 MANIFEST.MF >--- META-INF/MANIFEST.MF 8 Mar 2006 19:49:44 -0000 1.11 >+++ META-INF/MANIFEST.MF 16 Mar 2006 10:19:40 -0000 >@@ -19,5 +19,6 @@ > Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.1.0,4.0.0)", > org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)", > org.eclipse.team.core;bundle-version="[3.2.0,4.0.0)", >- org.eclipse.core.filesystem;bundle-version="[1.0.0,2.0.0)" >+ org.eclipse.core.filesystem;bundle-version="[1.0.0,2.0.0)", >+ com.jcraft.jsch;bundle-version="[0.1.25,2.0.0)" > Eclipse-LazyStart: true >Index: src/org/eclipse/team/internal/ccvs/core/connection/PServerConnection.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/PServerConnection.java,v >retrieving revision 1.19 >diff -u -r1.19 PServerConnection.java >--- src/org/eclipse/team/internal/ccvs/core/connection/PServerConnection.java 4 Aug 2005 20:24:44 -0000 1.19 >+++ src/org/eclipse/team/internal/ccvs/core/connection/PServerConnection.java 16 Mar 2006 10:19:40 -0000 >@@ -9,17 +9,21 @@ > * IBM Corporation - initial API and implementation > *******************************************************************************/ > package org.eclipse.team.internal.ccvs.core.connection; >- > > import java.io.*; >-import java.net.Socket; >+import java.net.*; > >-import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.*; > import org.eclipse.osgi.util.NLS; > import org.eclipse.team.internal.ccvs.core.*; >+import org.eclipse.team.internal.ccvs.core.connection.CVSAuthenticationException; >+import org.eclipse.team.internal.ccvs.core.connection.Connection; > import org.eclipse.team.internal.ccvs.core.util.Util; > import org.eclipse.team.internal.core.streams.*; > >+import com.jcraft.jsch.*; >+import com.jcraft.jsch.Proxy; >+ > /** > * A connection used to talk to an cvs pserver. > */ >@@ -97,13 +101,38 @@ > monitor.subTask(CVSMessages.PServerConnection_authenticating); > monitor.worked(1); > >- fSocket = createSocket(monitor); >+ InputStream is = null; >+ OutputStream os = null; >+ >+ Proxy proxy = getProxy(); >+ if (proxy!=null) { >+ String host = cvsroot.getHost(); >+ int port = cvsroot.getPort(); >+ if (port == ICVSRepositoryLocation.USE_DEFAULT_PORT) { >+ port = DEFAULT_PORT; >+ } >+ try { >+ int timeout = CVSProviderPlugin.getPlugin().getTimeout() * 1000; >+ proxy.connect(new ResponsiveSocketFacory(monitor), host, port, timeout); >+ } catch( Exception ex) { >+ ex.printStackTrace(); >+ throw new IOException(ex.getMessage()); >+ } >+ is = proxy.getInputStream(); >+ os = proxy.getOutputStream(); >+ >+ } else { >+ fSocket = createSocket(monitor); >+ is = fSocket.getInputStream(); >+ os = fSocket.getOutputStream(); >+ } >+ > boolean connected = false; > try { >- this.inputStream = new BufferedInputStream(new PollingInputStream(fSocket.getInputStream(), >+ this.inputStream = new BufferedInputStream(new PollingInputStream(is, > cvsroot.getTimeout(), monitor)); > this.outputStream = new PollingOutputStream(new TimeoutOutputStream( >- fSocket.getOutputStream(), 8192 /*bufferSize*/, 1000 /*writeTimeout*/, 1000 /*closeTimeout*/), >+ os, 8192 /*bufferSize*/, 1000 /*writeTimeout*/, 1000 /*closeTimeout*/), > cvsroot.getTimeout(), monitor); > authenticate(); > connected = true; >@@ -112,7 +141,34 @@ > } > } > >- /** >+ private Proxy getProxy() { >+ CVSProviderPlugin plugin = CVSProviderPlugin.getPlugin(); >+ boolean useProxy = plugin.isUseProxy(); >+ Proxy proxy = null; >+ if (useProxy) { >+ String type = plugin.getProxyType(); >+ String host = plugin.getProxyHost(); >+ String port = plugin.getProxyPort(); >+ >+ boolean useAuth = plugin.isUseProxyAuth(); >+ >+ String proxyhost = host + ":" + port; //$NON-NLS-1$ >+ if (type.equals(CVSProviderPlugin.PROXY_TYPE_HTTP)) { >+ proxy = new ProxyHTTP(proxyhost); >+ if (useAuth) { >+ ((ProxyHTTP) proxy).setUserPasswd(plugin.getProxyUser(), plugin.getProxyPassword()); >+ } >+ } else if (type.equals(CVSProviderPlugin.PROXY_TYPE_SOCKS5)) { >+ proxy = new ProxySOCKS5(proxyhost); >+ if (useAuth) { >+ ((ProxySOCKS5) proxy).setUserPasswd(plugin.getProxyUser(), plugin.getProxyPassword()); >+ } >+ } >+ } >+ return proxy; >+ } >+ >+ /** > * @see Connection#getInputStream() > */ > public InputStream getInputStream() { >@@ -169,13 +225,22 @@ > // Accumulate a message from the error (E) stream > String message = "";//$NON-NLS-1$ > String separator = ""; //$NON-NLS-1$ >- while (line.length() > 0 && line.charAt(0) == ERROR_CHAR) { >- if (line.length() > 2) { >- message += separator + line.substring(2); >- separator = " "; //$NON-NLS-1$ >- } >- line = Connection.readLine(cvsroot, getInputStream()); >- } >+ >+ if(!CVSProviderPlugin.getPlugin().isUseProxy()) { >+ while (line.length() > 0 && line.charAt(0) == ERROR_CHAR) { >+ if (line.length() > 2) { >+ message += separator + line.substring(2); >+ separator = " "; //$NON-NLS-1$ >+ } >+ line = Connection.readLine(cvsroot, getInputStream()); >+ } >+ } else { >+ while (line.length() > 0) { >+ message += separator + line; >+ separator = "\n"; //$NON-NLS-1$ >+ line = Connection.readLine(cvsroot, getInputStream()); >+ } >+ } > > // If the last line is the login failed (I HATE YOU) message, return authentication failure > if (LOGIN_FAILED.equals(line)) { >@@ -255,4 +320,43 @@ > private void throwInValidCharacter() throws CVSAuthenticationException { > throw new CVSAuthenticationException(CVSMessages.PServerConnection_invalidChars, CVSAuthenticationException.RETRY); > } >+ >+ >+ public static class SimpleSocketFactory implements SocketFactory { >+ InputStream in = null; >+ OutputStream out = null; >+ public Socket createSocket(String host, int port) throws IOException, UnknownHostException { >+ Socket socket = null; >+ socket = new Socket(host, port); >+ return socket; >+ } >+ public InputStream getInputStream(Socket socket) throws IOException { >+ if (in == null) >+ in = socket.getInputStream(); >+ return in; >+ } >+ public OutputStream getOutputStream(Socket socket) throws IOException { >+ if (out == null) >+ out = socket.getOutputStream(); >+ return out; >+ } >+ } >+ >+ public static class ResponsiveSocketFacory extends SimpleSocketFactory { >+ private IProgressMonitor monitor; >+ public ResponsiveSocketFacory(IProgressMonitor monitor) { >+ this.monitor = monitor; >+ } >+ public Socket createSocket(String host, int port) throws IOException, UnknownHostException { >+ Socket socket = null; >+ socket = Util.createSocket(host, port, monitor); >+ // Null out the monitor so we don't hold onto anything >+ // (i.e. the SSH2 session will keep a handle to the socket factory around >+ monitor = new NullProgressMonitor(); >+ // Set the socket timeout >+ socket.setSoTimeout(CVSProviderPlugin.getPlugin().getTimeout() * 1000); >+ return socket; >+ } >+ } >+ > } >#P org.eclipse.team.cvs.ui >Index: src/org/eclipse/team/internal/ccvs/ui/IHelpContextIds.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IHelpContextIds.java,v >retrieving revision 1.52 >diff -u -r1.52 IHelpContextIds.java >--- src/org/eclipse/team/internal/ccvs/ui/IHelpContextIds.java 3 Jun 2005 15:41:17 -0000 1.52 >+++ src/org/eclipse/team/internal/ccvs/ui/IHelpContextIds.java 16 Mar 2006 10:19:44 -0000 >@@ -105,6 +105,7 @@ > public static final String WATCH_EDIT_PREFERENCE_PAGE = PREFIX + "watch_edit_preference_page_context"; //$NON-NLS-1$ > public static final String PASSWORD_MANAGEMENT_PAGE = PREFIX + "password_management_preference_page_context"; //$NON-NLS-1$ > public static final String COMPARE_PREFERENCE_PAGE = PREFIX + "cvs_compare_preference_page_context"; //$NON-NLS-1$ >+ public static final String PROXY_PREFERENCE_PAGE = PREFIX + "proxy_preference_page_context"; //$NON-NLS-1$ > > // Views > public static final String CONSOLE_VIEW = PREFIX + "console_view_context"; //$NON-NLS-1$ >@@ -156,4 +157,5 @@ > public static final String PROJECT_PROPERTY_PAGE = PREFIX + "project_property_page_context"; //$NON-NLS-1$ > public static final String FOLDER_PROPERTY_PAGE = PREFIX + "folder_property_page_context"; //$NON-NLS-1$ > public static final String FILE_PROPERTY_PAGE = PREFIX + "file_property_page_context"; //$NON-NLS-1$ >+ > } >Index: src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java,v >retrieving revision 1.33 >diff -u -r1.33 CVSUIMessages.java >--- src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java 14 Mar 2006 04:46:55 -0000 1.33 >+++ src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java 16 Mar 2006 10:19:43 -0000 >@@ -1074,5 +1074,14 @@ > public static String CVSHistoryPage_Previous; > public static String CVSHistoryPage_NoRevisionsForMode; > public static String CVSHistoryPage_NoFilter; >+ >+ public static String CVSProxyPreferencePage_enableProxy; >+ public static String CVSProxyPreferencePage_proxyTpe; >+ public static String CVSProxyPreferencePage_proxyHost; >+ public static String CVSProxyPreferencePage_proxyPort; >+ public static String CVSProxyPreferencePage_enableProxyAuth; >+ public static String CVSProxyPreferencePage_proxyUser; >+ public static String CVSProxyPreferencePage_proxyPass; >+ public static String CVSProxyPreferencePage_proxyPortError; > > } >Index: src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java,v >retrieving revision 1.103 >diff -u -r1.103 ICVSUIConstants.java >--- src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java 14 Mar 2006 14:33:23 -0000 1.103 >+++ src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java 16 Mar 2006 10:19:44 -0000 >@@ -170,6 +170,12 @@ > > public final String PREF_ENABLE_MODEL_SYNC = "enableModelSync"; //$NON-NLS-1$ > >+ public final String PREF_USE_PROXY = "proxyEnabled"; //$NON-NLS-1$ >+ public final String PREF_PROXY_TYPE = "proxyType"; //$NON-NLS-1$ >+ public final String PREF_PROXY_HOST = "proxyHost"; //$NON-NLS-1$ >+ public final String PREF_PROXY_PORT = "proxyPort"; //$NON-NLS-1$ >+ public final String PREF_PROXY_AUTH = "proxyAuth"; //$NON-NLS-1$ >+ > // Wizard banners > public final String IMG_WIZBAN_SHARE = "wizban/newconnect_wizban.png"; //$NON-NLS-1$ > public final String IMG_WIZBAN_MERGE = "wizban/mergestream_wizban.png"; //$NON-NLS-1$ >Index: src/org/eclipse/team/internal/ccvs/ui/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties,v >retrieving revision 1.466 >diff -u -r1.466 messages.properties >--- src/org/eclipse/team/internal/ccvs/ui/messages.properties 14 Mar 2006 04:46:55 -0000 1.466 >+++ src/org/eclipse/team/internal/ccvs/ui/messages.properties 16 Mar 2006 10:19:44 -0000 >@@ -226,6 +226,14 @@ > CVSPreferencesPage_45=Use .project &project name instead of module name on check out > CVSPropertiesPage_virtualModule=<no corresponding remote folder> > >+CVSProxyPreferencePage_enableProxy=&Enable proxy connection >+CVSProxyPreferencePage_proxyTpe=Proxy &type: >+CVSProxyPreferencePage_proxyHost=Proxy host add&ress: >+CVSProxyPreferencePage_proxyPort=Proxy host p&ort: >+CVSProxyPreferencePage_enableProxyAuth=E&nable proxy authentication >+CVSProxyPreferencePage_proxyUser=Proxy &user name: >+CVSProxyPreferencePage_proxyPass=Proxy pa&ssword: >+CVSProxyPreferencePage_proxyPortError=Port must be a number between 0 and 65535. > > CVSRemoteFilePropertySource_name=Name > CVSRemoteFilePropertySource_revision=Revision >Index: src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java,v >retrieving revision 1.186 >diff -u -r1.186 CVSUIPlugin.java >--- src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java 14 Mar 2006 14:33:23 -0000 1.186 >+++ src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java 16 Mar 2006 10:19:44 -0000 >@@ -600,6 +600,19 @@ > CVSProviderPlugin.getPlugin().setDetermineVersionEnabled(store.getBoolean(ICVSUIConstants.PREF_DETERMINE_SERVER_VERSION)); > CVSProviderPlugin.getPlugin().setDebugProtocol(CVSProviderPlugin.getPlugin().isDebugProtocol() || store.getBoolean(ICVSUIConstants.PREF_DEBUG_PROTOCOL)); > CVSProviderPlugin.getPlugin().setAutoshareOnImport(store.getBoolean(ICVSUIConstants.PREF_AUTO_SHARE_ON_IMPORT)); >+ >+ // proxy configuration >+ store.setDefault(ICVSUIConstants.PREF_USE_PROXY, false); >+ store.setDefault(ICVSUIConstants.PREF_PROXY_TYPE, CVSProviderPlugin.PROXY_TYPE_HTTP); >+ store.setDefault(ICVSUIConstants.PREF_PROXY_HOST, ""); //$NON-NLS-1$ >+ store.setDefault(ICVSUIConstants.PREF_PROXY_PORT, CVSProviderPlugin.HTTP_DEFAULT_PORT); >+ store.setDefault(ICVSUIConstants.PREF_PROXY_AUTH, false); >+ >+ CVSProviderPlugin.getPlugin().setUseProxy(store.getBoolean(ICVSUIConstants.PREF_USE_PROXY)); >+ CVSProviderPlugin.getPlugin().setProxyType(store.getString(ICVSUIConstants.PREF_PROXY_TYPE)); >+ CVSProviderPlugin.getPlugin().setProxyHost(store.getString(ICVSUIConstants.PREF_PROXY_HOST)); >+ CVSProviderPlugin.getPlugin().setProxyPort(store.getString(ICVSUIConstants.PREF_PROXY_PORT)); >+ CVSProviderPlugin.getPlugin().setUseProxyAuth(store.getBoolean(ICVSUIConstants.PREF_PROXY_AUTH)); > } > > /** >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.cvs.ui/plugin.xml,v >retrieving revision 1.244 >diff -u -r1.244 plugin.xml >--- plugin.xml 14 Mar 2006 14:33:23 -0000 1.244 >+++ plugin.xml 16 Mar 2006 10:19:43 -0000 >@@ -895,6 +895,19 @@ > <keywordReference id="org.eclipse.team.cvs.ui.cvs"/> > </page> > </extension> >+ >+ <extension >+ point="org.eclipse.ui.preferencePages"> >+ <page >+ name="%ProxyPreferencePage.name" >+ category="org.eclipse.team.cvs.ui.CVSPreferences" >+ class="org.eclipse.team.internal.ccvs.ui.ProxyPreferencePage" >+ id="org.eclipse.team.cvs.ui.ProxyPreferencesPreferences"> >+ <keywordReference id="org.eclipse.team.cvs.ui.cvs.proxy"/> >+ </page> >+ </extension> >+ >+ > <!-- **************** Decorator ******************* --> > <extension > point="org.eclipse.ui.decorators"> >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.cvs.ui/plugin.properties,v >retrieving revision 1.145 >diff -u -r1.145 plugin.properties >--- plugin.properties 7 Mar 2006 21:11:31 -0000 1.145 >+++ plugin.properties 16 Mar 2006 10:19:42 -0000 >@@ -34,6 +34,7 @@ > ConsolePreferencePage.name=Console > DecoratorPreferencePage.name=Label Decorations > ExtMethodPreferencePage.name=Ext Connection Method >+ProxyPreferencePage.name=Proxy Settings > WatchEditPreferencePage.name=Watch/Edit > ComparePreferencePage.name=Synchronize/Compare > UpdateMergePreferencePage.name=Update/Merge >Index: src/org/eclipse/team/internal/ccvs/ui/ProxyPreferencePage.java >=================================================================== >RCS file: src/org/eclipse/team/internal/ccvs/ui/ProxyPreferencePage.java >diff -N src/org/eclipse/team/internal/ccvs/ui/ProxyPreferencePage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/internal/ccvs/ui/ProxyPreferencePage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,279 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.team.internal.ccvs.ui; >+ >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.jface.preference.PreferencePage; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.*; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; >+import org.eclipse.ui.*; >+ >+public class ProxyPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { >+ >+ private Label proxyTypeLabel; >+ private Label proxyHostLabel; >+ private Label proxyPortLabel; >+ private Label proxyUserLabel; >+ private Label proxyPassLabel; >+ >+ private Button enableProxy; >+ private Combo proxyTypeCombo; >+ private Text proxyHostText; >+ private Text proxyPortText; >+ private Button enableAuth; >+ private Text proxyUserText; >+ private Text proxyPassText; >+ >+ /* >+ * @see PreferencePage#createContents(Composite) >+ */ >+ protected Control createContents(Composite parent) { >+ Composite composite = new Composite(parent, SWT.NULL); >+ GridLayout layout = new GridLayout(); >+ layout.marginWidth = 0; >+ layout.marginHeight = 0; >+ layout.numColumns = 2; >+ composite.setLayout(layout); >+ composite.setLayoutData(new GridData()); >+ >+ GridData data = new GridData(); >+ data.horizontalAlignment = GridData.FILL; >+ composite.setLayoutData(data); >+ >+ createProxyPage(composite); >+ >+ initializeDefaults(); >+ PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.PROXY_PREFERENCE_PAGE); >+ Dialog.applyDialogFont(parent); >+ return composite; >+ } >+ >+ >+ private void initializeDefaults() { >+ IPreferenceStore store = getPreferenceStore(); >+ >+ enableProxy.setSelection(store.getBoolean(ICVSUIConstants.PREF_USE_PROXY)); >+ >+ proxyTypeCombo.select(store.getString(ICVSUIConstants.PREF_PROXY_TYPE).equals(CVSProviderPlugin.PROXY_TYPE_HTTP)? 0:1); >+ proxyHostText.setText(store.getString(ICVSUIConstants.PREF_PROXY_HOST)); >+ proxyPortText.setText(store.getString(ICVSUIConstants.PREF_PROXY_PORT)); >+ >+ enableAuth.setSelection(store.getBoolean(ICVSUIConstants.PREF_PROXY_AUTH)); >+ proxyUserText.setText(CVSProviderPlugin.getPlugin().getProxyUser()); >+ proxyPassText.setText(CVSProviderPlugin.getPlugin().getProxyPassword()); >+ >+ // FIXME >+ updateControls(); >+ } >+ >+ /* >+ * @see IWorkbenchPreferencePage#init(IWorkbench) >+ */ >+ public void init(IWorkbench workbench) { >+ } >+ >+ /* >+ * @see IPreferencePage#performOk() >+ */ >+ public boolean performOk() { >+ IPreferenceStore store = getPreferenceStore(); >+ >+ store.setValue(ICVSUIConstants.PREF_USE_PROXY, enableProxy.getSelection()); >+ >+ store.setValue(ICVSUIConstants.PREF_PROXY_TYPE, proxyTypeCombo.getText()); >+ store.setValue(ICVSUIConstants.PREF_PROXY_HOST, proxyHostText.getText()); >+ store.setValue(ICVSUIConstants.PREF_PROXY_PORT, proxyPortText.getText()); >+ >+ store.setValue(ICVSUIConstants.PREF_PROXY_AUTH, enableAuth.getSelection()); >+ >+ CVSProviderPlugin plugin = CVSProviderPlugin.getPlugin(); >+ >+ plugin.setUseProxy(enableProxy.getSelection()); >+ >+ plugin.setProxyType(proxyTypeCombo.getText()); >+ plugin.setProxyHost(proxyHostText.getText()); >+ plugin.setProxyPort(proxyPortText.getText()); >+ >+ plugin.setUseProxyAuth(enableAuth.getSelection()); >+ plugin.setProxyAuth(proxyUserText.getText(), proxyPassText.getText()); >+ >+ CVSUIPlugin.getPlugin().savePluginPreferences(); >+ return super.performOk(); >+ } >+ >+ /* >+ * @see PreferencePage#performDefaults() >+ */ >+ protected void performDefaults() { >+ super.performDefaults(); >+ IPreferenceStore store = getPreferenceStore(); >+ store.setToDefault(ICVSUIConstants.PREF_USE_PROXY); >+ store.setToDefault(ICVSUIConstants.PREF_PROXY_TYPE); >+ store.setToDefault(ICVSUIConstants.PREF_PROXY_HOST); >+ store.setToDefault(ICVSUIConstants.PREF_PROXY_PORT); >+ store.setToDefault(ICVSUIConstants.PREF_PROXY_AUTH); >+ CVSProviderPlugin.getPlugin().setProxyAuth("",""); //$NON-NLS-1$ //$NON-NLS-2$ >+ >+ initializeDefaults(); >+ } >+ >+ >+ /* >+ * @see PreferencePage#doGetPreferenceStore() >+ */ >+ protected IPreferenceStore doGetPreferenceStore() { >+ return CVSUIPlugin.getPlugin().getPreferenceStore(); >+ } >+ >+ private void createProxyPage(Composite group) { >+ >+ enableProxy = new Button(group, SWT.CHECK); >+ enableProxy.setText(CVSUIMessages.CVSProxyPreferencePage_enableProxy); >+ GridData gd = new GridData(); >+ gd.horizontalSpan = 2; >+ enableProxy.setLayoutData(gd); >+ enableProxy.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ updateControls(); >+ } >+ }); >+ >+ proxyTypeLabel = new Label(group, SWT.NONE); >+ proxyTypeLabel.setText(CVSUIMessages.CVSProxyPreferencePage_proxyTpe); >+ >+ proxyTypeCombo = new Combo(group, SWT.READ_ONLY); >+ proxyTypeCombo.setFont(group.getFont()); >+ gd = new GridData(GridData.FILL_HORIZONTAL); >+ gd.horizontalSpan = 1; >+ proxyTypeCombo.setLayoutData(gd); >+ proxyTypeCombo.add(CVSProviderPlugin.PROXY_TYPE_HTTP); >+ proxyTypeCombo.add(CVSProviderPlugin.PROXY_TYPE_SOCKS5); >+ proxyTypeCombo.select(0); >+ proxyTypeCombo.addModifyListener(new ModifyListener() { >+ public void modifyText(ModifyEvent e) { >+ if(proxyPortText == null) >+ return; >+ Combo combo = (Combo) (e.getSource()); >+ String foo = combo.getText(); >+ if(foo.equals(CVSProviderPlugin.PROXY_TYPE_HTTP)) { >+ proxyPortText.setText(CVSProviderPlugin.HTTP_DEFAULT_PORT); >+ } else if(foo.equals(CVSProviderPlugin.PROXY_TYPE_SOCKS5)) { >+ proxyPortText.setText(CVSProviderPlugin.SOCKS5_DEFAULT_PORT); >+ } >+ } >+ }); >+ >+ proxyHostLabel = new Label(group, SWT.NONE); >+ proxyHostLabel.setText(CVSUIMessages.CVSProxyPreferencePage_proxyHost); >+ >+ proxyHostText = new Text(group, SWT.SINGLE | SWT.BORDER); >+ proxyHostText.setFont(group.getFont()); >+ gd = new GridData(GridData.FILL_HORIZONTAL); >+ gd.horizontalSpan = 1; >+ proxyHostText.setLayoutData(gd); >+ >+ proxyPortLabel = new Label(group, SWT.NONE); >+ proxyPortLabel.setText(CVSUIMessages.CVSProxyPreferencePage_proxyPort); >+ >+ proxyPortText = new Text(group, SWT.SINGLE | SWT.BORDER); >+ proxyPortText.setFont(group.getFont()); >+ gd = new GridData(GridData.FILL_HORIZONTAL); >+ gd.horizontalSpan = 1; >+ proxyPortText.setLayoutData(gd); >+ >+ proxyPortText.addModifyListener(new ModifyListener() { >+ public void modifyText(ModifyEvent e) { >+ if(isValidPort(proxyPortText.getText())) { >+ setErrorMessage(null); >+ } >+ } >+ }); >+ >+ createSpacer(group, 2); >+ >+ enableAuth = new Button(group, SWT.CHECK); >+ enableAuth.setText(CVSUIMessages.CVSProxyPreferencePage_enableProxyAuth); >+ gd = new GridData(); >+ gd.horizontalSpan = 2; >+ enableAuth.setLayoutData(gd); >+ enableAuth.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ updateControls(); >+ } >+ }); >+ >+ proxyUserLabel = new Label(group, SWT.NONE); >+ proxyUserLabel.setText(CVSUIMessages.CVSProxyPreferencePage_proxyUser); >+ >+ proxyUserText = new Text(group, SWT.SINGLE | SWT.BORDER); >+ proxyUserText.setFont(group.getFont()); >+ gd = new GridData(GridData.FILL_HORIZONTAL); >+ gd.horizontalSpan = 1; >+ proxyUserText.setLayoutData(gd); >+ >+ proxyPassLabel = new Label(group, SWT.NONE); >+ proxyPassLabel.setText(CVSUIMessages.CVSProxyPreferencePage_proxyPass); >+ >+ proxyPassText = new Text(group, SWT.SINGLE | SWT.BORDER); >+ proxyPassText.setEchoChar('*'); >+ proxyPassText.setFont(group.getFont()); >+ gd = new GridData(GridData.FILL_HORIZONTAL); >+ gd.horizontalSpan = 1; >+ proxyPassText.setLayoutData(gd); >+ >+ // performDefaults(); >+ } >+ >+ private boolean isValidPort(String port){ >+ int i = -1; >+ try { >+ i = Integer.parseInt(port); >+ } catch (NumberFormatException ee) { >+// setErrorMessage(Policy.bind("CVSSSH2PreferencePage.103")); //$NON-NLS-1$ >+// return false; >+ } >+ if(i < 0 || i > 65535){ >+ setErrorMessage(CVSUIMessages.CVSProxyPreferencePage_proxyPortError); >+ return false; >+ } >+ return true; >+ } >+ >+ protected void createSpacer(Composite composite, int columnSpan) { >+ Label label = new Label(composite, SWT.NONE); >+ GridData gd = new GridData(); >+ gd.horizontalSpan = columnSpan; >+ label.setLayoutData(gd); >+ } >+ >+ private void updateControls() { >+ boolean enable = enableProxy.getSelection(); >+ proxyTypeLabel.setEnabled(enable); >+ proxyTypeCombo.setEnabled(enable); >+ proxyPortLabel.setEnabled(enable); >+ proxyPortText.setEnabled(enable); >+ proxyHostLabel.setEnabled(enable); >+ proxyHostText.setEnabled(enable); >+ >+ enableAuth.setEnabled(enable); >+ enable&=enableAuth.getSelection(); >+ proxyUserLabel.setEnabled(enable); >+ proxyUserText.setEnabled(enable); >+ proxyPassLabel.setEnabled(enable); >+ proxyPassText.setEnabled(enable); >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 102654
:
28843
|
29375
|
36040
|
36346
| 36408 |
36410
|
36422
|
37225