Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2007-04-23 18:39:12 +0000
committerMichael Valenta2007-04-23 18:39:12 +0000
commit8ac01eda063138d98f49280296b88f84dd019fc0 (patch)
tree611e6b5056c8cc61678533359d9be041de34c73e /bundles/org.eclipse.ui.net
parent1add9d8fcfc74013a94fbe3fb757e61d1cd1d4de (diff)
downloadeclipse.platform.team-8ac01eda063138d98f49280296b88f84dd019fc0.tar.gz
eclipse.platform.team-8ac01eda063138d98f49280296b88f84dd019fc0.tar.xz
eclipse.platform.team-8ac01eda063138d98f49280296b88f84dd019fc0.zip
Bug 183372 The Proxy Host Address field should not allow invalid characters
Diffstat (limited to 'bundles/org.eclipse.ui.net')
-rw-r--r--bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NetUIMessages.java6
-rw-r--r--bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/ProxyPreferencePage.java63
-rw-r--r--bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/messages.properties3
3 files changed, 72 insertions, 0 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 6690638fd..ebf202176 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
@@ -59,6 +59,12 @@ public final class NetUIMessages extends NLS {
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;
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 181017c37..20e77f8bb 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
@@ -315,6 +315,17 @@ public class ProxyPreferencePage extends PreferencePage implements
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);
+ }
private GridData newGridData(int span, int verticalIndent,
boolean horizontal, boolean vertical) {
@@ -344,6 +355,7 @@ public class ProxyPreferencePage extends PreferencePage implements
String prevHostname;
int prevPort;
private final IProxyData proxyData;
+ private String errorMessage;
public Entry(IProxyData proxyData) {
this.proxyData = proxyData;
@@ -359,6 +371,7 @@ public class ProxyPreferencePage extends PreferencePage implements
setEnabled(false);
}
}
+ updateMessage();
}
public void setUseSameProtocol(boolean useSameProtocol, Entry httpEntry) {
@@ -442,11 +455,47 @@ public class ProxyPreferencePage extends PreferencePage implements
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();
@@ -484,6 +533,11 @@ public class ProxyPreferencePage extends PreferencePage implements
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);
@@ -493,6 +547,11 @@ public class ProxyPreferencePage extends PreferencePage implements
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) {
@@ -540,5 +599,9 @@ public class ProxyPreferencePage extends PreferencePage implements
portLabel.setEnabled(enabled);
port.setEnabled(enabled);
}
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
}
}
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 5d42b9b68..595035408 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
@@ -41,6 +41,9 @@ 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
UserValidationDialog_0=Password Required
UserValidationDialog_1=Connect to: {0}
UserValidationDialog_2=&Password:

Back to the top