Search in sources :

Example 1 with AttributeEditor

use of com.haulmont.cuba.web.app.ui.jmxcontrol.util.AttributeEditor in project cuba by cuba-platform.

the class MbeanInspectWindow method initOperationsLayout.

protected void initOperationsLayout(ManagedBeanInfo mbean) {
    BoxLayout container = operations;
    for (final ManagedBeanOperation op : mbean.getOperations()) {
        BoxLayout vl = componentsFactory.createComponent(VBoxLayout.class);
        vl.setMargin(false, false, true, false);
        vl.setSpacing(true);
        vl.setStyleName("c-mbeans-operation-container");
        Label nameLbl = componentsFactory.createComponent(Label.class);
        nameLbl.setValue(AttributeHelper.convertTypeToReadableName(op.getReturnType()) + " " + op.getName() + "()");
        nameLbl.setStyleName("h2");
        vl.add(nameLbl);
        if (StringUtils.isNotEmpty(op.getDescription())) {
            Label descrLbl = componentsFactory.createComponent(Label.class);
            descrLbl.setValue(op.getDescription());
            vl.add(descrLbl);
        }
        final List<AttributeEditor> attrProviders = new ArrayList<>();
        if (!op.getParameters().isEmpty()) {
            GridLayout grid = componentsFactory.createComponent(GridLayout.class);
            grid.setSpacing(true);
            grid.setColumns(3);
            grid.setRows(op.getParameters().size());
            int row = 0;
            for (ManagedBeanOperationParameter param : op.getParameters()) {
                Label pnameLbl = componentsFactory.createComponent(Label.class);
                pnameLbl.setValue(param.getName());
                Label ptypeLbl = componentsFactory.createComponent(Label.class);
                ptypeLbl.setValue(AttributeHelper.convertTypeToReadableName(param.getType()));
                AttributeEditor prov = new AttributeEditor(this, param.getType());
                attrProviders.add(prov);
                Component editField = prov.getComponent();
                Component editComposition = editField;
                if (StringUtils.isNotBlank(param.getDescription())) {
                    Label pdescrLbl = componentsFactory.createComponent(Label.class);
                    pdescrLbl.setValue(param.getDescription());
                    BoxLayout editorLayout = componentsFactory.createComponent(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 = componentsFactory.createComponent(Button.class);
        invokeBtn.setAction(new AbstractAction("invoke") {

            @Override
            public void actionPerform(Component component) {
                invokeOperation(op, attrProviders);
            }

            @Override
            public String getCaption() {
                return getMessage("mbean.operation.invoke");
            }
        });
        vl.add(invokeBtn);
        container.add(vl);
    }
    if (mbean.getOperations().isEmpty()) {
        Label lbl = componentsFactory.createComponent(Label.class);
        lbl.setValue(getMessage("mbean.operations.none"));
        container.add(lbl);
    }
}
Also used : AttributeEditor(com.haulmont.cuba.web.app.ui.jmxcontrol.util.AttributeEditor)

Example 2 with AttributeEditor

use of com.haulmont.cuba.web.app.ui.jmxcontrol.util.AttributeEditor in project cuba by cuba-platform.

the class AttributeEditWindow method postInit.

@Override
protected void postInit() {
    ManagedBeanAttribute mba = getItem();
    final String type = mba.getType();
    valueHolder = new AttributeEditor(this, type, mba.getValue(), true, true);
    valueContainer.add(valueHolder.getComponent(), 1, 0);
    if (mba.getName() != null) {
        setCaption(formatMessage("editAttribute.title.format", mba.getName()));
    }
}
Also used : ManagedBeanAttribute(com.haulmont.cuba.web.jmx.entity.ManagedBeanAttribute) AttributeEditor(com.haulmont.cuba.web.app.ui.jmxcontrol.util.AttributeEditor)

Aggregations

AttributeEditor (com.haulmont.cuba.web.app.ui.jmxcontrol.util.AttributeEditor)2 ManagedBeanAttribute (com.haulmont.cuba.web.jmx.entity.ManagedBeanAttribute)1