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 118360 Details for
Bug 228739
[Proxy] add UI support to see what the automatically detected proxy settings are
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]
Patch_v02
228739_v02.txt (text/plain), 87.35 KB, created by
Pawel Pogorzelski
on 2008-11-20 08:50:22 EST
(
hide
)
Description:
Patch_v02
Filename:
MIME Type:
Creator:
Pawel Pogorzelski
Created:
2008-11-20 08:50:22 EST
Size:
87.35 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.core.net >Index: src/org/eclipse/core/internal/net/ProxyType.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyType.java,v >retrieving revision 1.13 >diff -u -r1.13 ProxyType.java >--- src/org/eclipse/core/internal/net/ProxyType.java 29 Sep 2008 11:10:30 -0000 1.13 >+++ src/org/eclipse/core/internal/net/ProxyType.java 20 Nov 2008 13:43:10 -0000 >@@ -11,6 +11,7 @@ > package org.eclipse.core.internal.net; > > import java.io.IOException; >+import java.util.ArrayList; > import java.util.Properties; > > import org.eclipse.core.net.proxy.IProxyData; >@@ -98,7 +99,14 @@ > } > > public static String[] convertPropertyStringToHosts(String property) { >- return property.split("\\|"); //$NON-NLS-1$ >+ String hosts[] = property.split("\\|"); //$NON-NLS-1$ >+ ArrayList ret = new ArrayList(); >+ for (int i = 0; i < hosts.length; i++) { >+ if (hosts[i].length() != 0) { >+ ret.add(hosts[i]); >+ } >+ } >+ return (String[]) ret.toArray(new String[0]); > } > > public ProxyType(String name) { >Index: src/org/eclipse/core/internal/net/ProxyData.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyData.java,v >retrieving revision 1.6 >diff -u -r1.6 ProxyData.java >--- src/org/eclipse/core/internal/net/ProxyData.java 18 Nov 2008 15:16:53 -0000 1.6 >+++ src/org/eclipse/core/internal/net/ProxyData.java 20 Nov 2008 13:43:10 -0000 >@@ -55,6 +55,10 @@ > public String getUserId() { > return user; > } >+ >+ public void setType(String type) { >+ this.type = type; >+ } > > public void setHost(String host) { > if (host.length() == 0) >Index: src/org/eclipse/core/internal/net/ProxySelector.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxySelector.java,v >retrieving revision 1.1 >diff -u -r1.1 ProxySelector.java >--- src/org/eclipse/core/internal/net/ProxySelector.java 18 Nov 2008 15:16:53 -0000 1.1 >+++ src/org/eclipse/core/internal/net/ProxySelector.java 20 Nov 2008 13:43:10 -0000 >@@ -51,8 +51,9 @@ > } else if (provider.equals(NATIVE_PROVIDER)) { > service.setProxiesEnabled(true); > service.setSystemProxiesEnabled(true); >+ } else { >+ throw new IllegalArgumentException("Provider not supported"); //$NON-NLS-1$ > } >- throw new IllegalArgumentException("Provider not supported"); //$NON-NLS-1$ > } > > public static IProxyData[] getProxyData(String provider) { >#P org.eclipse.ui.net >Index: src/org/eclipse/ui/internal/net/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/messages.properties,v >retrieving revision 1.6 >diff -u -r1.6 messages.properties >--- src/org/eclipse/ui/internal/net/messages.properties 3 Sep 2008 09:37:54 -0000 1.6 >+++ src/org/eclipse/ui/internal/net/messages.properties 20 Nov 2008 13:43:15 -0000 >@@ -15,39 +15,45 @@ > # > # Messages in InternetPreferencePage > # >-BUTTON_PREFERENCE_ADD=Add &Host... >-BUTTON_PREFERENCE_EDIT=Ed&it... >-BUTTON_PREFERENCE_REMOVE=&Remove >-TITLE_PREFERENCE_HOSTS_DIALOG=Non Proxy host names >-LABEL_PREFERENCE_HOSTS_DIALOG=Enter host names separated by a vertical bar, space, or comma. >+ProxyPreferencePage_0=Active Provider: >+ProxyPreferencePage_1=Proxy entries >+ProxyPreferencePage_2=Schema >+ProxyPreferencePage_3=Host >+ProxyPreferencePage_4=Port >+ProxyPreferencePage_5=Provider >+ProxyPreferencePage_6=Auth >+ProxyPreferencePage_7=User >+ProxyPreferencePage_8=Password >+ProxyPreferencePage_9=Add &Entry... >+ProxyPreferencePage_10=Ed&it... >+ProxyPreferencePage_11=&Clear >+ProxyPreferencePage_12=Proxy bypass >+ProxyPreferencePage_13=Host >+ProxyPreferencePage_14=Provider >+ProxyPreferencePage_15=Add &Host... >+ProxyPreferencePage_16=Edi&t... >+ProxyPreferencePage_17=Re&move >+ProxyPreferencePage_18=Dynamic >+ >+ProxyEntryDialog_0=New Proxy Entry >+ProxyEntryDialog_1=Edit Proxy Entry >+ProxyEntryDialog_2=Schema: >+ProxyEntryDialog_3=Host: >+ProxyEntryDialog_4=Port: >+ProxyEntryDialog_5=Provider: >+ProxyEntryDialog_6=Requires Authentication: >+ProxyEntryDialog_7=User: >+ProxyEntryDialog_8=Password: >+ProxyEntryDialog_9=Setting for provided type is already defined >+ProxyEntryDialog_10=Invalid host name >+ProxyEntryDialog_11=Invalid port number >+ProxyEntryDialog_12=Invalid user ID >+ >+ProxyBypassDialog_0=Proxy bypass hosts >+ProxyBypassDialog_1=Enter host names separated by a semicolon or a space. >+ProxyBypassDialog_2=You can use the wildcard character * to specify a host name pattern and | to combine multiple patterns > >-ProxyPreferencePage_2=Proxy Preferences >-ProxyPreferencePage_3=Direct &connection to the Internet >-ProxyPreferencePage_4=&Manual proxy configuration: >-ProxyPreferencePage_5=&Use this proxy server for SSL >-ProxyPreferencePage_6=&No proxy for: >-ProxyPreferencePage_7=&Enable proxy authentication: >-ProxyPreferencePage_8=Us&er name: >-ProxyPreferencePage_9=&Password: >-ProxyPreferencePage_1=Specifies that no configuration is needed to access the Internet. >-ProxyPreferencePage_0=Specifies that a proxy server is required to access the Internet. >-ProxyPreferencePage_22=Port: >-ProxyPreferencePage_23=Specifies that the HTTP protocol settings should be used for the protocols below. >-ProxyPreferencePage_24=Specifies which hosts should not be routed via a proxy server. >-ProxyPreferencePage_25=Specifies that basic authentication is required. >-ProxyPreferencePage_26=Specifies the basic authentication user name. >-ProxyPreferencePage_27=Specifies the basic authentication password >-ProxyPreferencePage_37=&HTTP proxy: >-ProxyPreferencePage_38=&SSL proxy: >-ProxyPreferencePage_39=S&OCKS proxy: >-ProxyPreferencePage_40=The proxy service is not available >-ProxyPreferencePage_41=The host name cannot begin or end with a space character >-ProxyPreferencePage_42=Invalid port >-ProxyPreferencePage_43=The port must be an integer >-ProxyPreferencePage_44=System proxy configuration (if available) >-ProxyPreferencePage_45=Specifies that system proxy settings are used to access the Internet. If such settings can't be retrieved, no proxy should be used. > UserValidationDialog_0=Password Required > UserValidationDialog_1=Connect to: {0} > UserValidationDialog_2=&Password: > UserValidationDialog_3=&User name: >-NonProxyHostsComposite_0=You can use the wildcard character * to specify a host name pattern and | to combine multiple patterns >Index: src/org/eclipse/ui/internal/net/NetUIMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NetUIMessages.java,v >retrieving revision 1.5 >diff -u -r1.5 NetUIMessages.java >--- src/org/eclipse/ui/internal/net/NetUIMessages.java 14 Apr 2008 13:37:59 -0000 1.5 >+++ src/org/eclipse/ui/internal/net/NetUIMessages.java 20 Nov 2008 13:43:15 -0000 >@@ -17,83 +17,57 @@ > > public final class NetUIMessages extends NLS { > >- private static final String BUNDLE_NAME = "org.eclipse.ui.internal.net.messages";//$NON-NLS-1$ >+ private static final String BUNDLE_NAME = "org.eclipse.ui.internal.net.messages"; //$NON-NLS-1$ > > private NetUIMessages() { > // Do not instantiate > } > >- public static String BUTTON_PREFERENCE_ADD; >- >- public static String BUTTON_PREFERENCE_EDIT; >- >- public static String BUTTON_PREFERENCE_REMOVE; >- >- public static String NonProxyHostsComposite_0; >- > public static String ProxyPreferencePage_0; >- > public static String ProxyPreferencePage_1; >- > public static String ProxyPreferencePage_2; >- >- public static String ProxyPreferencePage_22; >- >- public static String ProxyPreferencePage_23; >- >- public static String ProxyPreferencePage_24; >- >- public static String ProxyPreferencePage_25; >- >- public static String ProxyPreferencePage_26; >- >- public static String ProxyPreferencePage_27; >- > public static String ProxyPreferencePage_3; >- >- public static String ProxyPreferencePage_37; >- >- public static String ProxyPreferencePage_38; >- >- public static String ProxyPreferencePage_39; >- > public static String ProxyPreferencePage_4; >- >- public static String ProxyPreferencePage_40; >- >- public static String ProxyPreferencePage_41; >- >- public static String ProxyPreferencePage_42; >- >- public static String ProxyPreferencePage_43; >- > public static String ProxyPreferencePage_5; >- > public static String ProxyPreferencePage_6; >- > public static String ProxyPreferencePage_7; >- > public static String ProxyPreferencePage_8; >- > public static String ProxyPreferencePage_9; >- >- public static String ProxyPreferencePage_44; >- >- public static String ProxyPreferencePage_45; >- >- public static String TITLE_PREFERENCE_HOSTS_DIALOG; >- >- public static String LABEL_PREFERENCE_HOSTS_DIALOG; >+ public static String ProxyPreferencePage_10; >+ public static String ProxyPreferencePage_11; >+ public static String ProxyPreferencePage_12; >+ public static String ProxyPreferencePage_13; >+ public static String ProxyPreferencePage_14; >+ public static String ProxyPreferencePage_15; >+ public static String ProxyPreferencePage_16; >+ public static String ProxyPreferencePage_17; >+ public static String ProxyPreferencePage_18; >+ >+ public static String ProxyEntryDialog_0; >+ public static String ProxyEntryDialog_1; >+ public static String ProxyEntryDialog_2; >+ public static String ProxyEntryDialog_3; >+ public static String ProxyEntryDialog_4; >+ public static String ProxyEntryDialog_5; >+ public static String ProxyEntryDialog_6; >+ public static String ProxyEntryDialog_7; >+ public static String ProxyEntryDialog_8; >+ public static String ProxyEntryDialog_9; >+ public static String ProxyEntryDialog_10; >+ public static String ProxyEntryDialog_11; >+ public static String ProxyEntryDialog_12; >+ >+ public static String ProxyBypassDialog_0; >+ public static String ProxyBypassDialog_1; >+ public static String ProxyBypassDialog_2; > > public static String UserValidationDialog_0; >- > public static String UserValidationDialog_1; >- > public static String UserValidationDialog_2; >- > public static String UserValidationDialog_3; > > static { > NLS.initializeMessages(BUNDLE_NAME, NetUIMessages.class); > } >+ > } >Index: src/org/eclipse/ui/internal/net/ProxyPreferencePage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/ProxyPreferencePage.java,v >retrieving revision 1.14 >diff -u -r1.14 ProxyPreferencePage.java >--- src/org/eclipse/ui/internal/net/ProxyPreferencePage.java 29 Sep 2008 11:10:27 -0000 1.14 >+++ src/org/eclipse/ui/internal/net/ProxyPreferencePage.java 20 Nov 2008 13:43:15 -0000 >@@ -18,23 +18,17 @@ > *******************************************************************************/ > package org.eclipse.ui.internal.net; > >-import org.eclipse.core.net.proxy.IProxyData; >-import org.eclipse.core.net.proxy.IProxyService; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.jface.dialogs.ErrorDialog; >+import org.eclipse.core.internal.net.ProxySelector; > import org.eclipse.jface.preference.PreferencePage; > import org.eclipse.swt.SWT; >-import org.eclipse.swt.events.ModifyEvent; >-import org.eclipse.swt.events.ModifyListener; > import org.eclipse.swt.events.SelectionAdapter; > import org.eclipse.swt.events.SelectionEvent; > import org.eclipse.swt.layout.GridData; > import org.eclipse.swt.layout.GridLayout; >-import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Combo; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Control; > import org.eclipse.swt.widgets.Label; >-import org.eclipse.swt.widgets.Text; > import org.eclipse.ui.IWorkbench; > import org.eclipse.ui.IWorkbenchPreferencePage; > import org.eclipse.ui.PlatformUI; >@@ -42,240 +36,73 @@ > public class ProxyPreferencePage extends PreferencePage implements > IWorkbenchPreferencePage { > >- private static final String PROXY_PREFERENCE_PAGE_CONTEXT_ID >- = "org.eclipse.ui.net.proxy_preference_page_context"; //$NON-NLS-1$ >- >- Entry[] entryList; >- Button directConnectionToButton; >- Button manualProxyConfigurationButton; >- Button useSameProxyButton; >- private Label nonHostLabel; >- private NonProxyHostsComposite nonHostComposite; >- Button enableProxyAuth; >- private Label useridLabel; >- private Label passwordLabel; >- Text userid; >- Text password; >- private IProxyService proxyService; >- Button systemProxyConfigurationButton; >- >- public ProxyPreferencePage() { >- super(NetUIMessages.ProxyPreferencePage_2); >- setPreferenceStore(Activator.getDefault().getPreferenceStore()); >- } >+ private static final String PROXY_PREFERENCE_PAGE_CONTEXT_ID = "org.eclipse.ui.net.proxy_preference_page_context"; //$NON-NLS-1$ > >- public void init(IWorkbench workbench) { >- // Nothing to do >- } >+ private Label providerLabel; >+ protected Combo providerCombo; >+ private ProxyEntriesComposite proxyEntriesComposite; >+ private NonProxyHostsComposite nonProxyHostsComposite; > > protected Control createContents(Composite parent) { >- >- proxyService = Activator.getDefault().getProxyService(); >- if (proxyService == null) { >- Label l = new Label(parent, SWT.NONE); >- l.setText(NetUIMessages.ProxyPreferencePage_40); >- return l; >- } >- >- IProxyData[] proxyData = proxyService.getProxyData(); >- entryList = new Entry[proxyData.length]; >- for (int i = 0; i < proxyData.length; i++) { >- IProxyData pd = proxyData[i]; >- entryList[i] = new Entry(pd); >- } >- > Composite composite = new Composite(parent, SWT.NONE); >- GridLayout layout = new GridLayout(); >- layout.numColumns = 1; >- layout.marginRight = 5; >- layout.marginTop = 5; >+ GridLayout layout = new GridLayout(1, false); > layout.marginWidth = 0; >+ layout.marginHeight = 0; > composite.setLayout(layout); >- GridData data = new GridData(GridData.FILL_BOTH); >- composite.setLayoutData(data); > >- systemProxyConfigurationButton = new Button(composite, SWT.RADIO); >- systemProxyConfigurationButton.setLayoutData(new GridData()); >- systemProxyConfigurationButton.setText(NetUIMessages.ProxyPreferencePage_44); >- systemProxyConfigurationButton >- .setToolTipText(NetUIMessages.ProxyPreferencePage_45); >- systemProxyConfigurationButton.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- if (systemProxyConfigurationButton.getSelection()) >- enableControls(false); >- } >- }); >+ createProviderComposite(composite); >+ createProxyEntriesComposite(composite); >+ createNonProxiedHostsComposite(composite); >+ >+ // Adding help accessible by F1 >+ PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), >+ PROXY_PREFERENCE_PAGE_CONTEXT_ID); > >- directConnectionToButton = new Button(composite, SWT.RADIO); >- directConnectionToButton.setLayoutData(new GridData()); >- directConnectionToButton.setText(NetUIMessages.ProxyPreferencePage_3); >- directConnectionToButton >- .setToolTipText(NetUIMessages.ProxyPreferencePage_1); >- directConnectionToButton.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- if (directConnectionToButton.getSelection()) >- enableControls(false); >- } >- }); >- >- manualProxyConfigurationButton = new Button(composite, SWT.RADIO); >- manualProxyConfigurationButton >- .setText(NetUIMessages.ProxyPreferencePage_4); >- manualProxyConfigurationButton >- .setToolTipText(NetUIMessages.ProxyPreferencePage_0); >- manualProxyConfigurationButton.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- if (manualProxyConfigurationButton.getSelection()) >- enableControls(true); >- } >- }); >+ initializeValues(); >+ return composite; >+ } > >- final Composite manualProxyConfigurationComposite = new Composite( >- composite, SWT.NONE); >- final GridLayout gridLayout = new GridLayout(); >- gridLayout.marginWidth = 0; >- gridLayout.marginHeight = 0; >- gridLayout.numColumns = 4; >- manualProxyConfigurationComposite.setLayout(gridLayout); >- final GridData gridData_2 = new GridData(GridData.FILL_BOTH); >- gridData_2.horizontalIndent = 17; >- manualProxyConfigurationComposite.setLayoutData(gridData_2); >- >- entryList[0].addProtocolEntry(manualProxyConfigurationComposite); >- >- new Label(manualProxyConfigurationComposite, SWT.NONE); >- useSameProxyButton = new Button(manualProxyConfigurationComposite, >- SWT.CHECK); >- useSameProxyButton.setText(NetUIMessages.ProxyPreferencePage_5); >- GridData gridData = new GridData(); >- gridData.horizontalSpan = 3; >- useSameProxyButton.setLayoutData(gridData); >- useSameProxyButton.setToolTipText(NetUIMessages.ProxyPreferencePage_23); >- useSameProxyButton.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- toggleUseSameProtocol(); >- } >- }); >+ private void createProviderComposite(Composite parent) { >+ Composite composite = new Composite(parent, SWT.NONE); >+ composite.setLayout(new GridLayout(2, false)); >+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); > >- for (int index = 1; index < entryList.length; index++) { >- entryList[index] >- .addProtocolEntry(manualProxyConfigurationComposite); >- } >- >- Label separator = new Label(manualProxyConfigurationComposite, >- SWT.HORIZONTAL | SWT.SEPARATOR); >- separator.setLayoutData(newGridData(4, 5, true, false)); >- nonHostLabel = new Label(manualProxyConfigurationComposite, SWT.NONE); >- nonHostLabel.setText(NetUIMessages.ProxyPreferencePage_6); >- nonHostLabel.setToolTipText(NetUIMessages.ProxyPreferencePage_24); >- nonHostLabel.setLayoutData(newGridData(4, 5, true, false)); >- nonHostComposite = new NonProxyHostsComposite( >- manualProxyConfigurationComposite, SWT.NONE); >- nonHostComposite.setLayoutData(newGridData(4, -1, true, true)); >- >- Label separator2 = new Label(manualProxyConfigurationComposite, >- SWT.HORIZONTAL | SWT.SEPARATOR); >- separator2.setLayoutData(newGridData(4, 5, true, false)); >- enableProxyAuth = new Button(manualProxyConfigurationComposite, >- SWT.CHECK); >- enableProxyAuth.setText(NetUIMessages.ProxyPreferencePage_7); >- enableProxyAuth.setLayoutData(newGridData(4, 5, true, false)); >- enableProxyAuth.setToolTipText(NetUIMessages.ProxyPreferencePage_25); >- enableProxyAuth.addSelectionListener(new SelectionAdapter() { >+ providerLabel = new Label(composite, SWT.NONE); >+ providerLabel.setText(NetUIMessages.ProxyPreferencePage_0); >+ providerCombo = new Combo(composite, SWT.READ_ONLY | SWT.DROP_DOWN); >+ providerCombo.addSelectionListener(new SelectionAdapter() { > public void widgetSelected(SelectionEvent e) { >- enableUseridPassword(enableProxyAuth.getSelection()); >+ setProvider(providerCombo.getText()); > } > }); >+ } > >- final Composite userIdPassword = new Composite( >- manualProxyConfigurationComposite, SWT.NONE); >- GridLayout layout2 = new GridLayout(2, false); >- layout2.marginWidth = 0; >- layout2.marginHeight = 0; >- userIdPassword.setLayoutData(newGridData(4, -1, true, false)); >- userIdPassword.setLayout(layout2); >- >- useridLabel = new Label(userIdPassword, SWT.NONE); >- useridLabel.setText(NetUIMessages.ProxyPreferencePage_8); >- userid = new Text(userIdPassword, SWT.BORDER); >- passwordLabel = new Label(userIdPassword, SWT.NONE); >- passwordLabel.setText(NetUIMessages.ProxyPreferencePage_9); >- password = new Text(userIdPassword, SWT.BORDER); >- >- userid.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >- userid.setToolTipText(NetUIMessages.ProxyPreferencePage_26); >- password.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >- password.setToolTipText(NetUIMessages.ProxyPreferencePage_27); >- password.setEchoChar('*'); >- >- ModifyListener modifyListener = new ModifyListener() { >- public void modifyText(ModifyEvent e) { >- if (useSameProxyButton.getSelection()) { >- for (int index = 1; index < entryList.length; index++) { >- entryList[index].copyValuesFrom(entryList[0]); >- } >- } >- } >- }; >- >- entryList[0].hostname.addModifyListener(modifyListener); >- entryList[0].port.addModifyListener(modifyListener); >+ private void createProxyEntriesComposite(Composite parent) { >+ proxyEntriesComposite = new ProxyEntriesComposite(parent, SWT.NONE); >+ proxyEntriesComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, >+ true, true)); >+ } > >- initializeValues(proxyService.isProxiesEnabled() , proxyService.isSystemProxiesEnabled()); >- applyDialogFont(composite); >- >- // F1 >- PlatformUI.getWorkbench().getHelpSystem().setHelp( >- getControl(), PROXY_PREFERENCE_PAGE_CONTEXT_ID); >+ private void createNonProxiedHostsComposite(Composite parent) { >+ nonProxyHostsComposite = new NonProxyHostsComposite(parent, SWT.NONE); >+ nonProxyHostsComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, >+ true, true)); >+ } > >- return composite; >+ public void init(IWorkbench workbench) { >+ // Nothing to do > } > > protected void performApply() { >- if (proxyService == null) >- return; >- boolean manualProxiesEnabled = manualProxyConfigurationButton.getSelection(); >- boolean systemProxiesEnabled = systemProxyConfigurationButton.getSelection(); >- >- // Save the contents of the text fields to the proxy data. >- IProxyData[] proxyData = new IProxyData[entryList.length]; >- for (int index = 0; index < entryList.length; index++) { >- entryList[index].applyValues(); >- proxyData[index] = entryList[index].getProxy(); >- } >- >- proxyService.setProxiesEnabled(manualProxiesEnabled || systemProxiesEnabled); >- >- if (manualProxiesEnabled) { >- try { >- proxyService.setNonProxiedHosts( >- nonHostComposite.getList()); >- proxyService.setProxyData(proxyData); >- } catch (CoreException e) { >- ErrorDialog.openError(getShell(), null, null, e.getStatus()); >- } >- } >- >- proxyService.setSystemProxiesEnabled(systemProxiesEnabled); >- >- Activator.getDefault().savePluginPreferences(); >+ int sel = providerCombo.getSelectionIndex(); >+ ProxySelector.setDefaultProvider(providerCombo.getItem(sel)); >+ proxyEntriesComposite.performApply(); >+ nonProxyHostsComposite.performApply(); > } > > protected void performDefaults() { >- directConnectionToButton.setSelection(false); >- systemProxyConfigurationButton.setSelection(true); >- manualProxyConfigurationButton.setSelection(false); >- useSameProxyButton.setSelection(false); >- enableProxyAuth.setSelection(false); >- >- for (int index = 0; index < entryList.length; index++) { >- entryList[index].reset(); >- } >- >- nonHostComposite.setList(new String[] { "localhost", "127.0.0.1" }); //$NON-NLS-1$ //$NON-NLS-2$ >- userid.setText(""); //$NON-NLS-1$ >- password.setText(""); //$NON-NLS-1$ >- enableControls(false); >+ providerCombo.select(1); >+ setProvider(providerCombo.getItem(1)); > } > > public boolean performOk() { >@@ -283,381 +110,15 @@ > return super.performOk(); > } > >- /** >- * This method is run once when when this preference page is displayed. It >- * will restore the state of this page using previously saved preferences. >- * >- * @param proxiesEnabled indicates if manual proxies are enabled or not. >- */ >- private void initializeValues(boolean proxiesEnabled, boolean systemProxiesEnabled) { >- directConnectionToButton.setSelection(!proxiesEnabled); >- manualProxyConfigurationButton.setSelection(proxiesEnabled && !systemProxiesEnabled); >- systemProxyConfigurationButton.setSelection(proxiesEnabled && systemProxiesEnabled); >- >- >- String[] nonHostLists = null; >- if (proxyService != null) >- nonHostLists = proxyService.getNonProxiedHosts(); >- this.nonHostComposite.setList(nonHostLists == null ? new String[] { >- "localhost", "127.0.0.1" } : nonHostLists); //$NON-NLS-1$ //$NON-NLS-2$ >- if (!proxiesEnabled || systemProxiesEnabled) { >- this.useSameProxyButton.setSelection(false); >- this.enableProxyAuth.setSelection(false); >- this.userid.setText(""); //$NON-NLS-1$ >- this.password.setText(""); //$NON-NLS-1$ >- } else { >- // use the first entry which does need authentication >- IProxyData data = null; >- for (int i = 0; i < entryList.length; i++) { >- IProxyData idata = entryList[i].getProxy(); >- if (idata.isRequiresAuthentication()) { >- data = idata; >- break; >- } >- } >- if (data == null) { >- // no entry needs authentication, just pick the first. >- data = entryList[0].getProxy(); >- } >- this.enableProxyAuth.setSelection(data.isRequiresAuthentication()); >- this.userid.setText(data.getUserId() == null ? "" : data //$NON-NLS-1$ >- .getUserId()); >- this.password.setText(data.getPassword() == null ? "" : data //$NON-NLS-1$ >- .getPassword()); >- >- } >- boolean useSameProtocol = true; >- for (int i = 1; i < entryList.length; i++) { >- Entry entry = entryList[i]; >- if (!entry.isUseSameProtocol(entryList[0])) { >- useSameProtocol = false; >- break; >- } >- } >- this.useSameProxyButton.setSelection(useSameProtocol); >- for (int index = 1; index < entryList.length; index++) { >- Entry entry = entryList[index]; >- entry.loadPreviousValues(); >- entry.updateEnablement(proxiesEnabled && !systemProxiesEnabled, useSameProtocol); >- } >- >- enableControls(proxiesEnabled && !systemProxiesEnabled); >- } >- >- void enableControls(boolean enabled) { >- for (int index = 0; index < entryList.length; index++) { >- entryList[index].updateEnablement(enabled, useSameProxyButton.getSelection()); >- } >- >- useSameProxyButton.setEnabled(enabled); >- nonHostLabel.setEnabled(enabled); >- nonHostComposite.setEnabled(enabled); >- enableProxyAuth.setEnabled(enabled); >- >- enableUseridPassword(enableProxyAuth.getSelection() && enabled); >+ private void initializeValues() { >+ providerCombo.setItems(ProxySelector.getProviders()); >+ providerCombo.select(providerCombo.indexOf(ProxySelector >+ .getDefaultProvider())); > } > >- void enableUseridPassword(boolean enabled) { >- useridLabel.setEnabled(enabled); >- userid.setEnabled(enabled); >- passwordLabel.setEnabled(enabled); >- password.setEnabled(enabled); >- } >- >- protected void toggleUseSameProtocol() { >- boolean useSameProtocol = useSameProxyButton.getSelection(); >- for (int index = 1; index < entryList.length; index++) { >- entryList[index].setUseSameProtocol(useSameProtocol, entryList[0]); >- } >- } >- >- public void updateErrorMessage() { >- for (int index = 0; index < entryList.length; index++) { >- String message = entryList[index].getErrorMessage(); >- if (message != null) { >- setErrorMessage(message); >- return; >- } >- } >- setErrorMessage(null); >+ protected void setProvider(String name) { >+ proxyEntriesComposite.setProvider(name); >+ nonProxyHostsComposite.setProvider(name); > } > >- private GridData newGridData(int span, int verticalIndent, >- boolean horizontal, boolean vertical) { >- int style = 0; >- >- style |= horizontal ? GridData.FILL_HORIZONTAL : 0; >- style |= vertical ? GridData.FILL_VERTICAL : 0; >- >- GridData gridData = new GridData(style); >- >- if (span != -1) { >- gridData.horizontalSpan = span; >- } >- >- if (verticalIndent != -1) { >- gridData.verticalIndent = verticalIndent; >- } >- >- return gridData; >- } >- >- private class Entry { >- Label nameLabel; >- Text hostname; >- Label portLabel; >- Text port; >- String prevHostname; >- int prevPort; >- private final IProxyData proxyData; >- private String errorMessage; >- >- public Entry(IProxyData proxyData) { >- this.proxyData = proxyData; >- } >- >- public void updateEnablement(boolean proxiesEnabled, boolean useSameProtocol) { >- if (isHttpProxy()) { >- setEnabled(proxiesEnabled); >- } else { >- if (proxiesEnabled) { >- setUseSameProtocol(useSameProtocol); >- } else { >- setEnabled(false); >- } >- } >- updateMessage(); >- } >- >- public void setUseSameProtocol(boolean useSameProtocol, Entry httpEntry) { >- setUseSameProtocol(useSameProtocol); >- if (isSocksProxy() || isHttpProxy()) >- return; >- if (useSameProtocol) { >- recordPreviousValues(); >- copyValuesFrom(entryList[0]); >- } else { >- restorePreviousValues(); >- } >- } >- >- public void setUseSameProtocol(boolean useSameProtocol) { >- if (isSocksProxy()) { >- setEnabled(true); >- } else { >- setEnabled(!useSameProtocol); >- } >- } >- >- public void loadPreviousValues() { >- IProxyData proxy = getProxy(); >- prevHostname = proxy.getHost(); >- prevPort = proxy.getPort(); >- } >- >- public void restorePreviousValues() { >- hostname.setText(prevHostname); >- port.setText(prevPort == -1 ? "" : String //$NON-NLS-1$ >- .valueOf(prevPort)); >- } >- >- public void recordPreviousValues() { >- prevHostname = hostname.getText(); >- try { >- prevPort = Integer.parseInt(port.getText()); >- } catch (NumberFormatException e) { >- prevPort = -1; >- } >- } >- >- /** >- * The user has chosen to use the same entry for all protocols >- * @param entry the entry (the http entry to be exact) >- */ >- public void copyValuesFrom(Entry entry) { >- // For SOCKS, don't use the general entry >- if (!isSocksProxy()){ >- hostname.setText( entry.hostname.getText() ); >- port.setText( entry.port.getText() ); >- } >- } >- >- public boolean isUseSameProtocol(Entry entry) { >- // Always answer true for the SOCKS proxy since we never disable >- if (isSocksProxy()) >- return true; >- return (hostsEqual(proxyData.getHost(), entry.getProxy().getHost()) >- && portsEqual(proxyData.getPort(), entry.getProxy().getPort())); >- } >- >- private boolean portsEqual(int port1, int port2) { >- return port1 == port2; >- } >- >- private boolean hostsEqual(String host1, String host2) { >- if (host1 == host2) >- // If there are no hosts, don't enable the use same hosts button >- return false; >- if (host1 == null || host2 == null) >- return false; >- return host1.equals(host2); >- } >- >- boolean isSocksProxy() { >- return getProxy().getType().equals(IProxyData.SOCKS_PROXY_TYPE); >- } >- >- boolean isHttpProxy() { >- return getProxy().getType().equals(IProxyData.HTTP_PROXY_TYPE); >- } >- >- boolean isHttpsProxy() { >- return getProxy().getType().equals(IProxyData.HTTPS_PROXY_TYPE); >- } >- >- public IProxyData getProxy() { >- return proxyData; >- } >- >- public boolean updateMessage() { >- if (hostname.isEnabled()) { >- if (isSocksProxy() || isHttpProxy()|| !useSameProxyButton.getSelection()) { >- String hostString = hostname.getText(); >- if (hostString.startsWith(" ") || hostString.endsWith(" ")) { //$NON-NLS-1$ //$NON-NLS-2$ >- setErrorMessage(NetUIMessages.ProxyPreferencePage_41); >- return false; >- } >- String portString = port.getText(); >- if (portString.length() > 0) { >- try { >- int port = Integer.valueOf(portString).intValue(); >- if (port < 0) { >- setErrorMessage(NetUIMessages.ProxyPreferencePage_42); >- return false; >- } >- } catch (NumberFormatException e) { >- setErrorMessage(NetUIMessages.ProxyPreferencePage_43); >- return false; >- } >- } >- } >- } >- setErrorMessage(null); >- return true; >- } >- >- private void setErrorMessage(String message) { >- errorMessage = message; >- updateErrorMessage(); >- } >- >- public void applyValues() { >- IProxyData proxy = getProxy(); >- boolean enableAuth = enableProxyAuth.getSelection(); >- >- String hostString; >- String portString; >- if (useSameProxyButton.getSelection() && !isSocksProxy()) { >- hostString = entryList[0].hostname.getText(); >- portString = entryList[0].port.getText(); >- } else { >- hostString = hostname.getText(); >- portString = port.getText(); >- } >- >- proxy.setHost(hostString); >- try { >- int port = Integer.valueOf(portString).intValue(); >- proxy.setPort(port); >- } catch (NumberFormatException e) { >- proxy.setPort(-1); >- } >- proxy.setUserid(enableAuth ? userid.getText() : null); >- proxy.setPassword(enableAuth ? password.getText() : null); >- proxy.setSource(null); >- } >- >- public void addProtocolEntry(Composite parent) { >- GridData gridData; >- IProxyData proxy = getProxy(); >- >- nameLabel = new Label(parent, SWT.NONE); >- nameLabel.setText(getLabel(proxy)); >- >- hostname = new Text(parent, SWT.BORDER); >- gridData = new GridData(GridData.FILL_HORIZONTAL); >- gridData.widthHint = 120; >- hostname.setLayoutData(gridData); >- hostname.setText(getHostName(proxy)); >- hostname.addModifyListener(new ModifyListener() { >- public void modifyText(ModifyEvent e) { >- Entry.this.updateMessage(); >- } >- }); >- >- portLabel = new Label(parent, SWT.NONE); >- portLabel.setText(NetUIMessages.ProxyPreferencePage_22); >- >- port = new Text(parent, SWT.BORDER); >- gridData = new GridData(); >- gridData.widthHint = 50; >- port.setLayoutData(gridData); >- port.setText(getPortString(proxy)); >- port.addModifyListener(new ModifyListener() { >- public void modifyText(ModifyEvent e) { >- Entry.this.updateMessage(); >- } >- }); >- } >- >- private String getLabel(IProxyData data) { >- if (data.getType().equals(IProxyData.HTTP_PROXY_TYPE)) { >- return NetUIMessages.ProxyPreferencePage_37; >- } >- if (data.getType().equals(IProxyData.HTTPS_PROXY_TYPE)) { >- return NetUIMessages.ProxyPreferencePage_38; >- } >- if (data.getType().equals(IProxyData.SOCKS_PROXY_TYPE)) { >- return NetUIMessages.ProxyPreferencePage_39; >- } >- return ""; //$NON-NLS-1$ >- } >- >- private String getPortString(IProxyData proxy) { >- int portInt = proxy.getPort(); >- String portString; >- if (portInt == -1) { >- portString = ""; //$NON-NLS-1$ >- } else { >- portString = String.valueOf(portInt); >- } >- return portString; >- } >- >- private String getHostName(IProxyData proxy) { >- String hostnameString = proxy.getHost(); >- if (hostnameString == null) { >- hostnameString = ""; //$NON-NLS-1$ >- } >- return hostnameString; >- } >- >- public void reset() { >- hostname.setText(""); //$NON-NLS-1$ >- port.setText(""); //$NON-NLS-1$ >- prevHostname = ""; //$NON-NLS-1$ >- prevPort = -1; >- } >- >- private void setEnabled(boolean enabled) { >- hostname.setEnabled(enabled); >- nameLabel.setEnabled(enabled); >- portLabel.setEnabled(enabled); >- port.setEnabled(enabled); >- } >- >- public String getErrorMessage() { >- return errorMessage; >- } >- } > } >Index: src/org/eclipse/ui/internal/net/NonProxyHostsContentProvider.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NonProxyHostsContentProvider.java,v >retrieving revision 1.1 >diff -u -r1.1 NonProxyHostsContentProvider.java >--- src/org/eclipse/ui/internal/net/NonProxyHostsContentProvider.java 26 Feb 2007 18:16:44 -0000 1.1 >+++ src/org/eclipse/ui/internal/net/NonProxyHostsContentProvider.java 20 Nov 2008 13:43:15 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 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 >@@ -7,11 +7,10 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >- * yyyymmdd bug Email and other contact information >+ * yyyymmdd bug Email and other contact information > * -------- -------- ----------------------------------------------------------- > * 20070201 154100 pmoogk@ca.ibm.com - Peter Moogk, Port internet code from WTP to Eclipse base. > *******************************************************************************/ >- > package org.eclipse.ui.internal.net; > > import java.util.Collection; >@@ -19,44 +18,23 @@ > import org.eclipse.jface.viewers.IStructuredContentProvider; > import org.eclipse.jface.viewers.Viewer; > >-/** >- * Monitor content provider. >- */ >-public class NonProxyHostsContentProvider implements IStructuredContentProvider >-{ >- /** >- * MonitorContentProvider constructor comment. >- */ >- public NonProxyHostsContentProvider() >- { >+public class NonProxyHostsContentProvider implements IStructuredContentProvider { >+ >+ public NonProxyHostsContentProvider() { > super(); > } > >- /* >- * Disposes of this content provider. >- */ >- public void dispose() >- { >- // do nothing >+ public void dispose() { >+ // Do nothing > } > >- /* >- * Returns the elements to display in the viewer >- * when its input is set to the given element. >- */ >- public Object[] getElements(Object inputElement) >- { >- Collection coll = (Collection)inputElement; >- >- return coll.toArray( new String[0] ); >+ public Object[] getElements(Object inputElement) { >+ Collection coll = (Collection) inputElement; >+ return coll.toArray(new ProxyBypassData[0]); > } > >- /* >- * Notifies this content provider that the given viewer's input >- * has been switched to a different element. >- */ >- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) >- { >- // do nothing >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ // Do nothing > } >+ > } >Index: src/org/eclipse/ui/internal/net/NonProxyHostsLabelProvider.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NonProxyHostsLabelProvider.java,v >retrieving revision 1.1 >diff -u -r1.1 NonProxyHostsLabelProvider.java >--- src/org/eclipse/ui/internal/net/NonProxyHostsLabelProvider.java 26 Feb 2007 18:16:44 -0000 1.1 >+++ src/org/eclipse/ui/internal/net/NonProxyHostsLabelProvider.java 20 Nov 2008 13:43:15 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 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 >@@ -11,107 +11,78 @@ > * -------- -------- ----------------------------------------------------------- > * 20070201 154100 pmoogk@ca.ibm.com - Peter Moogk, Port internet code from WTP to Eclipse base. > *******************************************************************************/ >- > package org.eclipse.ui.internal.net; > >-import org.eclipse.jface.viewers.ILabelProviderListener; >- >-import org.eclipse.swt.graphics.Image; >+import org.eclipse.core.internal.net.ProxySelector; >+import org.eclipse.jface.viewers.BaseLabelProvider; >+import org.eclipse.jface.viewers.IColorProvider; > import org.eclipse.jface.viewers.ITableLabelProvider; >+import org.eclipse.jface.viewers.TableViewer; >+import org.eclipse.jface.viewers.TableViewerColumn; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.graphics.Color; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.swt.widgets.TableColumn; >+ >+public class NonProxyHostsLabelProvider extends BaseLabelProvider implements >+ ITableLabelProvider, IColorProvider { > >-/** >- * Monitor table label provider. >- */ >-public class NonProxyHostsLabelProvider implements ITableLabelProvider >-{ >- /** >- * MonitorTableLabelProvider constructor comment. >- */ >- public NonProxyHostsLabelProvider() >- { >+ public NonProxyHostsLabelProvider() { > super(); > } > >- /** >- * Adds a listener to this label provider. >- * Has no effect if an identical listener is already registered. >- * <p> >- * Label provider listeners are informed about state changes >- * that affect the rendering of the viewer that uses this label provider. >- * </p> >- * >- * @param listener a label provider listener >- */ >- public void addListener(ILabelProviderListener listener) >- { >- // do nothing >- } >- >- /** >- * Disposes of this label provider. When a label provider is >- * attached to a viewer, the viewer will automatically call >- * this method when the viewer is being closed. When label providers >- * are used outside of the context of a viewer, it is the client's >- * responsibility to ensure that this method is called when the >- * provider is no longer needed. >- */ >- public void dispose() >- { >- // do nothing >- } >- >- /** >- * Returns the label image for the given column of the given element. >- * >- * @param element the object representing the entire row, or >- * <code>null</code> indicating that no input object is set >- * in the viewer >- * @param columnIndex the zero-based index of the column in which >- * the label appears >- */ >- public Image getColumnImage(Object element, int columnIndex) >- { >+ public Image getColumnImage(Object element, int columnIndex) { > return null; > } > >- /** >- * Returns the label text for the given column of the given element. >- * >- * @param element the object representing the entire row, or >- * <code>null</code> indicating that no input object is set >- * in the viewer >- * @param columnIndex the zero-based index of the column in which the label appears >- */ >- public String getColumnText(Object element, int columnIndex) >- { >- return (String)element; >- } >- >- /** >- * Returns whether the label would be affected >- * by a change to the given property of the given element. >- * This can be used to optimize a non-structural viewer update. >- * If the property mentioned in the update does not affect the label, >- * then the viewer need not update the label. >- * >- * @param element the element >- * @param property the property >- * @return <code>true</code> if the label would be affected, >- * and <code>false</code> if it would be unaffected >- */ >- public boolean isLabelProperty(Object element, String property) >- { >+ public String getColumnText(Object element, int columnIndex) { >+ if (element == null) { >+ return null; >+ } >+ ProxyBypassData data = (ProxyBypassData) element; >+ switch (columnIndex) { >+ case 0: >+ return null; >+ case 1: >+ return data.getHost(); >+ case 2: >+ return data.getSource(); >+ default: >+ return null; >+ } >+ } >+ >+ public boolean isLabelProperty(Object element, String property) { > return false; > } > >- /** >- * Removes a listener to this label provider. >- * Has no affect if an identical listener is not registered. >- * >- * @param listener a label provider listener >- */ >- public void removeListener(ILabelProviderListener listener) >- { >- // do nothing >+ public void createColumns(TableViewer viewer) { >+ String[] titles = { >+ "", //$NON-NLS-1$ >+ NetUIMessages.ProxyPreferencePage_13, >+ NetUIMessages.ProxyPreferencePage_14 }; >+ for (int i = 0; i < titles.length; i++) { >+ TableColumn column = new TableViewerColumn(viewer, SWT.NONE) >+ .getColumn(); >+ column.setText(titles[i]); >+ column.setResizable(true); >+ } >+ } >+ >+ public Color getBackground(Object element) { >+ if (element instanceof ProxyBypassData) { >+ String provider = ((ProxyBypassData) element).getSource(); >+ if (!ProxySelector.canSetBypassHosts(provider)) { >+ return Display.getCurrent().getSystemColor( >+ SWT.COLOR_INFO_BACKGROUND); >+ } >+ } >+ return null; >+ } >+ >+ public Color getForeground(Object element) { >+ return null; > } >+ > } >Index: src/org/eclipse/ui/internal/net/NonProxyHostsComposite.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NonProxyHostsComposite.java,v >retrieving revision 1.3 >diff -u -r1.3 NonProxyHostsComposite.java >--- src/org/eclipse/ui/internal/net/NonProxyHostsComposite.java 7 Sep 2007 15:19:09 -0000 1.3 >+++ src/org/eclipse/ui/internal/net/NonProxyHostsComposite.java 20 Nov 2008 13:43:15 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 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 >@@ -12,243 +12,310 @@ > * 20060217 127138 pmoogk@ca.ibm.com - Peter Moogk > * 20070201 154100 pmoogk@ca.ibm.com - Peter Moogk, Port internet code from WTP to Eclipse base. > *******************************************************************************/ >- > package org.eclipse.ui.internal.net; > >-import java.util.Arrays; >+import java.util.ArrayList; > import java.util.Iterator; >-import java.util.TreeSet; >+ >+import org.eclipse.core.internal.net.ProxySelector; > import org.eclipse.jface.dialogs.InputDialog; > import org.eclipse.jface.fieldassist.ControlDecoration; > import org.eclipse.jface.fieldassist.FieldDecorationRegistry; >-import org.eclipse.jface.viewers.*; >+import org.eclipse.jface.viewers.CheckStateChangedEvent; >+import org.eclipse.jface.viewers.CheckboxTableViewer; >+import org.eclipse.jface.viewers.ColumnPixelData; >+import org.eclipse.jface.viewers.ColumnWeightData; >+import org.eclipse.jface.viewers.DoubleClickEvent; >+import org.eclipse.jface.viewers.ICheckStateListener; >+import org.eclipse.jface.viewers.IDoubleClickListener; >+import org.eclipse.jface.viewers.ISelectionChangedListener; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.viewers.SelectionChangedEvent; >+import org.eclipse.jface.viewers.TableLayout; > import org.eclipse.jface.window.Window; > import org.eclipse.swt.SWT; > import org.eclipse.swt.events.SelectionAdapter; > import org.eclipse.swt.events.SelectionEvent; > import org.eclipse.swt.layout.GridData; > import org.eclipse.swt.layout.GridLayout; >-import org.eclipse.swt.widgets.*; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.Table; > > /** >- * This class is the Composite that consists of the controls for >- * "http.nonProxyHosts" and is used by InternetPreferencesPage. >+ * This class is the Composite that consists of controls for proxy bypass hosts >+ * and is used by ProxyPreferencesPage. > */ > public class NonProxyHostsComposite extends Composite { >- private Table table_; >- TableViewer tableViewer_; >- private TreeSet tableValues_; >- private Button add_; >- private Button edit_; >- private Button remove_; > >- public NonProxyHostsComposite(Composite parent, int style) { >+ private Label hostsLabel; >+ CheckboxTableViewer hostsViewer; >+ private Button addButton; >+ private Button editButton; >+ private Button removeButton; >+ >+ protected String currentProvider; >+ private ArrayList bypassHosts = new ArrayList(); >+ >+ NonProxyHostsComposite(Composite parent, int style) { > super(parent, style); > createWidgets(); > } > > protected void createWidgets() { >- GridLayout layout = new GridLayout(); >- layout.horizontalSpacing = 6; >- layout.verticalSpacing = 6; >- layout.marginWidth = 0; >- layout.marginHeight = 0; >- layout.numColumns = 2; >- setLayout(layout); >- >- table_ = new Table(this, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL >- | SWT.MULTI | SWT.FULL_SELECTION); >- GridData data = new GridData(GridData.FILL_BOTH >- | GridData.VERTICAL_ALIGN_FILL); >- >- table_.setLayoutData(data); >- table_.setHeaderVisible(false); >- table_.setLinesVisible(true); >- >- TableLayout tableLayout = new TableLayout(); >- >- new TableColumn(table_, SWT.NONE); >- ColumnWeightData colData = new ColumnWeightData(100, 60, false); >- tableLayout.addColumnData(colData); >+ setLayout(new GridLayout(2, false)); > >- table_.setLayout(tableLayout); >+ hostsLabel = new Label(this, SWT.NONE); >+ hostsLabel.setText(NetUIMessages.ProxyPreferencePage_12); >+ hostsLabel.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, >+ 2, 1)); >+ >+ Table hostsTable = new Table(this, SWT.BORDER | SWT.V_SCROLL >+ | SWT.H_SCROLL | SWT.MULTI | SWT.FULL_SELECTION | SWT.CHECK); >+ hostsTable.setHeaderVisible(true); >+ hostsTable.setLinesVisible(true); >+ hostsTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, >+ 1, 3)); >+ >+ hostsViewer = new CheckboxTableViewer(hostsTable); >+ NonProxyHostsLabelProvider labelProvider = new NonProxyHostsLabelProvider(); >+ NonProxyHostsContentProvider contentProvider = new NonProxyHostsContentProvider(); >+ labelProvider.createColumns(hostsViewer); >+ hostsViewer.setContentProvider(contentProvider); >+ hostsViewer.setLabelProvider(labelProvider); > >- tableViewer_ = new TableViewer(table_); >- tableViewer_.setContentProvider(new NonProxyHostsContentProvider()); >- tableViewer_.setLabelProvider(new NonProxyHostsLabelProvider()); >+ TableLayout tableLayout = new TableLayout(); >+ tableLayout.addColumnData(new ColumnPixelData(18)); >+ tableLayout.addColumnData(new ColumnWeightData(50, 50, true)); >+ tableLayout.addColumnData(new ColumnWeightData(50, 50, true)); >+ hostsTable.setLayout(tableLayout); >+ >+ addButton = createButton(NetUIMessages.ProxyPreferencePage_15); >+ editButton = createButton(NetUIMessages.ProxyPreferencePage_16); >+ removeButton = createButton(NetUIMessages.ProxyPreferencePage_17); > >- tableViewer_ >+ hostsViewer > .addSelectionChangedListener(new ISelectionChangedListener() { > public void selectionChanged(SelectionChangedEvent event) { > enableButtons(); > } > }); >- >- tableViewer_.addDoubleClickListener(new IDoubleClickListener() { >+ hostsViewer.addCheckStateListener(new ICheckStateListener() { >+ public void checkStateChanged(CheckStateChangedEvent event) { >+ setProvider(currentProvider); >+ } >+ }); >+ hostsViewer.addDoubleClickListener(new IDoubleClickListener() { > public void doubleClick(DoubleClickEvent event) { > editSelection(); > } > }); >- >- Composite buttonComp = new Composite(this, SWT.NONE); >- layout = new GridLayout(); >- layout.horizontalSpacing = 0; >- layout.verticalSpacing = 8; >- layout.marginWidth = 0; >- layout.marginHeight = 0; >- layout.numColumns = 1; >- buttonComp.setLayout(layout); >- data = new GridData(GridData.HORIZONTAL_ALIGN_END >- | GridData.VERTICAL_ALIGN_FILL); >- buttonComp.setLayoutData(data); >- >- add_ = createButton(buttonComp, NetUIMessages.BUTTON_PREFERENCE_ADD); >- >- add_.addSelectionListener(new SelectionAdapter() { >+ addButton.addSelectionListener(new SelectionAdapter() { > public void widgetSelected(SelectionEvent e) { > addHost(); > } > }); >- >- edit_ = createButton(buttonComp, NetUIMessages.BUTTON_PREFERENCE_EDIT); >- >- edit_.addSelectionListener(new SelectionAdapter() { >+ editButton.addSelectionListener(new SelectionAdapter() { > public void widgetSelected(SelectionEvent e) { > editSelection(); > } > }); >- edit_.setEnabled(false); >- >- remove_ = createButton(buttonComp, >- NetUIMessages.BUTTON_PREFERENCE_REMOVE); >- >- remove_.addSelectionListener(new SelectionAdapter() { >+ removeButton.addSelectionListener(new SelectionAdapter() { > public void widgetSelected(SelectionEvent e) { >- removeFromList((IStructuredSelection) tableViewer_ >- .getSelection()); >- tableViewer_.refresh(); >+ removeSelection(); > } > }); >- remove_.setEnabled(false); >- } > >- private Button createButton(Composite comp, String label) { >- Button button = new Button(comp, SWT.PUSH); >- button.setText(label); >- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL >- | GridData.VERTICAL_ALIGN_BEGINNING); >- button.setLayoutData(data); >- return button; >+ initializeValues(); >+ enableButtons(); > } > >- /* (non-Javadoc) >- * @see org.eclipse.swt.widgets.Control#setEnabled(boolean) >- */ > public void setEnabled(boolean enabled) { > super.setEnabled(enabled); >- table_.setEnabled(enabled); >+ hostsViewer.getTable().setEnabled(enabled); > enableButtons(); > } > >- public void setList(String[] hosts) { >- tableValues_ = new TreeSet(Arrays.asList(hosts)); >- >- tableViewer_.setInput(tableValues_); >- tableViewer_.refresh(); >- } >- >- public String[] getList() { >- return (String[]) tableValues_.toArray(new String[0]); >- } >- >- String getStringList(Iterator iterator) { >- StringBuffer buffer = new StringBuffer(); >- >- if (iterator.hasNext()) { >- buffer.append((String) iterator.next()); >- } >- >- while (iterator.hasNext()) { >- buffer.append(','); >- buffer.append((String) iterator.next()); >+ protected void enableButtons() { >+ boolean enabled = getEnabled(); >+ if (enabled) { >+ IStructuredSelection selection = (IStructuredSelection) hostsViewer >+ .getSelection(); >+ Iterator iterator = selection.iterator(); >+ boolean editable = iterator.hasNext(); >+ while (iterator.hasNext()) { >+ String provider = ((ProxyBypassData) iterator.next()) >+ .getSource(); >+ if (!ProxySelector.canSetBypassHosts(provider)) { >+ editable = false; >+ } >+ } >+ addButton.setEnabled(true); >+ editButton.setEnabled(editable); >+ removeButton.setEnabled(editable); >+ } else { >+ addButton.setEnabled(false); >+ editButton.setEnabled(false); >+ removeButton.setEnabled(false); > } >- >- return buffer.toString(); > } > >- void removeFromList(IStructuredSelection selection) { >- tableValues_.removeAll(selection.toList()); >+ protected void addHost() { >+ String hosts[] = promptForHost(null); >+ if (hosts != null) { >+ for (int i = 0; i < hosts.length; i++) { >+ bypassHosts.add(0, new ProxyBypassData(hosts[i], >+ getEditableProvider())); >+ } >+ hostsViewer.refresh(); >+ setProvider(currentProvider); >+ } > } > >- void updateList(String value) { >- // Split the string with a delimiter of either a vertical bar, a space, >- // or a comma. >- String[] hosts = value.split("\\|| |,"); //$NON-NLS-1$ >- >- tableValues_.addAll(Arrays.asList(hosts)); >- tableValues_.remove(""); //$NON-NLS-1$ >- tableViewer_.refresh(); >+ private String getEditableProvider() { >+ String providers[] = ProxySelector.getProviders(); >+ for (int i = 0; i < providers.length; i++) { >+ if (ProxySelector.canSetBypassHosts(providers[i])) { >+ return providers[i]; >+ } >+ } >+ return null; > } > >- void enableButtons() { >- boolean enabled = getEnabled(); >- >- if (enabled) { >- boolean itemsSelected = !tableViewer_.getSelection().isEmpty(); >- >- add_.setEnabled(true); >- edit_.setEnabled(itemsSelected); >- remove_.setEnabled(itemsSelected); >- } else { >- add_.setEnabled(false); >- edit_.setEnabled(false); >- remove_.setEnabled(false); >+ protected void removeSelection() { >+ IStructuredSelection selection = (IStructuredSelection) hostsViewer >+ .getSelection(); >+ Iterator it = selection.iterator(); >+ while (it.hasNext()) { >+ ProxyBypassData data = (ProxyBypassData) it.next(); >+ bypassHosts.remove(data); > } >+ hostsViewer.refresh(); > } > >- void editSelection() { >- IStructuredSelection selection = (IStructuredSelection) tableViewer_.getSelection(); >+ protected void editSelection() { >+ IStructuredSelection selection = (IStructuredSelection) hostsViewer >+ .getSelection(); > String selectedHosts = getStringList(selection.iterator()); >- String value = promptForHost(selectedHosts); >- if (value != null) { >- removeFromList(selection); >- updateList(value); >+ String hosts[] = promptForHost(selectedHosts); >+ if (hosts != null) { >+ Iterator it = selection.iterator(); >+ while (it.hasNext()) { >+ ProxyBypassData data = (ProxyBypassData) it.next(); >+ bypassHosts.remove(data); >+ } >+ for (int i = 0; i < hosts.length; i++) { >+ bypassHosts.add(0, new ProxyBypassData(hosts[i], >+ getEditableProvider())); >+ } >+ hostsViewer.refresh(); > } > } > >- void addHost() { >- String value = promptForHost(null); >- if (value != null) { >- updateList(value); >+ String getStringList(Iterator iterator) { >+ StringBuffer buffer = new StringBuffer(); >+ if (iterator.hasNext()) { >+ ProxyBypassData data = (ProxyBypassData) iterator.next(); >+ buffer.append(data.getHost()); > } >+ while (iterator.hasNext()) { >+ buffer.append(';'); >+ ProxyBypassData data = (ProxyBypassData) iterator.next(); >+ buffer.append(data.getHost()); >+ } >+ return buffer.toString(); > } >- >- private String promptForHost(String selectedHosts) { >+ >+ private String[] promptForHost(String selectedHosts) { > InputDialog dialog = new InputDialog(getShell(), >- NetUIMessages.TITLE_PREFERENCE_HOSTS_DIALOG, >- NetUIMessages.LABEL_PREFERENCE_HOSTS_DIALOG, selectedHosts, >- null) { >+ NetUIMessages.ProxyBypassDialog_0, >+ NetUIMessages.ProxyBypassDialog_1, selectedHosts, null) { > private ControlDecoration decorator; >+ > protected Control createDialogArea(Composite parent) { > Control createDialogArea = super.createDialogArea(parent); > decorator = new ControlDecoration(getText(), SWT.TOP | SWT.LEFT); >- decorator.setDescriptionText(NetUIMessages.NonProxyHostsComposite_0); >- decorator.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration( >- FieldDecorationRegistry.DEC_INFORMATION).getImage()); >+ decorator.setDescriptionText(NetUIMessages.ProxyBypassDialog_2); >+ decorator.setImage(FieldDecorationRegistry.getDefault() >+ .getFieldDecoration( >+ FieldDecorationRegistry.DEC_INFORMATION) >+ .getImage()); > return createDialogArea; > } >+ > public boolean close() { > decorator.dispose(); > return super.close(); > } > }; > int result = dialog.open(); >- String value; > if (result != Window.CANCEL) { >- value = dialog.getValue(); >+ String value = dialog.getValue(); >+ String hosts[] = value.split("\\;| "); //$NON-NLS-1$ >+ ArrayList filtered = new ArrayList(); >+ for (int i = 0; i < hosts.length; i++) { >+ if (hosts[i].length() != 0) { >+ filtered.add(hosts[i]); >+ } >+ } >+ return (String[]) filtered.toArray(new String[0]); >+ } >+ return null; >+ } >+ >+ private Button createButton(String message) { >+ Button button = new Button(this, SWT.PUSH); >+ button.setText(message); >+ button.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false)); >+ return button; >+ } >+ >+ public void initializeValues() { >+ String providers[] = ProxySelector.getProviders(); >+ for (int i = 0; i < providers.length; i++) { >+ String[] hosts = ProxySelector.getBypassHosts(providers[i]); >+ for (int j = 0; hosts != null && j < hosts.length; j++) { >+ ProxyBypassData data = new ProxyBypassData(hosts[j], >+ providers[i]); >+ bypassHosts.add(data); >+ } >+ } >+ hostsViewer.setInput(bypassHosts); >+ setProvider(ProxySelector.getDefaultProvider()); >+ } >+ >+ public void setProvider(String item) { >+ if (item == null) { >+ item = currentProvider; > } else { >- value = null; >+ currentProvider = item; > } >- return value; >+ ArrayList selected = new ArrayList(); >+ Iterator it = bypassHosts.iterator(); >+ while (it.hasNext()) { >+ ProxyBypassData data = (ProxyBypassData) it.next(); >+ if (data.getSource().equalsIgnoreCase(item)) { >+ selected.add(data); >+ } >+ } >+ hostsViewer >+ .setCheckedElements(selected.toArray(new ProxyBypassData[0])); > } >+ >+ public void performApply() { >+ String provider = getEditableProvider(); >+ Iterator it = bypassHosts.iterator(); >+ ArrayList hosts = new ArrayList(); >+ while (it.hasNext()) { >+ ProxyBypassData data = (ProxyBypassData) it.next(); >+ if (data.getSource().equals(provider)) { >+ hosts.add(data.getHost()); >+ } >+ } >+ String data[] = (String[]) hosts.toArray(new String[0]); >+ ProxySelector.setBypassHosts(provider, data); >+ } >+ > } >Index: src/org/eclipse/ui/internal/net/Activator.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/Activator.java,v >retrieving revision 1.1 >diff -u -r1.1 Activator.java >--- src/org/eclipse/ui/internal/net/Activator.java 26 Feb 2007 18:16:44 -0000 1.1 >+++ src/org/eclipse/ui/internal/net/Activator.java 20 Nov 2008 13:43:15 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >+ * Copyright (c) 2007, 2008 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 >@@ -13,10 +13,8 @@ > *******************************************************************************/ > package org.eclipse.ui.internal.net; > >-import org.eclipse.core.net.proxy.IProxyService; > import org.eclipse.ui.plugin.AbstractUIPlugin; > import org.osgi.framework.BundleContext; >-import org.osgi.util.tracker.ServiceTracker; > > /** > * The activator class controls the plug-in life cycle >@@ -29,8 +27,6 @@ > // The shared instance > private static Activator plugin; > >- private ServiceTracker tracker; >- > /** > * The constructor > */ >@@ -47,26 +43,13 @@ > return plugin; > } > >- /** >- * Return the {@link IProxyService} or <code>null</code> if the service is >- * not available. >- * >- * @return the {@link IProxyService} or <code>null</code> >- */ >- public IProxyService getProxyService() { >- return (IProxyService) tracker.getService(); >- } >- > public void start(BundleContext context) throws Exception { > super.start(context); >- tracker = new ServiceTracker(getBundle().getBundleContext(), >- IProxyService.class.getName(), null); >- tracker.open(); > } > > public void stop(BundleContext context) throws Exception { > plugin = null; > super.stop(context); >- tracker.close(); > } >+ > } >Index: src/org/eclipse/ui/internal/net/ProxyEntryDialog.java >=================================================================== >RCS file: src/org/eclipse/ui/internal/net/ProxyEntryDialog.java >diff -N src/org/eclipse/ui/internal/net/ProxyEntryDialog.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ui/internal/net/ProxyEntryDialog.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,241 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 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.ui.internal.net; >+ >+import java.net.URI; >+import java.net.URISyntaxException; >+ >+import org.eclipse.core.internal.net.ProxyData; >+import org.eclipse.core.net.proxy.IProxyData; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.jface.dialogs.StatusDialog; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.ModifyEvent; >+import org.eclipse.swt.events.ModifyListener; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.swt.widgets.Text; >+ >+public class ProxyEntryDialog extends StatusDialog { >+ >+ private IProxyData data; >+ private String[] addedTypes; >+ >+ private Label typeLabel; >+ private Text typeText; >+ private Label hostLabel; >+ private Text hostText; >+ private Label portLabel; >+ private Text portText; >+ >+ private Button requiresAuthentificationButton; >+ private Label userIdLabel; >+ private Text userIdText; >+ private Label passwordLabel; >+ private Text passwordText; >+ >+ public ProxyEntryDialog(Shell parent, IProxyData data, String[] addedArray, >+ String title) { >+ super(parent); >+ if (data == null) { >+ this.data = new ProxyData("", "", 0, false, ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >+ } else { >+ this.data = data; >+ } >+ this.addedTypes = addedArray; >+ this.setTitle(title); >+ } >+ >+ public IProxyData getValue() { >+ return data; >+ } >+ >+ protected Control createDialogArea(Composite parent) { >+ Composite composite = new Composite(parent, SWT.NONE); >+ composite.setLayout(new GridLayout(4, false)); >+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL >+ | GridData.FILL_VERTICAL)); >+ >+ typeLabel = new Label(composite, SWT.NONE); >+ typeLabel.setText(NetUIMessages.ProxyEntryDialog_2); >+ typeLabel.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, >+ 1, 1)); >+ typeText = new Text(composite, SWT.BORDER); >+ typeText.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 3, >+ 1)); >+ typeText.setEditable(false); >+ >+ hostLabel = new Label(composite, SWT.NONE); >+ hostLabel.setText(NetUIMessages.ProxyEntryDialog_3); >+ hostLabel.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, >+ 1, 1)); >+ hostText = new Text(composite, SWT.BORDER); >+ GridData gdata = new GridData(SWT.FILL, SWT.TOP, true, false); >+ gdata.widthHint = 250; >+ hostText.setLayoutData(gdata); >+ >+ portLabel = new Label(composite, SWT.NONE); >+ portLabel.setText(NetUIMessages.ProxyEntryDialog_4); >+ portText = new Text(composite, SWT.BORDER); >+ gdata = new GridData(); >+ gdata.widthHint = 25; >+ portText.setLayoutData(gdata); >+ >+ requiresAuthentificationButton = new Button(composite, SWT.CHECK); >+ requiresAuthentificationButton >+ .setText(NetUIMessages.ProxyEntryDialog_6); >+ requiresAuthentificationButton.setLayoutData(new GridData(SWT.LEFT, >+ SWT.CENTER, false, false, 4, 1)); >+ >+ userIdLabel = new Label(composite, SWT.NONE); >+ userIdLabel.setText(NetUIMessages.ProxyEntryDialog_7); >+ userIdLabel.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, >+ 1, 1)); >+ userIdText = new Text(composite, SWT.BORDER); >+ userIdText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, >+ 3, 1)); >+ >+ passwordLabel = new Label(composite, SWT.NONE); >+ passwordLabel.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, >+ true, 1, 1)); >+ passwordLabel.setText(NetUIMessages.ProxyEntryDialog_8); >+ passwordText = new Text(composite, SWT.BORDER); >+ passwordText.setEchoChar('*'); >+ passwordText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true, >+ 3, 1)); >+ >+ ModifyListener validationListener = new ModifyListener() { >+ public void modifyText(ModifyEvent e) { >+ updateStatus(); >+ } >+ }; >+ typeText.addModifyListener(validationListener); >+ hostText.addModifyListener(validationListener); >+ portText.addModifyListener(validationListener); >+ userIdText.addModifyListener(validationListener); >+ passwordText.addModifyListener(validationListener); >+ requiresAuthentificationButton >+ .addSelectionListener(new SelectionListener() { >+ public void widgetDefaultSelected(SelectionEvent e) { >+ enableButtons(); >+ updateStatus(); >+ } >+ >+ public void widgetSelected(SelectionEvent e) { >+ enableButtons(); >+ updateStatus(); >+ } >+ }); >+ >+ Dialog.applyDialogFont(composite); >+ applyData(); >+ enableButtons(); >+ return composite; >+ } >+ >+ public boolean isHelpAvailable() { >+ return false; >+ } >+ >+ public boolean isResizable() { >+ return true; >+ } >+ >+ private String toString(String str) { >+ return str == null ? "" : str; //$NON-NLS-1$ >+ } >+ >+ private void applyData() { >+ typeText.setText(toString(data.getType())); >+ hostText.setText(toString(data.getHost())); >+ if (data.getPort() != -1) { >+ portText.setText(toString(Integer.toString(data.getPort()))); >+ } else { >+ portText.setText(""); //$NON-NLS-1$ >+ } >+ boolean auth = data.isRequiresAuthentication(); >+ requiresAuthentificationButton.setSelection(auth); >+ userIdText.setText(toString(data.getUserId())); >+ passwordText.setText(toString(data.getPassword())); >+ } >+ >+ protected void okPressed() { >+ ((ProxyData) data).setType(typeText.getText()); >+ data.setHost(hostText.getText()); >+ data.setPort(Integer.parseInt(portText.getText())); >+ if (requiresAuthentificationButton.getSelection()) { >+ data.setUserid(userIdText.getText()); >+ data.setPassword(passwordText.getText()); >+ } else { >+ data.setUserid(null); >+ data.setPassword(null); >+ } >+ super.okPressed(); >+ } >+ >+ protected void enableButtons() { >+ boolean auth = requiresAuthentificationButton.getSelection(); >+ userIdText.setEnabled(auth); >+ passwordText.setEnabled(auth); >+ } >+ >+ protected void updateStatus() { >+ String type = typeText.getText(); >+ for (int i = 0; i < addedTypes.length; i++) { >+ if (addedTypes[i].equalsIgnoreCase(type)) { >+ updateStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, >+ IStatus.OK, NetUIMessages.ProxyEntryDialog_9, null)); >+ return; >+ } >+ } >+ try { >+ new URI(hostText.getText()); >+ } catch (URISyntaxException e) { >+ updateStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, >+ IStatus.OK, NetUIMessages.ProxyEntryDialog_10, null)); >+ return; >+ } >+ if (hostText.getText().length() == 0) { >+ updateStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, >+ IStatus.OK, NetUIMessages.ProxyEntryDialog_10, null)); >+ return; >+ } >+ try { >+ int port = Integer.parseInt(portText.getText()); >+ if (port < 0) { >+ updateStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, >+ IStatus.OK, NetUIMessages.ProxyEntryDialog_11, null)); >+ return; >+ } >+ } catch (NumberFormatException e) { >+ updateStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, >+ IStatus.OK, NetUIMessages.ProxyEntryDialog_11, null)); >+ return; >+ } >+ if (requiresAuthentificationButton.getSelection()) { >+ if (userIdText.getText().length() == 0) { >+ updateStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, >+ IStatus.OK, NetUIMessages.ProxyEntryDialog_12, null)); >+ return; >+ } >+ } >+ updateStatus(Status.OK_STATUS); >+ } >+} >Index: src/org/eclipse/ui/internal/net/ProxyEntriesLabelProvider.java >=================================================================== >RCS file: src/org/eclipse/ui/internal/net/ProxyEntriesLabelProvider.java >diff -N src/org/eclipse/ui/internal/net/ProxyEntriesLabelProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ui/internal/net/ProxyEntriesLabelProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,110 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 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.ui.internal.net; >+ >+import org.eclipse.core.internal.net.ProxySelector; >+import org.eclipse.core.net.proxy.IProxyData; >+import org.eclipse.jface.viewers.BaseLabelProvider; >+import org.eclipse.jface.viewers.IColorProvider; >+import org.eclipse.jface.viewers.ITableLabelProvider; >+import org.eclipse.jface.viewers.TableViewer; >+import org.eclipse.jface.viewers.TableViewerColumn; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.graphics.Color; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.swt.widgets.TableColumn; >+ >+public class ProxyEntriesLabelProvider extends BaseLabelProvider implements >+ ITableLabelProvider, IColorProvider { >+ >+ public ProxyEntriesLabelProvider() { >+ super(); >+ } >+ >+ public Image getColumnImage(Object element, int columnIndex) { >+ return null; >+ } >+ >+ public String getColumnText(Object element, int columnIndex) { >+ if (element == null) { >+ return null; >+ } >+ IProxyData data = (IProxyData) element; >+ switch (columnIndex) { >+ case 0: >+ return null; >+ case 1: >+ return data.getType(); >+ case 2: >+ if (data.isDynamic()) { >+ return NetUIMessages.ProxyPreferencePage_18; >+ } >+ return data.getHost(); >+ case 3: >+ if (data.isDynamic()) { >+ return NetUIMessages.ProxyPreferencePage_18; >+ } >+ if (data.getPort() == -1) { >+ return ""; //$NON-NLS-1$ >+ } >+ return Integer.toString(data.getPort()); >+ case 4: >+ return data.getSource(); >+ case 5: >+ return Boolean.toString(data.isRequiresAuthentication()); >+ case 6: >+ return data.getUserId(); >+ case 7: >+ return data.getPassword(); >+ default: >+ return null; >+ } >+ } >+ >+ public boolean isLabelProperty(Object element, String property) { >+ return false; >+ } >+ >+ public void createColumns(TableViewer viewer) { >+ String[] titles = { >+ "", //$NON-NLS-1$ >+ NetUIMessages.ProxyPreferencePage_2, >+ NetUIMessages.ProxyPreferencePage_3, >+ NetUIMessages.ProxyPreferencePage_4, >+ NetUIMessages.ProxyPreferencePage_5, >+ NetUIMessages.ProxyPreferencePage_6, >+ NetUIMessages.ProxyPreferencePage_7, >+ NetUIMessages.ProxyPreferencePage_8 }; >+ for (int i = 0; i < titles.length; i++) { >+ TableColumn column = new TableViewerColumn(viewer, SWT.NONE) >+ .getColumn(); >+ column.setText(titles[i]); >+ column.setResizable(true); >+ } >+ } >+ >+ public Color getBackground(Object element) { >+ if (element instanceof IProxyData) { >+ String provider = ((IProxyData) element).getSource(); >+ if (!ProxySelector.canSetProxyData(provider)) { >+ return Display.getCurrent().getSystemColor( >+ SWT.COLOR_INFO_BACKGROUND); >+ } >+ } >+ return null; >+ } >+ >+ public Color getForeground(Object element) { >+ return null; >+ } >+ >+} >Index: src/org/eclipse/ui/internal/net/ProxyEntriesComposite.java >=================================================================== >RCS file: src/org/eclipse/ui/internal/net/ProxyEntriesComposite.java >diff -N src/org/eclipse/ui/internal/net/ProxyEntriesComposite.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ui/internal/net/ProxyEntriesComposite.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,291 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 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.ui.internal.net; >+ >+import java.util.ArrayList; >+import java.util.Iterator; >+ >+import org.eclipse.core.internal.net.ProxySelector; >+import org.eclipse.core.net.proxy.IProxyData; >+import org.eclipse.jface.viewers.CheckStateChangedEvent; >+import org.eclipse.jface.viewers.CheckboxTableViewer; >+import org.eclipse.jface.viewers.ColumnPixelData; >+import org.eclipse.jface.viewers.ColumnWeightData; >+import org.eclipse.jface.viewers.DoubleClickEvent; >+import org.eclipse.jface.viewers.ICheckStateListener; >+import org.eclipse.jface.viewers.IDoubleClickListener; >+import org.eclipse.jface.viewers.ISelectionChangedListener; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.viewers.SelectionChangedEvent; >+import org.eclipse.jface.viewers.TableLayout; >+import org.eclipse.jface.window.Window; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.Table; >+ >+/** >+ * This class is the Composite that consists of the controls for proxy entries >+ * and is used by ProxyPreferencesPage. >+ */ >+public class ProxyEntriesComposite extends Composite { >+ >+ private Label entriesLabel; >+ private CheckboxTableViewer entriesViewer; >+ // private Button addButton; >+ private Button editButton; >+ private Button removeButton; >+ >+ protected String currentProvider; >+ private ArrayList proxyEntries = new ArrayList(); >+ >+ ProxyEntriesComposite(Composite parent, int style) { >+ super(parent, style); >+ createWidgets(); >+ } >+ >+ protected void createWidgets() { >+ setLayout(new GridLayout(2, false)); >+ >+ entriesLabel = new Label(this, SWT.NONE); >+ entriesLabel.setText(NetUIMessages.ProxyPreferencePage_1); >+ entriesLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, >+ false, false, 2, 1)); >+ >+ Table entriesTable = new Table(this, SWT.BORDER | SWT.V_SCROLL >+ | SWT.H_SCROLL | SWT.MULTI | SWT.FULL_SELECTION | SWT.CHECK); >+ entriesTable.setHeaderVisible(true); >+ entriesTable.setLinesVisible(true); >+ entriesTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, >+ 1, 3)); >+ >+ entriesViewer = new CheckboxTableViewer(entriesTable); >+ ProxyEntriesLabelProvider labelProvider = new ProxyEntriesLabelProvider(); >+ ProxyEntriesContentProvider contentProvider = new ProxyEntriesContentProvider(); >+ labelProvider.createColumns(entriesViewer); >+ entriesViewer.setContentProvider(contentProvider); >+ entriesViewer.setLabelProvider(labelProvider); >+ >+ TableLayout tableLayout = new TableLayout(); >+ tableLayout.addColumnData(new ColumnPixelData(18)); >+ tableLayout.addColumnData(new ColumnWeightData(20, 50, true)); >+ tableLayout.addColumnData(new ColumnWeightData(50, 50, true)); >+ tableLayout.addColumnData(new ColumnWeightData(20, 50, true)); >+ tableLayout.addColumnData(new ColumnWeightData(20, 50, true)); >+ tableLayout.addColumnData(new ColumnWeightData(20, 50, true)); >+ tableLayout.addColumnData(new ColumnWeightData(50, 50, true)); >+ tableLayout.addColumnData(new ColumnWeightData(50, 50, true)); >+ >+ entriesTable.setLayout(tableLayout); >+ >+ // addButton = createButton(NetUIMessages.ProxyPreferencePage_9); >+ editButton = createButton(NetUIMessages.ProxyPreferencePage_10); >+ removeButton = createButton(NetUIMessages.ProxyPreferencePage_11); >+ >+ entriesViewer >+ .addSelectionChangedListener(new ISelectionChangedListener() { >+ public void selectionChanged(SelectionChangedEvent event) { >+ enableButtons(); >+ } >+ }); >+ entriesViewer.addCheckStateListener(new ICheckStateListener() { >+ public void checkStateChanged(CheckStateChangedEvent event) { >+ setProvider(currentProvider); >+ } >+ }); >+ entriesViewer.addDoubleClickListener(new IDoubleClickListener() { >+ public void doubleClick(DoubleClickEvent event) { >+ editSelection(); >+ } >+ }); >+ // addButton.addSelectionListener(new SelectionAdapter() { >+ // public void widgetSelected(SelectionEvent e) { >+ // addEntry(); >+ // } >+ // }); >+ editButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ editSelection(); >+ } >+ }); >+ removeButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ removeSelection(); >+ } >+ }); >+ >+ initializeValues(); >+ enableButtons(); >+ } >+ >+ protected void enableButtons() { >+ boolean enabled = getEnabled(); >+ if (enabled) { >+ IStructuredSelection selection = (IStructuredSelection) entriesViewer >+ .getSelection(); >+ Iterator iterator = selection.iterator(); >+ boolean editable = iterator.hasNext(); >+ while (iterator.hasNext()) { >+ String provider = ((IProxyData) iterator.next()).getSource(); >+ if (!ProxySelector.canSetProxyData(provider)) { >+ editable = false; >+ } >+ } >+ // addButton.setEnabled(true); >+ editButton.setEnabled(editable && selection.size() == 1); >+ removeButton.setEnabled(editable); >+ } else { >+ // addButton.setEnabled(false); >+ editButton.setEnabled(false); >+ removeButton.setEnabled(false); >+ } >+ } >+ >+ protected void addEntry() { >+ Iterator it = proxyEntries.iterator(); >+ ArrayList added = new ArrayList(); >+ String editableProvider = getEditableProvider(); >+ while (it.hasNext()) { >+ IProxyData data = (IProxyData) it.next(); >+ if (data.getSource().equalsIgnoreCase(editableProvider)) { >+ added.add(data.getType()); >+ } >+ } >+ String addedArray[] = (String[]) added.toArray(new String[0]); >+ IProxyData data = promptForEntry(null, addedArray, >+ NetUIMessages.ProxyEntryDialog_0); >+ if (data != null) { >+ data.setSource(editableProvider); >+ proxyEntries.add(0, data); >+ entriesViewer.refresh(); >+ } >+ } >+ >+ private String getEditableProvider() { >+ String providers[] = ProxySelector.getProviders(); >+ for (int i = 0; i < providers.length; i++) { >+ if (ProxySelector.canSetProxyData(providers[i])) { >+ return providers[i]; >+ } >+ } >+ return null; >+ } >+ >+ private IProxyData promptForEntry(IProxyData entry, String[] addedArray, >+ String title) { >+ ProxyEntryDialog dialog = new ProxyEntryDialog(getShell(), entry, >+ addedArray, title); >+ int result = dialog.open(); >+ if (result != Window.CANCEL) { >+ return dialog.getValue(); >+ } >+ return null; >+ } >+ >+ protected void editSelection() { >+ Iterator itsel = ((IStructuredSelection) entriesViewer.getSelection()) >+ .iterator(); >+ IProxyData toEdit = null; >+ if (itsel.hasNext()) { >+ toEdit = ((IProxyData) itsel.next()); >+ } else { >+ return; >+ } >+ Iterator it = proxyEntries.iterator(); >+ ArrayList added = new ArrayList(); >+ String editableProvider = getEditableProvider(); >+ while (it.hasNext()) { >+ IProxyData data = (IProxyData) it.next(); >+ if (data.getSource().equalsIgnoreCase(editableProvider)) { >+ if (data.getType() != toEdit.getType()) { >+ added.add(data.getType()); >+ } >+ } >+ } >+ String addedArray[] = (String[]) added.toArray(new String[0]); >+ IProxyData data = promptForEntry(toEdit, addedArray, >+ NetUIMessages.ProxyEntryDialog_1); >+ if (data != null) { >+ entriesViewer.refresh(); >+ } >+ } >+ >+ protected void removeSelection() { >+ IStructuredSelection selection = (IStructuredSelection) entriesViewer >+ .getSelection(); >+ Iterator it = selection.iterator(); >+ while (it.hasNext()) { >+ IProxyData data = (IProxyData) it.next(); >+ data.setHost(""); //$NON-NLS-1$ >+ data.setPort(-1); >+ data.setUserid(null); >+ data.setPassword(null); >+ } >+ entriesViewer.refresh(); >+ } >+ >+ private Button createButton(String message) { >+ Button button = new Button(this, SWT.PUSH); >+ button.setText(message); >+ button.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false)); >+ return button; >+ } >+ >+ public void initializeValues() { >+ String providers[] = ProxySelector.getProviders(); >+ for (int i = 0; i < providers.length; i++) { >+ IProxyData[] entries = ProxySelector.getProxyData(providers[i]); >+ for (int j = 0; j < entries.length; j++) { >+ entries[j].setSource(providers[i]); >+ proxyEntries.add(entries[j]); >+ } >+ } >+ entriesViewer.setInput(proxyEntries); >+ setProvider(ProxySelector.getDefaultProvider()); >+ } >+ >+ public void setProvider(String item) { >+ if (item == null) { >+ item = currentProvider; >+ } else { >+ currentProvider = item; >+ } >+ ArrayList checked = new ArrayList(); >+ Iterator it = proxyEntries.iterator(); >+ while (it.hasNext()) { >+ IProxyData data = (IProxyData) it.next(); >+ if (data.getSource().equalsIgnoreCase(item)) { >+ checked.add(data); >+ } >+ } >+ entriesViewer.setCheckedElements(checked.toArray(new IProxyData[0])); >+ } >+ >+ public void performApply() { >+ String provider = getEditableProvider(); >+ Iterator it = proxyEntries.iterator(); >+ ArrayList proxies = new ArrayList(); >+ while (it.hasNext()) { >+ IProxyData data = (IProxyData) it.next(); >+ if (data.getSource().equals(provider)) { >+ proxies.add(data); >+ } >+ } >+ IProxyData data[] = (IProxyData[]) proxies.toArray(new IProxyData[0]); >+ ProxySelector.setProxyData(provider, data); >+ } >+ >+} >Index: src/org/eclipse/ui/internal/net/ProxyBypassData.java >=================================================================== >RCS file: src/org/eclipse/ui/internal/net/ProxyBypassData.java >diff -N src/org/eclipse/ui/internal/net/ProxyBypassData.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ui/internal/net/ProxyBypassData.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,40 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 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.ui.internal.net; >+ >+public class ProxyBypassData { >+ >+ private String host; >+ private String source; >+ >+ public ProxyBypassData(String host, String source) { >+ super(); >+ this.host = host; >+ this.source = source; >+ } >+ >+ public String getHost() { >+ return host; >+ } >+ >+ public void setHost(String host) { >+ this.host = host; >+ } >+ >+ public String getSource() { >+ return source; >+ } >+ >+ public void setSource(String source) { >+ this.source = source; >+ } >+ >+} >Index: src/org/eclipse/ui/internal/net/ProxyEntriesContentProvider.java >=================================================================== >RCS file: src/org/eclipse/ui/internal/net/ProxyEntriesContentProvider.java >diff -N src/org/eclipse/ui/internal/net/ProxyEntriesContentProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ui/internal/net/ProxyEntriesContentProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,38 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 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.ui.internal.net; >+ >+import java.util.Collection; >+ >+import org.eclipse.core.net.proxy.IProxyData; >+import org.eclipse.jface.viewers.IStructuredContentProvider; >+import org.eclipse.jface.viewers.Viewer; >+ >+public class ProxyEntriesContentProvider implements IStructuredContentProvider { >+ >+ public ProxyEntriesContentProvider() { >+ super(); >+ } >+ >+ public void dispose() { >+ // Do nothing >+ } >+ >+ public Object[] getElements(Object inputElement) { >+ Collection coll = (Collection) inputElement; >+ return coll.toArray(new IProxyData[0]); >+ } >+ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ // Do nothing >+ } >+ >+} >\ No newline at end of file
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
Flags:
pawel.pogorzelski1
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 228739
:
97571
|
98755
|
115783
|
118282
| 118360