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);
}
}
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;
}
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;
}
Aggregations