Search in sources :

Example 1 with PopupButton

use of com.haulmont.cuba.gui.components.PopupButton in project cuba by cuba-platform.

the class PropertyOperationEditor method createComponent.

@Override
protected Component createComponent() {
    OpManager opManager = AppBeans.get(OpManager.class);
    MetadataTools metadataTools = AppBeans.get(MetadataTools.class);
    componentsFactory = AppBeans.get(ComponentsFactory.class);
    popupButton = componentsFactory.createComponent(PopupButton.class);
    MetaClass metaClass = condition.getEntityMetaClass();
    MetaPropertyPath propertyPath = metaClass.getPropertyPath(condition.getName());
    if (propertyPath == null) {
        throw new IllegalStateException(String.format("Unable to find property '%s' in entity %s", condition.getName(), metaClass));
    }
    MetaClass propertyMetaClass = metadataTools.getPropertyEnclosingMetaClass(propertyPath);
    for (Op op : opManager.availableOps(propertyMetaClass, propertyPath.getMetaProperty())) {
        OperatorChangeAction operatorChangeAction = new OperatorChangeAction(op);
        popupButton.addAction(operatorChangeAction);
    }
    popupButton.setCaption(condition.getOperator().getLocCaption());
    popupButton.setStyleName("condition-operation-button");
    return popupButton;
}
Also used : ComponentsFactory(com.haulmont.cuba.gui.xml.layout.ComponentsFactory) Op(com.haulmont.cuba.core.global.filter.Op) MetadataTools(com.haulmont.cuba.core.global.MetadataTools) PopupButton(com.haulmont.cuba.gui.components.PopupButton) MetaClass(com.haulmont.chile.core.model.MetaClass) MetaPropertyPath(com.haulmont.chile.core.model.MetaPropertyPath) OpManager(com.haulmont.cuba.core.global.filter.OpManager)

Aggregations

MetaClass (com.haulmont.chile.core.model.MetaClass)1 MetaPropertyPath (com.haulmont.chile.core.model.MetaPropertyPath)1 MetadataTools (com.haulmont.cuba.core.global.MetadataTools)1 Op (com.haulmont.cuba.core.global.filter.Op)1 OpManager (com.haulmont.cuba.core.global.filter.OpManager)1 PopupButton (com.haulmont.cuba.gui.components.PopupButton)1 ComponentsFactory (com.haulmont.cuba.gui.xml.layout.ComponentsFactory)1