Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net')
-rw-r--r--bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/Activator.java72
-rw-r--r--bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NetUIMessages.java91
-rw-r--r--bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NonProxyHostsComposite.java255
-rw-r--r--bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NonProxyHostsContentProvider.java62
-rw-r--r--bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NonProxyHostsLabelProvider.java117
-rw-r--r--bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/ProxyPreferencePage.java517
-rw-r--r--bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/auth/Authentication.java36
-rw-r--r--bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/auth/NetAuthenticator.java49
-rw-r--r--bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/auth/UserValidationDialog.java164
-rw-r--r--bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/messages.properties47
10 files changed, 1410 insertions, 0 deletions
diff --git a/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/Activator.java b/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/Activator.java
new file mode 100644
index 000000000..a1e4d2999
--- /dev/null
+++ b/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/Activator.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ * 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 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
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.ui.net"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ private ServiceTracker tracker;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ plugin = this;
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ 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();
+ }
+}
diff --git a/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NetUIMessages.java b/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NetUIMessages.java
new file mode 100644
index 000000000..d768a1f7e
--- /dev/null
+++ b/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NetUIMessages.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 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
+ * 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 org.eclipse.osgi.util.NLS;
+
+public final class NetUIMessages extends NLS {
+
+ 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 InternetCategoryPage_0;
+
+ public static String InternetCategoryPage_1;
+
+ 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_5;
+
+ public static String ProxyPreferencePage_6;
+
+ public static String ProxyPreferencePage_7;
+
+ public static String ProxyPreferencePage_8;
+
+ public static String ProxyPreferencePage_9;
+
+ public static String TITLE_PREFERENCE_HOSTS_DIALOG;
+
+ public static String LABEL_PREFERENCE_HOSTS_DIALOG;
+
+ 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);
+ }
+}
diff --git a/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NonProxyHostsComposite.java b/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NonProxyHostsComposite.java
new file mode 100644
index 000000000..948012e64
--- /dev/null
+++ b/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NonProxyHostsComposite.java
@@ -0,0 +1,255 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 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
+ * yyyymmdd bug Email and other contact information
+ * -------- -------- -----------------------------------------------------------
+ * 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.Iterator;
+import java.util.TreeSet;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.viewers.ColumnWeightData;
+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.viewers.TableViewer;
+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.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+/**
+ * This class is the Composite that consists of the controls for
+ * "http.nonProxyHosts" and is used by InternetPreferencesPage.
+ */
+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 )
+ {
+ super(parent, style);
+ createWidgets();
+ }
+
+ public void enableComposite( boolean enabled )
+ {
+ table_.setEnabled( enabled );
+ add_.setEnabled( enabled );
+ edit_.setEnabled( enabled );
+ remove_.setEnabled( enabled );
+ }
+
+ 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_HORIZONTAL | 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);
+
+ table_.setLayout(tableLayout);
+
+ tableViewer_ = new TableViewer(table_);
+ tableViewer_.setContentProvider(new NonProxyHostsContentProvider());
+ tableViewer_.setLabelProvider(new NonProxyHostsLabelProvider());
+
+ tableViewer_.addSelectionChangedListener(new ISelectionChangedListener()
+ {
+ public void selectionChanged(SelectionChangedEvent event)
+ {
+ enableButtons();
+ }
+ });
+
+ 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()
+ {
+ public void widgetSelected(SelectionEvent e)
+ {
+ InputDialog dialog = new InputDialog( getShell(),
+ NetUIMessages.TITLE_PREFERENCE_HOSTS_DIALOG,
+ NetUIMessages.LABEL_PREFERENCE_HOSTS_DIALOG,
+ "", //$NON-NLS-1$
+ null );
+
+ if (dialog.open() != Window.CANCEL)
+ {
+ updateList( dialog.getValue() );
+ }
+ }
+ });
+
+ edit_ = createButton(buttonComp, NetUIMessages.BUTTON_PREFERENCE_EDIT );
+
+ edit_.addSelectionListener(new SelectionAdapter()
+ {
+ public void widgetSelected(SelectionEvent e)
+ {
+ IStructuredSelection selection = (IStructuredSelection)tableViewer_.getSelection();
+ String selectedHosts = getStringList( selection.iterator() );
+
+ InputDialog dialog = new InputDialog( getShell(),
+ NetUIMessages.TITLE_PREFERENCE_HOSTS_DIALOG,
+ NetUIMessages.LABEL_PREFERENCE_HOSTS_DIALOG,
+ selectedHosts,
+ null );
+
+ if (dialog.open() != Window.CANCEL)
+ {
+ removeFromList( selection );
+ updateList( dialog.getValue() );
+ }
+ }
+ });
+ edit_.setEnabled(false);
+
+ remove_ = createButton(buttonComp, NetUIMessages.BUTTON_PREFERENCE_REMOVE);
+
+ remove_.addSelectionListener(new SelectionAdapter()
+ {
+ public void widgetSelected(SelectionEvent e)
+ {
+ removeFromList( (IStructuredSelection)tableViewer_.getSelection() );
+ tableViewer_.refresh();
+ }
+ });
+ 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;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.widgets.Control#setEnabled(boolean)
+ */
+ public void setEnabled(boolean enabled)
+ {
+ super.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() );
+ }
+
+ return buffer.toString();
+ }
+
+ void removeFromList( IStructuredSelection selection )
+ {
+ tableValues_.removeAll( selection.toList() );
+ }
+
+ 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();
+ }
+
+ 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 );
+ }
+ }
+}
diff --git a/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NonProxyHostsContentProvider.java b/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NonProxyHostsContentProvider.java
new file mode 100644
index 000000000..c0167b179
--- /dev/null
+++ b/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NonProxyHostsContentProvider.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 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
+ * 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;
+
+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()
+ {
+ super();
+ }
+
+ /*
+ * Disposes of this content provider.
+ */
+ 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] );
+ }
+
+ /*
+ * 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
+ }
+}
diff --git a/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NonProxyHostsLabelProvider.java b/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NonProxyHostsLabelProvider.java
new file mode 100644
index 000000000..8aeeae266
--- /dev/null
+++ b/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NonProxyHostsLabelProvider.java
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 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
+ * 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 org.eclipse.jface.viewers.ILabelProviderListener;
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+
+/**
+ * Monitor table label provider.
+ */
+public class NonProxyHostsLabelProvider implements ITableLabelProvider
+{
+ /**
+ * MonitorTableLabelProvider constructor comment.
+ */
+ 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)
+ {
+ 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)
+ {
+ 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
+ }
+}
diff --git a/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/ProxyPreferencePage.java b/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/ProxyPreferencePage.java
new file mode 100644
index 000000000..544323aed
--- /dev/null
+++ b/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/ProxyPreferencePage.java
@@ -0,0 +1,517 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ * yyyymmdd bug Email and other contact information
+ * -------- -------- -----------------------------------------------------------
+ * 20070123 154100 eu@md.pp.ru - Eugene Kuleshov, Initial UI coding
+ * 20070201 154100 pmoogk@ca.ibm.com - Peter Moogk, Port internet code from WTP to Eclipse base.
+ * 20070219 174674 pmoogk@ca.ibm.com - Peter Moogk
+ *******************************************************************************/
+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.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.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+public class ProxyPreferencePage extends PreferencePage implements
+ IWorkbenchPreferencePage {
+ IProxyData[] proxyData;
+
+ Entry[] entryList;
+
+ Button directConnectionToButton;
+
+ private Button manualProxyConfigurationButton;
+
+ Button useSameProxyButton;
+
+ private Text nonHostLabel;
+
+ private NonProxyHostsComposite nonHostComposite;
+
+ Button enableProxyAuth;
+
+ private Label useridLabel;
+
+ private Label passwordLabel;
+
+ Text userid;
+
+ Text password;
+
+ private IProxyService proxyService;
+
+ public ProxyPreferencePage() {
+ super(NetUIMessages.ProxyPreferencePage_2);
+ setPreferenceStore(Activator.getDefault().getPreferenceStore());
+ }
+
+ public void init(IWorkbench workbench) {
+ // Nothing to do
+ }
+
+ 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;
+ }
+ proxyData = proxyService.getProxyData();
+ entryList = new Entry[proxyData.length];
+
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ layout.marginRight = 5;
+ layout.marginTop = 5;
+ layout.marginWidth = 0;
+ composite.setLayout(layout);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ composite.setLayoutData(data);
+
+ 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) {
+ enableControls(!directConnectionToButton.getSelection());
+ }
+ });
+
+ manualProxyConfigurationButton = new Button(composite, SWT.RADIO);
+ manualProxyConfigurationButton
+ .setText(NetUIMessages.ProxyPreferencePage_4);
+ manualProxyConfigurationButton
+ .setToolTipText(NetUIMessages.ProxyPreferencePage_0);
+
+ 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_2.horizontalIndent = 17;
+ manualProxyConfigurationComposite.setLayoutData(gridData_2);
+
+ addProtocolEntry(manualProxyConfigurationComposite, 0);
+
+ 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) {
+ handleUseSameProtocol(false);
+ }
+ });
+
+ for (int index = 1; index < proxyData.length; index++) {
+ addProtocolEntry(manualProxyConfigurationComposite, index);
+ }
+
+ Label separator = new Label(manualProxyConfigurationComposite,
+ SWT.HORIZONTAL | SWT.SEPARATOR);
+ separator.setLayoutData(newGridData(4, 5, true, false));
+ nonHostLabel = new Text(manualProxyConfigurationComposite,
+ SWT.READ_ONLY);
+ 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, false));
+
+ 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() {
+ public void widgetSelected(SelectionEvent e) {
+ enableUseridPassword(enableProxyAuth.getSelection());
+ }
+ });
+
+ 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() )
+ {
+ Entry httpEntry = entryList[0];
+ String httpHostname = httpEntry.hostname.getText();
+ String httpPort = httpEntry.port.getText();
+
+ for( int index = 1; index < entryList.length; index++ )
+ {
+ Entry entry = entryList[index];
+
+ entry.hostname.setText( httpHostname );
+ entry.port.setText( httpPort );
+ }
+ }
+ }
+ };
+
+ entryList[0].hostname.addModifyListener( modifyListener );
+ entryList[0].port.addModifyListener( modifyListener );
+
+ restoreState(proxyService.isProxiesEnabled());
+ applyDialogFont(composite);
+
+ return composite;
+ }
+
+ protected void performApply() {
+ if (proxyService == null)
+ return;
+ boolean proxiesEnabled = manualProxyConfigurationButton.getSelection();
+
+ // Save the contents of the text fields to the proxy data.
+ for (int index = 0; index < entryList.length; index++) {
+ entryList[index].applyValues();
+ }
+
+ proxyService.setProxiesEnabled(proxiesEnabled);
+ if (proxiesEnabled) {
+ try {
+ proxyService.setProxyData(proxyData);
+ proxyService.setNonProxiedHosts(
+ nonHostComposite.getList());
+ } catch (CoreException e) {
+ ErrorDialog.openError(getShell(), null, null, e.getStatus());
+ }
+ }
+ Activator.getDefault().savePluginPreferences();
+ }
+
+ protected void performDefaults() {
+ directConnectionToButton.setSelection(true);
+ manualProxyConfigurationButton.setSelection(false);
+ useSameProxyButton.setSelection(false);
+ enableProxyAuth.setSelection(false);
+
+ for (int index = 0; index < entryList.length; index++) {
+ Entry entry = entryList[index];
+
+ entry.hostname.setText(""); //$NON-NLS-1$
+ entry.port.setText(""); //$NON-NLS-1$
+ entry.prevHostname = ""; //$NON-NLS-1$
+ entry.prevPort = -1;
+ }
+
+ 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);
+ }
+
+ public boolean performOk() {
+ performApply();
+ 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 restoreState(boolean proxiesEnabled) {
+
+ directConnectionToButton.setSelection(!proxiesEnabled);
+ manualProxyConfigurationButton.setSelection(proxiesEnabled);
+
+ 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) {
+ this.useSameProxyButton.setSelection(false);
+ this.enableProxyAuth.setSelection(false);
+ this.userid.setText(""); //$NON-NLS-1$
+ this.password.setText(""); //$NON-NLS-1$
+ } else {
+ boolean useSameProtocol = true;
+ for (int i = 1; i < proxyData.length; i++) {
+ IProxyData data = proxyData[i];
+ boolean same = (hostsEqual(data.getHost(), proxyData[0]
+ .getHost()) && portsEqual(data.getPort(), proxyData[0]
+ .getPort()));
+ if (!same) {
+ useSameProtocol = false;
+ break;
+ }
+ }
+ this.useSameProxyButton.setSelection(useSameProtocol);
+ IProxyData 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());
+
+ // TODO: Why does this loop from 1 and not 0?
+ for (int index = 1; index < entryList.length; index++) {
+ entryList[index].restoreValues();
+ }
+ }
+
+ enableControls(proxiesEnabled);
+ handleUseSameProtocol(true);
+ }
+
+ 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);
+ }
+
+ void enableControls(boolean enabled) {
+ for (int index = 0; index < entryList.length; index++) {
+ Entry entry = entryList[index];
+
+ entry.hostname.setEnabled(enabled);
+ entry.nameLabel.setEnabled(enabled);
+ entry.portLabel.setEnabled(enabled);
+ entry.port.setEnabled(enabled);
+ }
+
+ useSameProxyButton.setEnabled(enabled);
+ nonHostLabel.setEnabled(enabled);
+ nonHostComposite.enableComposite(enabled);
+ enableProxyAuth.setEnabled(enabled);
+
+ enableUseridPassword(enableProxyAuth.getSelection() && enabled);
+ }
+
+ void enableUseridPassword(boolean enabled) {
+ useridLabel.setEnabled(enabled);
+ userid.setEnabled(enabled);
+ passwordLabel.setEnabled(enabled);
+ password.setEnabled(enabled);
+ }
+
+ void handleUseSameProtocol(boolean init) {
+ String httpHostname = entryList[0].hostname.getText();
+ String httpPort = entryList[0].port.getText();
+ boolean proxiesEnabled = manualProxyConfigurationButton.getSelection();
+ boolean useSameProtocol = useSameProxyButton.getSelection();
+ boolean controlEnabled = proxiesEnabled && !useSameProtocol;
+
+ for (int index = 1; index < entryList.length; index++) {
+ Entry entry = entryList[index];
+
+ entry.hostname.setEnabled(controlEnabled);
+ entry.nameLabel.setEnabled(controlEnabled);
+ entry.portLabel.setEnabled(controlEnabled);
+ entry.port.setEnabled(controlEnabled);
+
+ if (useSameProtocol) {
+ if (!init) {
+ entry.prevHostname = entry.hostname.getText();
+ try {
+ entry.prevPort = Integer.parseInt(entry.port.getText());
+ } catch (NumberFormatException e) {
+ entry.prevPort = -1;
+ }
+ }
+
+ entry.hostname.setText(httpHostname);
+ entry.port.setText(httpPort);
+ } else {
+ if (!init) {
+ entry.hostname.setText(entry.prevHostname);
+ entry.port.setText(entry.prevPort == -1 ? "" : String //$NON-NLS-1$
+ .valueOf(entry.prevPort));
+ }
+ }
+ }
+ }
+
+ private void addProtocolEntry(Composite parent, int index) {
+ Entry entry = new Entry(index);
+ GridData gridData = null;
+ IProxyData proxy = entry.getProxy();
+ String name = getLabel(proxy);
+
+ String hostname = proxy.getHost();
+ if (hostname == null) {
+ hostname = ""; //$NON-NLS-1$
+ }
+
+ int portInt = proxy.getPort();
+ String port;
+ if (portInt == -1) {
+ port = ""; //$NON-NLS-1$
+ } else {
+ port = String.valueOf(portInt);
+ }
+
+ entry.nameLabel = new Label(parent, SWT.NONE);
+ entry.nameLabel.setText(name);
+
+ entry.hostname = new Text(parent, SWT.BORDER);
+ gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.widthHint = 120;
+ entry.hostname.setLayoutData(gridData);
+ entry.hostname.setText(hostname);
+
+ entry.portLabel = new Label(parent, SWT.NONE);
+ entry.portLabel.setText(NetUIMessages.ProxyPreferencePage_22);
+
+ entry.port = new Text(parent, SWT.BORDER);
+ gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.widthHint = 50;
+ entry.port.setLayoutData(gridData);
+ entry.port.setText(port);
+ entryList[index] = entry;
+ }
+
+ 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 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;
+
+ String prevHostname;
+
+ Label portLabel;
+
+ Text port;
+
+ int prevPort;
+
+ private int proxyIndex;
+
+ public Entry(int index) {
+ this.proxyIndex = index;
+ }
+
+ public IProxyData getProxy() {
+ return proxyData[proxyIndex];
+ }
+
+ public void restoreValues() {
+ IProxyData proxy = getProxy();
+ prevHostname = proxy.getHost();
+ prevPort = proxy.getPort();
+ }
+
+ public void applyValues() {
+ IProxyData proxy = getProxy();
+ boolean enableAuth = enableProxyAuth.getSelection();
+
+ String hostString;
+ String portString;
+ if (useSameProxyButton.getSelection()) {
+ 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);
+ }
+ }
+}
diff --git a/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/auth/Authentication.java b/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/auth/Authentication.java
new file mode 100644
index 000000000..c7d8a0bbb
--- /dev/null
+++ b/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/auth/Authentication.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 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.auth;
+
+/**
+ * Keeps user and password strings.
+ */
+public class Authentication {
+ protected String user;
+ protected String password;
+ public Authentication(String user, String password){
+ this.user = user;
+ this.password = password;
+ }
+
+ /**
+ * @return Returns the password.
+ */
+ public String getPassword() {
+ return password;
+ }
+ /**
+ * @return Returns the user.
+ */
+ public String getUser() {
+ return user;
+ }
+}
diff --git a/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/auth/NetAuthenticator.java b/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/auth/NetAuthenticator.java
new file mode 100644
index 000000000..4f5dade17
--- /dev/null
+++ b/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/auth/NetAuthenticator.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 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.auth;
+
+import java.net.*;
+
+public class NetAuthenticator extends Authenticator {
+
+ /*
+ * @see Authenticator#getPasswordAuthentication()
+ */
+ protected PasswordAuthentication getPasswordAuthentication() {
+ // String protocol = getRequestingProtocol();
+ InetAddress address = getRequestingSite(); // can be null;
+ // int port = getRequestingPort();
+ String prompt = getRequestingPrompt(); // realm or message, not documented that can be null
+ // String scheme = getRequestingScheme(); // not documented that can be null
+
+ // get the host name from the address since #getRequestingHost
+ // is not available in the foundation 1.0 class libraries
+ String hostString = null;
+ if (address != null) {
+ hostString = address.getHostName();
+ }
+ if (hostString == null) {
+ hostString = ""; //$NON-NLS-1$
+ }
+ String promptString = prompt;
+ if (prompt == null) {
+ promptString = ""; //$NON-NLS-1$
+ }
+
+ Authentication auth = UserValidationDialog.getAuthentication(
+ hostString, promptString);
+ if (auth != null)
+ return new PasswordAuthentication(auth.getUser(), auth
+ .getPassword().toCharArray());
+ else
+ return null;
+ }
+}
diff --git a/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/auth/UserValidationDialog.java b/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/auth/UserValidationDialog.java
new file mode 100644
index 000000000..1328fdd73
--- /dev/null
+++ b/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/auth/UserValidationDialog.java
@@ -0,0 +1,164 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 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.auth;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.internal.net.NetUIMessages;
+
+/**
+ * User authentication dialog
+ */
+public class UserValidationDialog extends Dialog {
+ protected Text usernameField;
+ protected Text passwordField;
+
+ protected String host;
+ protected String message;
+ protected Authentication userAuthentication = null;
+ /**
+ * Gets user and password from a user. May be called from any thread
+ * @param host the host name
+ * @param message the message to be displayed when prompting
+ *
+ * @return UserAuthentication that contains the userid and the password or
+ * <code>null</code> if the dialog has been cancelled
+ */
+ public static Authentication getAuthentication(final String host,
+ final String message) {
+ class UIOperation implements Runnable {
+ public Authentication authentication;
+ public void run() {
+ authentication = UserValidationDialog.askForAuthentication(
+ host, message);
+ }
+ }
+
+ UIOperation uio = new UIOperation();
+ if (Display.getCurrent() != null) {
+ uio.run();
+ } else {
+ Display.getDefault().syncExec(uio);
+ }
+ return uio.authentication;
+ }
+ /**
+ * Gets user and password from a user Must be called from UI thread
+ *
+ * @return UserAuthentication that contains the userid and the password or
+ * <code>null</code> if the dialog has been cancelled
+ */
+ protected static Authentication askForAuthentication(String host,
+ String message) {
+ UserValidationDialog ui = new UserValidationDialog(null, host, message);
+ ui.open();
+ return ui.getAuthentication();
+ }
+ /**
+ * Creates a new UserValidationDialog.
+ *
+ * @param parentShell
+ * parent Shell or null
+ */
+ protected UserValidationDialog(Shell parentShell, String host,
+ String message) {
+ super(parentShell);
+ this.host = host;
+ this.message = message;
+ setBlockOnOpen(true);
+ }
+ /**
+ */
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText(NetUIMessages.UserValidationDialog_0);
+ }
+ /**
+ */
+ public void create() {
+ super.create();
+ //give focus to username field
+ usernameField.selectAll();
+ usernameField.setFocus();
+ }
+ /**
+ */
+ protected Control createDialogArea(Composite parent) {
+ Composite main = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 3;
+ main.setLayout(layout);
+ main.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ Label label = new Label(main, SWT.WRAP);
+ String text = NLS.bind(NetUIMessages.UserValidationDialog_1, host);
+ text += "\n\n" + message; //$NON-NLS-1$
+ label.setText(text);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 3;
+ label.setLayoutData(data);
+
+ createUsernameFields(main);
+ createPasswordFields(main);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(main,
+ "org.eclipse.update.ui.UserValidationDialog"); //$NON-NLS-1$
+ return main;
+ }
+ /**
+ * Creates the three widgets that represent the user name entry area.
+ */
+ protected void createPasswordFields(Composite parent) {
+ new Label(parent, SWT.NONE).setText(NetUIMessages.UserValidationDialog_2);
+
+ passwordField = new Text(parent, SWT.BORDER | SWT.PASSWORD);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
+ passwordField.setLayoutData(data);
+
+ new Label(parent, SWT.NONE); //spacer
+ }
+ /**
+ * Creates the three widgets that represent the user name entry area.
+ */
+ protected void createUsernameFields(Composite parent) {
+ new Label(parent, SWT.NONE).setText(NetUIMessages.UserValidationDialog_3);
+
+ usernameField = new Text(parent, SWT.BORDER);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
+ usernameField.setLayoutData(data);
+
+ new Label(parent, SWT.NONE); //spacer
+ }
+ /**
+ * Returns the UserAuthentication entered by the user, or null if the user
+ * canceled.
+ * @return the authentication information
+ */
+ public Authentication getAuthentication() {
+ return userAuthentication;
+ }
+ /**
+ * Notifies that the ok button of this dialog has been pressed.
+ */
+ protected void okPressed() {
+ userAuthentication = new Authentication(usernameField.getText(),
+ passwordField.getText());
+ super.okPressed();
+ }
+
+}
diff --git a/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/messages.properties b/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/messages.properties
new file mode 100644
index 000000000..dec3244ef
--- /dev/null
+++ b/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/messages.properties
@@ -0,0 +1,47 @@
+###############################################################################
+# Copyright (c) 2000, 2007 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
+# yyyymmdd bug Email and other contact information
+# -------- -------- -----------------------------------------------------------
+# 20070201 154100 pmoogk@ca.ibm.com - Peter Moogk, Port internet code from WTP to Eclipse base.
+###############################################################################
+
+#
+# Messages in InternetPreferencePage
+#
+BUTTON_PREFERENCE_ADD=Add...
+BUTTON_PREFERENCE_EDIT=Edit...
+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_2=Proxy Preferences
+ProxyPreferencePage_3=Direct connection to the Internet
+ProxyPreferencePage_4=Manual proxy configuration:
+ProxyPreferencePage_5=Use this proxy server for all protocols
+ProxyPreferencePage_6=No Proxy for:
+ProxyPreferencePage_7=Enable proxy authentication:
+ProxyPreferencePage_8=Userid:
+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 userid.
+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
+UserValidationDialog_0=Password Required
+UserValidationDialog_1=Connect to: {0}
+UserValidationDialog_2=&Password:
+UserValidationDialog_3=&User name:

Back to the top