int parameterPositionOffset = 0;
for (ParameterData param : params)
{
boolean valueInCombo = false;
Label label = _toolkit.createLabel(_paramsComposite, ViewUtility.getDisplayText(param.getName()));
FormData formData = new FormData();
if (params.indexOf(param) == 0)
{
parameterPositionOffset = 0;
}
else
{
parameterPositionOffset += heightForAParameter;
}
formData.top = new FormAttachment(0, parameterPositionOffset + 2);
formData.right = new FormAttachment(labelWidth);
label.setLayoutData(formData);
label.setToolTipText(param.getDescription());
formData = new FormData();
formData.top = new FormAttachment(0, parameterPositionOffset);
formData.left = new FormAttachment(label, 5);
formData.right = new FormAttachment(valueWidth);
// this will contain the list of items, if the list is to be made available to choose from
// e.g. the list of exchanges
String[] items = null;
if (param.getName().equals(QUEUE))
{
List<String> qList = ApplicationRegistry.getServerRegistry(_mbean).getQueueNames(_virtualHostName);
// Customization for AMQQueueMBean method OPERATION_MOVE_MESSAGES
if (_opData.getName().equals(OPERATION_MOVE_MESSAGES))
{
qList.remove(_mbean.getName());
}
// End of Customization
items = qList.toArray(new String[0]);
}
else if (param.getName().equals(EXCHANGE))
{
items = ApplicationRegistry.getServerRegistry(_mbean).getExchangeNames(_virtualHostName);
}
else if (param.getName().equals(EXCHANGE_TYPE))
{
items = DEFAULT_EXCHANGE_TYPE_VALUES.toArray(new String[DEFAULT_EXCHANGE_TYPE_VALUES.size()]);
}
else if (isUserListParameter(param))
{
List<String> list = ApplicationRegistry.getServerRegistry(_mbean).getUsernames();
if (list != null && !list.isEmpty())
{
items = list.toArray(new String[0]);
}
}
if (items != null)
{
org.eclipse.swt.widgets.List _list = new org.eclipse.swt.widgets.List(_paramsComposite, SWT.BORDER | SWT.V_SCROLL);
int listSize = _form.getClientArea().height * 2 / 3;
int itemsHeight = items.length * (_list.getItemHeight() + 2);
// Set a min height for the list widget (set it to min 4 items)
if (items.length < 4)
{
itemsHeight = 4 * (_list.getItemHeight() + 2);
}
listSize = (listSize > itemsHeight) ? itemsHeight : listSize;
parameterPositionOffset = parameterPositionOffset + listSize;
formData.bottom = new FormAttachment(0, parameterPositionOffset);
_list.setLayoutData(formData);
_list.setData(param);
_list.setItems(items);
_list.addSelectionListener(parameterSelectionListener);
valueInCombo = true;
}
else if (param.isBoolean())
{
Button booleanButton = _toolkit.createButton(_paramsComposite, "", SWT.CHECK);
booleanButton.setLayoutData(formData);
booleanButton.setData(param);
booleanButton.addSelectionListener(booleanSelectionListener);
valueInCombo = true;
}
else
{
int style = SWT.NONE;
if (PASSWORD.equalsIgnoreCase(param.getName()))
{
style = SWT.PASSWORD;
}
Text text = _toolkit.createText(_paramsComposite, "", style);
formData = new FormData();
formData.top = new FormAttachment(0, parameterPositionOffset);
formData.left = new FormAttachment(label, 5);
formData.right = new FormAttachment(valueWidth);
text.setLayoutData(formData);
// Listener to assign value to the parameter
text.addKeyListener(keyListener);
// Listener to verify if the entered key is valid
text.addVerifyListener(verifyListener);
text.setData(param);
}
// display the parameter data type next to the text field
if (valueInCombo)
{
label = _toolkit.createLabel(_paramsComposite, "");
}
else if (PASSWORD.equalsIgnoreCase(param.getName()))
{
label = _toolkit.createLabel(_paramsComposite, "(String)");
}
else
{
String str = param.getType();
if (param.getType().lastIndexOf(".") != -1)
{
str = param.getType().substring(1 + param.getType().lastIndexOf("."));
}
label = _toolkit.createLabel(_paramsComposite, "(" + str + ")");
}
formData = new FormData();
formData.top = new FormAttachment(0, parameterPositionOffset);
formData.left = new FormAttachment(valueWidth, 5);
label.setLayoutData(formData);
}
}