//Get the text widgets
Control[] widgets = composite.getChildren();
for (int i=0; i < widgets.length; i++)
{
widgets[i].addKeyListener(new KeyAdapter()
{
public void keyPressed(KeyEvent event)
{
if (event.character == SWT.ESC)
{
//Escape key acts as cancel on all widgets
shell.dispose();
}
}
});
}
Composite buttonsComposite = new Composite(composite, SWT.NONE);
buttonsComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
buttonsComposite.setLayout(new GridLayout(2, true));
final Button connectButton = new Button(buttonsComposite, SWT.PUSH | SWT.CENTER);
connectButton.setText(BUTTON_CONNECT);
GridData gridData = new GridData (SWT.TRAIL, SWT.BOTTOM, true, true);
gridData.widthHint = 100;
connectButton.setLayoutData(gridData);
connectButton.setFont(ApplicationRegistry.getFont(FONT_BUTTON));
connectButton.addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent event)
{
_host = textHost.getText();
if ((_host == null) || (_host.trim().length() == 0))
{
ViewUtility.popupInfoMessage(ACTION_ADDSERVER, INFO_HOST_ADDRESS);
textHost.setText("");
textHost.setFocus();
return;
}
_port = textPort.getText();
if ((_port == null) || (_port.trim().length() == 0))
{
ViewUtility.popupInfoMessage(ACTION_ADDSERVER, INFO_HOST_PORT);
textPort.setText("");
textPort.setFocus();
return;
}
_user = textUser.getText();
if ((_user == null) || (_user.trim().length() == 0))
{
ViewUtility.popupInfoMessage(ACTION_ADDSERVER, INFO_USERNAME);
textUser.setText("");
textUser.setFocus();
return;
}
_password = textPwd.getText();
if (_password == null)
{
ViewUtility.popupInfoMessage(ACTION_ADDSERVER, INFO_PASSWORD);
textPwd.setText("");
textPwd.setFocus();
return;
}
_addServer = true;
shell.dispose();
}
});
final Button cancelButton = new Button(buttonsComposite, SWT.PUSH);
cancelButton.setText(BUTTON_CANCEL);
gridData = new GridData (SWT.LEAD, SWT.BOTTOM, true, true);
gridData.widthHint = 100;
cancelButton.setLayoutData(gridData);
cancelButton.setFont(ApplicationRegistry.getFont(FONT_BUTTON));
cancelButton.addSelectionListener(new SelectionAdapter()
{
public void widgetSelected(SelectionEvent event)
{
shell.dispose();
}
});
//Get the ok/cancel button widgets and add a new key listener
widgets = buttonsComposite.getChildren();
for (int i=0; i < widgets.length; i++)
{
widgets[i].addKeyListener(new KeyAdapter()
{
public void keyPressed(KeyEvent event)
{
if (event.character == SWT.ESC)
{