Search in sources :

Example 1 with OpManager

use of com.haulmont.cuba.core.global.filter.OpManager in project cuba by cuba-platform.

the class DynamicAttributesConditionFrame method fillOperationSelect.

protected void fillOperationSelect(CategoryAttribute categoryAttribute) {
    Class clazz = DynamicAttributesUtils.getAttributeClass(categoryAttribute);
    OpManager opManager = AppBeans.get(OpManager.class);
    EnumSet<Op> availableOps = BooleanUtils.isTrue(categoryAttribute.getIsCollection()) ? opManager.availableOpsForCollectionDynamicAttribute() : opManager.availableOps(clazz);
    List<Op> ops = new LinkedList<>(availableOps);
    operationLookup.setOptionsList(ops);
    Op operator = condition.getOperator();
    if (operator != null) {
        operationLookup.setValue(operator);
    }
}
Also used : Op(com.haulmont.cuba.core.global.filter.Op) MetaClass(com.haulmont.chile.core.model.MetaClass) OpManager(com.haulmont.cuba.core.global.filter.OpManager)

Example 2 with OpManager

use of com.haulmont.cuba.core.global.filter.OpManager in project cuba by cuba-platform.

the class PropertyConditionDescriptor method createCondition.

@Override
public AbstractCondition createCondition() {
    OpManager opManager = AppBeans.get(OpManager.class);
    MetadataTools metadataTools = AppBeans.get(MetadataTools.class);
    PropertyCondition propertyCondition = new PropertyCondition(this, entityAlias, propertiesPath);
    MetaPropertyPath propertyPath = datasourceMetaClass.getPropertyPath(name);
    if (propertyPath == null) {
        throw new IllegalStateException(String.format("Unable to find property '%s' in entity %s", name, datasourceMetaClass));
    }
    MetaClass propertyMetaClass = metadataTools.getPropertyEnclosingMetaClass(propertyPath);
    EnumSet<Op> ops = opManager.availableOps(propertyMetaClass, propertyPath.getMetaProperty());
    propertyCondition.setOperator(ops.iterator().next());
    return propertyCondition;
}
Also used : Op(com.haulmont.cuba.core.global.filter.Op) MetadataTools(com.haulmont.cuba.core.global.MetadataTools) PropertyCondition(com.haulmont.cuba.gui.components.filter.condition.PropertyCondition) MetaClass(com.haulmont.chile.core.model.MetaClass) MetaPropertyPath(com.haulmont.chile.core.model.MetaPropertyPath) OpManager(com.haulmont.cuba.core.global.filter.OpManager)

Example 3 with OpManager

use of com.haulmont.cuba.core.global.filter.OpManager 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)3 Op (com.haulmont.cuba.core.global.filter.Op)3 OpManager (com.haulmont.cuba.core.global.filter.OpManager)3 MetaPropertyPath (com.haulmont.chile.core.model.MetaPropertyPath)2 MetadataTools (com.haulmont.cuba.core.global.MetadataTools)2 PopupButton (com.haulmont.cuba.gui.components.PopupButton)1 PropertyCondition (com.haulmont.cuba.gui.components.filter.condition.PropertyCondition)1 ComponentsFactory (com.haulmont.cuba.gui.xml.layout.ComponentsFactory)1