Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2007-04-30 19:07:45 +0000
committerMichael Valenta2007-04-30 19:07:45 +0000
commitb846b176411e22140da52005275b657d8bba27f8 (patch)
tree5108f329f312c666c74520df308e70cfb10dfc3e /bundles/org.eclipse.ui.net
parent116fc03772f635a9ac22a59c1286817e4df40554 (diff)
downloadeclipse.platform.team-b846b176411e22140da52005275b657d8bba27f8.tar.gz
eclipse.platform.team-b846b176411e22140da52005275b657d8bba27f8.tar.xz
eclipse.platform.team-b846b176411e22140da52005275b657d8bba27f8.zip
Bug 177897 [Proxy] Improve UI of Proxy Preferences Page
Diffstat (limited to 'bundles/org.eclipse.ui.net')
-rw-r--r--bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NetUIMessages.java2
-rw-r--r--bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NonProxyHostsComposite.java311
-rw-r--r--bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/ProxyPreferencePage.java6
-rw-r--r--bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/messages.properties7
4 files changed, 167 insertions, 159 deletions
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
index ebf202176..e0637cd00 100644
--- 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
@@ -29,6 +29,8 @@ public final class NetUIMessages extends NLS {
public static String BUTTON_PREFERENCE_REMOVE;
+ public static String NonProxyHostsComposite_0;
+
public static String ProxyPreferencePage_0;
public static String ProxyPreferencePage_1;
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
index 948012e64..594a22828 100644
--- 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
@@ -19,53 +19,42 @@ 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.fieldassist.ControlDecoration;
+import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
+import org.eclipse.jface.viewers.*;
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;
+import org.eclipse.swt.widgets.*;
/**
* 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_;
+public class NonProxyHostsComposite extends Composite {
+ private Table table_;
TableViewer tableViewer_;
- private TreeSet tableValues_;
-
+ private TreeSet tableValues_;
private Button add_;
private Button edit_;
private Button remove_;
-
- public NonProxyHostsComposite(Composite parent, int style )
- {
- super(parent, style);
+
+ 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()
- {
+
+ 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;
@@ -73,34 +62,41 @@ public class NonProxyHostsComposite extends Composite
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_ = 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);
-
+
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();
+
+ tableViewer_
+ .addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ enableButtons();
+ }
+ });
+
+ tableViewer_.addDoubleClickListener(new IDoubleClickListener() {
+ public void doubleClick(DoubleClickEvent event) {
+ editSelection();
}
});
-
+
Composite buttonComp = new Composite(this, SWT.NONE);
layout = new GridLayout();
layout.horizontalSpacing = 0;
@@ -109,147 +105,156 @@ public class NonProxyHostsComposite extends Composite
layout.marginHeight = 0;
layout.numColumns = 1;
buttonComp.setLayout(layout);
- data = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_FILL);
+ 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() );
- }
+
+ add_ = createButton(buttonComp, NetUIMessages.BUTTON_PREFERENCE_ADD);
+
+ add_.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ addHost();
}
- });
-
- 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_ = createButton(buttonComp, NetUIMessages.BUTTON_PREFERENCE_EDIT);
+
+ edit_.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ editSelection();
}
});
edit_.setEnabled(false);
-
- remove_ = createButton(buttonComp, NetUIMessages.BUTTON_PREFERENCE_REMOVE);
-
- remove_.addSelectionListener(new SelectionAdapter()
- {
- public void widgetSelected(SelectionEvent e)
- {
- removeFromList( (IStructuredSelection)tableViewer_.getSelection() );
+
+ 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);
+ remove_.setEnabled(false);
}
-
- private Button createButton(Composite comp, String label)
- {
+
+ 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);
+ 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)
- {
+ */
+ public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
enableButtons();
}
-
- public void setList( String[] hosts )
- {
- tableValues_ = new TreeSet( Arrays.asList( hosts ) );
-
- tableViewer_.setInput( tableValues_ );
+
+ 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] );
+
+ 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() );
+
+ 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() );
+
+ while (iterator.hasNext()) {
+ buffer.append(',');
+ buffer.append((String) iterator.next());
}
-
+
return buffer.toString();
}
-
- void removeFromList( IStructuredSelection selection )
- {
- tableValues_.removeAll( selection.toList() );
+
+ 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$
+
+ 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()
- {
+
+ void enableButtons() {
boolean enabled = getEnabled();
-
- if( enabled )
- {
+
+ if (enabled) {
boolean itemsSelected = !tableViewer_.getSelection().isEmpty();
-
- add_.setEnabled( true );
- edit_.setEnabled( itemsSelected );
- remove_.setEnabled( itemsSelected );
+
+ add_.setEnabled(true);
+ edit_.setEnabled(itemsSelected);
+ remove_.setEnabled(itemsSelected);
+ } else {
+ add_.setEnabled(false);
+ edit_.setEnabled(false);
+ remove_.setEnabled(false);
+ }
+ }
+
+ void editSelection() {
+ IStructuredSelection selection = (IStructuredSelection) tableViewer_.getSelection();
+ String selectedHosts = getStringList(selection.iterator());
+ String value = promptForHost(selectedHosts);
+ if (value != null) {
+ removeFromList(selection);
+ updateList(value);
}
- else
- {
- add_.setEnabled( false );
- edit_.setEnabled( false );
- remove_.setEnabled( false );
+ }
+
+ void addHost() {
+ String value = promptForHost(null);
+ if (value != null) {
+ updateList(value);
+ }
+ }
+
+ private String promptForHost(String selectedHosts) {
+ InputDialog dialog = new InputDialog(getShell(),
+ NetUIMessages.TITLE_PREFERENCE_HOSTS_DIALOG,
+ NetUIMessages.LABEL_PREFERENCE_HOSTS_DIALOG, 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());
+ return createDialogArea;
+ }
+ public boolean close() {
+ decorator.dispose();
+ return super.close();
+ }
+ };
+ int result = dialog.open();
+ String value;
+ if (result != Window.CANCEL) {
+ value = dialog.getValue();
+ } else {
+ value = null;
}
+ return value;
}
}
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
index 20e77f8bb..08da8a2c3 100644
--- 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
@@ -105,7 +105,7 @@ public class ProxyPreferencePage extends PreferencePage implements
gridLayout.marginHeight = 0;
gridLayout.numColumns = 4;
manualProxyConfigurationComposite.setLayout(gridLayout);
- final GridData gridData_2 = new GridData();
+ final GridData gridData_2 = new GridData(GridData.FILL_BOTH);
gridData_2.horizontalIndent = 17;
manualProxyConfigurationComposite.setLayoutData(gridData_2);
@@ -139,7 +139,7 @@ public class ProxyPreferencePage extends PreferencePage implements
nonHostLabel.setLayoutData(newGridData(4, 5, true, false));
nonHostComposite = new NonProxyHostsComposite(
manualProxyConfigurationComposite, SWT.NONE);
- nonHostComposite.setLayoutData(newGridData(4, -1, true, false));
+ nonHostComposite.setLayoutData(newGridData(4, -1, true, true));
Label separator2 = new Label(manualProxyConfigurationComposite,
SWT.HORIZONTAL | SWT.SEPARATOR);
@@ -543,7 +543,7 @@ public class ProxyPreferencePage extends PreferencePage implements
portLabel.setText(NetUIMessages.ProxyPreferencePage_22);
port = new Text(parent, SWT.BORDER);
- gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData = new GridData();
gridData.widthHint = 50;
port.setLayoutData(gridData);
port.setText(getPortString(proxy));
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
index 595035408..f0c10fa1e 100644
--- 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
@@ -29,13 +29,13 @@ 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_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_26=Specifies the basic authentication user name.
ProxyPreferencePage_27=Specifies the basic authentication password
ProxyPreferencePage_37=&HTTP proxy:
ProxyPreferencePage_38=&SSL proxy:
@@ -48,3 +48,4 @@ 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

Back to the top