SWT.COLOR_BLUE));
testResultLabel.setText(PHPServerUIMessages.getString("PHPServerAdvancedTab.27")); //$NON-NLS-1$
testResultLabel.setCursor(Display.getDefault().getSystemCursor(
SWT.CURSOR_WAIT));
testResultLabel.setData("info", null); //$NON-NLS-1$
Job connectionTest = new UIJob(PHPServerUIMessages.getString("PHPServerAdvancedTab.29")) { //$NON-NLS-1$
public IStatus runInUIThread(IProgressMonitor monitor) {
try {
String remoteHost = PHPLaunchUtilities
.getDebugHost(launchConfiguration);
int port = PHPLaunchUtilities
.getDebugPort(launchConfiguration);
if (remoteHost == null || remoteHost.length() == 0
|| port < 0) {
// The host was not yet set in the launch configuration.
testButton.setEnabled(true);
testResultLabel.setCursor(Display.getDefault()
.getSystemCursor(SWT.CURSOR_HAND));
testResultLabel.setForeground(Display.getDefault()
.getSystemColor(SWT.COLOR_DARK_RED));
if (port > -1) {
testResultLabel
.setText(PHPServerUIMessages.getString("PHPServerAdvancedTab.30")); //$NON-NLS-1$
testResultLabel
.setData(
"info", //$NON-NLS-1$
PHPServerUIMessages.getString("PHPServerAdvancedTab.32")); //$NON-NLS-1$
} else {
testResultLabel
.setText(PHPServerUIMessages.getString("PHPServerAdvancedTab.33")); //$NON-NLS-1$
testResultLabel
.setData(
"info", //$NON-NLS-1$
PHPServerUIMessages.getString("PHPServerAdvancedTab.35")); //$NON-NLS-1$
}
}
testResultLabel.setCursor(Display.getDefault()
.getSystemCursor(SWT.CURSOR_WAIT));
IStatus connectionStatus = TunnelTester.test(remoteHost,
userName.getText().trim(), password.getText()
.trim(), port, port);
testButton.setEnabled(true);
testResultLabel.setCursor(null);
if (connectionStatus.isOK()) {
testResultLabel.setForeground(Display.getDefault()
.getSystemColor(SWT.COLOR_DARK_GREEN));
testResultLabel.setText(PHPServerUIMessages.getString("PHPServerAdvancedTab.36")); //$NON-NLS-1$
} else if (connectionStatus.isMultiStatus()) {
// A case where the connection indicate that it was
// successful, however, we were still not able to verify
// that
testResultLabel.setCursor(Display.getDefault()
.getSystemCursor(SWT.CURSOR_HAND));
testResultLabel.setForeground(Display.getDefault()
.getSystemColor(SWT.COLOR_DARK_YELLOW));
testResultLabel
.setText(PHPServerUIMessages.getString("PHPServerAdvancedTab.37")); //$NON-NLS-1$
testResultLabel.setData("info", //$NON-NLS-1$
connectionStatus.getMessage());
// Update the password fields in case the multi status
// also contains a password change information
IStatus[] children = connectionStatus.getChildren();
if (children != null) {
for (IStatus child : children) {
if (child.getSeverity() == IStatus.INFO
&& child.getCode() == TunnelTester.PASSWORD_CHANGED_CODE) {
password.setText(child.getMessage());
break;
}
}
}
} else if (connectionStatus.getSeverity() == IStatus.WARNING) {
testResultLabel.setCursor(Display.getDefault()
.getSystemCursor(SWT.CURSOR_HAND));
testResultLabel.setForeground(Display.getDefault()
.getSystemColor(SWT.COLOR_DARK_GREEN));
testResultLabel
.setText(PHPServerUIMessages.getString("PHPServerAdvancedTab.39")); //$NON-NLS-1$
testResultLabel.setData("info", //$NON-NLS-1$
connectionStatus.getMessage());
} else if (connectionStatus.getSeverity() == IStatus.INFO) {
testResultLabel.setForeground(Display.getDefault()
.getSystemColor(SWT.COLOR_DARK_GREEN));
testResultLabel.setText(PHPServerUIMessages.getString("PHPServerAdvancedTab.41")); //$NON-NLS-1$
// update the password field in case that the info
// indicated a password change.
if (connectionStatus.getCode() == TunnelTester.PASSWORD_CHANGED_CODE) {
password.setText(connectionStatus.getMessage());
}
} else if (connectionStatus.getSeverity() == IStatus.ERROR) {
testResultLabel.setCursor(Display.getDefault()
.getSystemCursor(SWT.CURSOR_HAND));
testResultLabel.setForeground(Display.getDefault()
.getSystemColor(SWT.COLOR_DARK_RED));
testResultLabel
.setText(PHPServerUIMessages.getString("PHPServerAdvancedTab.42")); //$NON-NLS-1$
testResultLabel.setData("info", //$NON-NLS-1$
connectionStatus.getMessage());
}
} catch (OperationCanceledException oce) {
testButton.setEnabled(true);
testResultLabel.setCursor(null);
testResultLabel.setForeground(null);
testResultLabel.setText(PHPServerUIMessages.getString("PHPServerAdvancedTab.44")); //$NON-NLS-1$
}
return Status.OK_STATUS;
}
};
connectionTest.setUser(true);
connectionTest.setPriority(Job.LONG);
connectionTest.schedule();
}