use of com.haulmont.cuba.web.jmx.entity.ManagedBeanOperationParameter in project cuba by cuba-platform.
the class MbeanInspectWindow method initOperationsLayout.
protected void initOperationsLayout(ManagedBeanInfo mbean) {
BoxLayout container = operations;
for (ManagedBeanOperation op : mbean.getOperations()) {
BoxLayout vl = uiComponents.create(VBoxLayout.class);
vl.setMargin(false, false, true, false);
vl.setSpacing(true);
vl.setStyleName("c-mbeans-operation-container");
Label<String> nameLbl = uiComponents.create(Label.TYPE_DEFAULT);
nameLbl.setValue(convertTypeToReadableName(op.getReturnType()) + " " + op.getName() + "()");
nameLbl.setStyleName("h2");
vl.add(nameLbl);
if (StringUtils.isNotEmpty(op.getDescription())) {
Label<String> descrLbl = uiComponents.create(Label.TYPE_DEFAULT);
descrLbl.setValue(op.getDescription());
vl.add(descrLbl);
}
List<AttributeEditor> attrProviders = new ArrayList<>();
if (!op.getParameters().isEmpty()) {
GridLayout grid = uiComponents.create(GridLayout.class);
grid.setSpacing(true);
grid.setColumns(3);
grid.setRows(op.getParameters().size());
int row = 0;
for (ManagedBeanOperationParameter param : op.getParameters()) {
Label<String> pnameLbl = uiComponents.create(Label.TYPE_DEFAULT);
pnameLbl.setValue(param.getName());
Label<String> ptypeLbl = uiComponents.create(Label.TYPE_DEFAULT);
ptypeLbl.setValue(convertTypeToReadableName(param.getType()));
AttributeEditor prov = new AttributeEditor(frame, param.getType());
attrProviders.add(prov);
Component editField = prov.getComponent();
Component editComposition = editField;
if (StringUtils.isNotBlank(param.getDescription())) {
Label<String> pdescrLbl = uiComponents.create(Label.TYPE_DEFAULT);
pdescrLbl.setValue(param.getDescription());
BoxLayout editorLayout = uiComponents.create(VBoxLayout.class);
editorLayout.add(editField);
editorLayout.add(pdescrLbl);
editComposition = editorLayout;
}
grid.add(pnameLbl, 0, row);
grid.add(ptypeLbl, 1, row);
grid.add(editComposition, 2, row);
row++;
}
vl.add(grid);
}
Button invokeBtn = uiComponents.create(Button.class);
invokeBtn.setAction(new BaseAction("invoke").withCaption(getMessage("mbean.operation.invoke")).withHandler(event -> invokeOperation(op, attrProviders)));
vl.add(invokeBtn);
container.add(vl);
}
if (mbean.getOperations().isEmpty()) {
Label<String> lbl = uiComponents.create(Label.TYPE_DEFAULT);
lbl.setValue(getMessage("mbean.operations.none"));
container.add(lbl);
}
}
Aggregations