use of javax.management.MBeanParameterInfo in project tdi-studio-se by Talend.
the class InvokeDialog method validate.
/**
* Validates the specified text.
*/
void validate() {
boolean enableButton = true;
for (Entry<MBeanParameterInfo, Control> entry : controls.entrySet()) {
Control control = entry.getValue();
if (!(control instanceof Text)) {
continue;
}
String type = entry.getKey().getType();
String text = ((Text) control).getText();
if (!validateNumber(type, text)) {
enableButton = false;
break;
}
}
Button invokeButton = getButton(IDialogConstants.CLIENT_ID);
if (invokeButton != null) {
invokeButton.setEnabled(enableButton);
}
}
use of javax.management.MBeanParameterInfo in project tdi-studio-se by Talend.
the class InvokeDialog method getParams.
/**
* Gets the parameters.
*
* @return The parameters
*/
private Object[] getParams() {
List<Object> params = new ArrayList<Object>();
for (final MBeanParameterInfo signature : info.getSignature()) {
String text = getText(signature);
Object object;
String type = signature.getType();
if ("int".equals(type)) {
//$NON-NLS-1$
object = Integer.valueOf(text);
} else if ("long".equals(type)) {
//$NON-NLS-1$
object = Long.valueOf(text);
} else if ("boolean".equals(type)) {
//$NON-NLS-1$
object = Boolean.valueOf(text);
} else if ("java.lang.String".equals(type)) {
//$NON-NLS-1$
object = String.valueOf(text);
} else if ("[J".equals(type)) {
//$NON-NLS-1$
//$NON-NLS-1$
String[] elements = text.split(",");
long[] objects = new long[elements.length];
for (int i = 0; i < elements.length; i++) {
objects[i] = Long.parseLong(elements[i]);
}
object = objects;
} else {
//$NON-NLS-1$
throw new IllegalStateException("unknown parameter type");
}
params.add(object);
}
return params.toArray(new Object[0]);
}
use of javax.management.MBeanParameterInfo in project tdi-studio-se by Talend.
the class InvokeDialog method getMethodSignature.
/**
* Gets the method signature.
*
* @return The method signature
*/
private String getMethodSignature() {
StringBuffer buffer = new StringBuffer();
buffer.append(info.getName());
//$NON-NLS-1$
buffer.append("(");
StringBuffer paramBuffer = new StringBuffer();
for (MBeanParameterInfo parameterInfo : info.getSignature()) {
if (paramBuffer.length() != 0) {
//$NON-NLS-1$
paramBuffer.append(", ");
}
String param = parameterInfo.getType();
if (param.startsWith("[")) {
//$NON-NLS-1$
param = Signature.toString(param);
}
int index = param.lastIndexOf('.');
if (index > 0) {
param = param.substring(index + 1);
}
paramBuffer.append(param);
}
buffer.append(paramBuffer);
//$NON-NLS-1$
buffer.append(")");
return buffer.toString();
}
use of javax.management.MBeanParameterInfo in project tdi-studio-se by Talend.
the class InvokeDialog method createParameterGroup.
/**
* Creates the parameter group.
*
* @param parent The parent composite
*/
private void createParameterGroup(Composite parent) {
if (info.getSignature().length == 0) {
return;
}
Group group = new Group(parent, SWT.NONE);
group.setText(Messages.parametersGroupLabel);
GridLayout layout = new GridLayout(2, false);
group.setLayout(layout);
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
for (MBeanParameterInfo signature : info.getSignature()) {
Label label = new Label(group, SWT.NONE);
String type = signature.getType();
if (type.startsWith("[")) {
//$NON-NLS-1$
type = Signature.toString(type);
label.setToolTipText(Messages.enterCommaSeparatedValuesToolTip);
}
int index = type.lastIndexOf('.');
if (index > 0) {
type = type.substring(index + 1);
}
//$NON-NLS-1$
label.setText(type + ":");
if (Boolean.class.getSimpleName().equalsIgnoreCase(type)) {
Combo combo = new Combo(group, SWT.READ_ONLY);
combo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
combo.add(Boolean.TRUE.toString());
combo.add(Boolean.FALSE.toString());
combo.select(0);
controls.put(signature, combo);
} else {
Text text = new Text(group, SWT.BORDER);
text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
text.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
validate();
}
});
controls.put(signature, text);
}
}
}
use of javax.management.MBeanParameterInfo in project tdi-studio-se by Talend.
the class OperationsTab method getValidOperations.
/**
* Gets the valid MBean operations.
*
* @param operations
* @return The valid MBean operations
*/
static MBeanOperationInfo[] getValidOperations(MBeanOperationInfo[] operations) {
List<MBeanOperationInfo> validOperations = new ArrayList<MBeanOperationInfo>();
for (MBeanOperationInfo operation : operations) {
boolean invalid = false;
MBeanParameterInfo[] signature = operation.getSignature();
for (int i = 0; i < signature.length; i++) {
String name = signature[i].getName();
String type = signature[i].getType();
String description = signature[i].getDescription();
if (name == null || type == null || description == null) {
invalid = true;
signature[i] = new MBeanParameterInfo(getNonNull(name), getNonNull(type), getNonNull(description), signature[i].getDescriptor());
}
}
if (invalid) {
operation = new MBeanOperationInfo(operation.getName(), operation.getDescription(), signature, operation.getReturnType(), operation.getImpact(), operation.getDescriptor());
}
validOperations.add(operation);
}
return validOperations.toArray(new MBeanOperationInfo[validOperations.size()]);
}
Aggregations