Search in sources :

Example 1 with AbstractConditionDescriptor

use of com.haulmont.cuba.gui.components.filter.descriptor.AbstractConditionDescriptor in project cuba by cuba-platform.

the class AddConditionWindow method select.

public void select() {
    Set<Entity> selectedItems = tree.getSelected();
    if (selectedItems.isEmpty()) {
        showNotification(messages.getMainMessage("filter.addCondition.selectCondition"), NotificationType.WARNING);
        return;
    } else {
        for (Entity item : selectedItems) {
            if (item instanceof HeaderConditionDescriptor) {
                showNotification(messages.getMainMessage("filter.addCondition.youSelectedGroup"), NotificationType.WARNING);
                return;
            } else if (isEmbeddedProperty((AbstractConditionDescriptor) item)) {
                showNotification(messages.getMainMessage("filter.addCondition.youSelectedEmbedded"), NotificationType.WARNING);
                return;
            }
        }
    }
    close(COMMIT_ACTION_ID);
}
Also used : Entity(com.haulmont.cuba.core.entity.Entity) AbstractConditionDescriptor(com.haulmont.cuba.gui.components.filter.descriptor.AbstractConditionDescriptor) HeaderConditionDescriptor(com.haulmont.cuba.gui.components.filter.descriptor.HeaderConditionDescriptor)

Example 2 with AbstractConditionDescriptor

use of com.haulmont.cuba.gui.components.filter.descriptor.AbstractConditionDescriptor in project cuba by cuba-platform.

the class AddConditionHelper method _addCondition.

protected void _addCondition(AbstractConditionDescriptor descriptor, ConditionsTree conditionsTree) {
    final AbstractCondition condition = descriptor.createCondition();
    if (descriptor instanceof CustomConditionCreator) {
        WindowInfo windowInfo = windowConfig.getWindowInfo("customConditionEditor");
        Map<String, Object> params = new HashMap<>();
        params.put("condition", condition);
        params.put("conditionsTree", conditionsTree);
        params.put("filter", filter);
        final CustomConditionEditor window = (CustomConditionEditor) windowManager.openWindow(windowInfo, OpenType.DIALOG, params);
        window.addCloseListener(actionId -> {
            if (Window.COMMIT_ACTION_ID.equals(actionId)) {
                handler.handle(condition);
            }
        });
    } else if (descriptor instanceof DynamicAttributesConditionCreator) {
        WindowInfo windowInfo = windowConfig.getWindowInfo("dynamicAttributesConditionEditor");
        Map<String, Object> params = new HashMap<>();
        params.put("condition", condition);
        params.put("filter", filter);
        DynamicAttributesConditionEditor window = (DynamicAttributesConditionEditor) windowManager.openWindow(windowInfo, OpenType.DIALOG, params);
        window.addCloseListener(actionId -> {
            if (Window.COMMIT_ACTION_ID.equals(actionId)) {
                handler.handle(condition);
            }
        });
    } else {
        handler.handle(condition);
    }
}
Also used : CustomConditionCreator(com.haulmont.cuba.gui.components.filter.descriptor.CustomConditionCreator) WindowManager(com.haulmont.cuba.gui.WindowManager) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo) Collection(java.util.Collection) AddConditionWindow(com.haulmont.cuba.gui.components.filter.addcondition.AddConditionWindow) HashMap(java.util.HashMap) AbstractCondition(com.haulmont.cuba.gui.components.filter.condition.AbstractCondition) AppBeans(com.haulmont.cuba.core.global.AppBeans) CustomConditionEditor(com.haulmont.cuba.gui.components.filter.edit.CustomConditionEditor) ConditionDescriptorsTreeBuilderAPI(com.haulmont.cuba.gui.components.filter.addcondition.ConditionDescriptorsTreeBuilderAPI) AbstractConditionDescriptor(com.haulmont.cuba.gui.components.filter.descriptor.AbstractConditionDescriptor) Window(com.haulmont.cuba.gui.components.Window) DynamicAttributesConditionCreator(com.haulmont.cuba.gui.components.filter.descriptor.DynamicAttributesConditionCreator) Configuration(com.haulmont.cuba.core.global.Configuration) WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) DynamicAttributesConditionEditor(com.haulmont.cuba.gui.components.filter.edit.DynamicAttributesConditionEditor) Tree(com.haulmont.bali.datastruct.Tree) Map(java.util.Map) ClientConfig(com.haulmont.cuba.client.ClientConfig) WindowManagerProvider(com.haulmont.cuba.gui.WindowManagerProvider) Filter(com.haulmont.cuba.gui.components.Filter) OpenType(com.haulmont.cuba.gui.WindowManager.OpenType) CustomConditionEditor(com.haulmont.cuba.gui.components.filter.edit.CustomConditionEditor) CustomConditionCreator(com.haulmont.cuba.gui.components.filter.descriptor.CustomConditionCreator) HashMap(java.util.HashMap) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo) DynamicAttributesConditionEditor(com.haulmont.cuba.gui.components.filter.edit.DynamicAttributesConditionEditor) DynamicAttributesConditionCreator(com.haulmont.cuba.gui.components.filter.descriptor.DynamicAttributesConditionCreator) AbstractCondition(com.haulmont.cuba.gui.components.filter.condition.AbstractCondition) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with AbstractConditionDescriptor

use of com.haulmont.cuba.gui.components.filter.descriptor.AbstractConditionDescriptor in project cuba by cuba-platform.

the class AddConditionHelper method addCondition.

/**
 * Opens AddCondition window. When condition is selected/created a {@code Handler#handle} method will be called
 *
 * @param conditionsTree conditions tree is necessary for custom condition editing. It is used for suggestion of
 *                       other component names in 'param where' field.
 */
public void addCondition(final ConditionsTree conditionsTree) {
    Map<String, Object> params = new HashMap<>();
    ConditionDescriptorsTreeBuilderAPI descriptorsTreeBuilder = AppBeans.getPrototype(ConditionDescriptorsTreeBuilderAPI.NAME, filter, clientConfig.getGenericFilterPropertiesHierarchyDepth(), hideDynamicAttributes, hideCustomConditions, conditionsTree);
    Tree<AbstractConditionDescriptor> descriptorsTree = descriptorsTreeBuilder.build();
    params.put("descriptorsTree", descriptorsTree);
    WindowInfo windowInfo = windowConfig.getWindowInfo("addCondition");
    AddConditionWindow window = (AddConditionWindow) windowManager.openWindow(windowInfo, OpenType.DIALOG, params);
    window.addCloseListener(actionId -> {
        if (Window.COMMIT_ACTION_ID.equals(actionId)) {
            Collection<AbstractConditionDescriptor> descriptors = window.getDescriptors();
            if (descriptors != null) {
                for (AbstractConditionDescriptor descriptor : descriptors) {
                    _addCondition(descriptor, conditionsTree);
                }
            }
        }
    });
}
Also used : AbstractConditionDescriptor(com.haulmont.cuba.gui.components.filter.descriptor.AbstractConditionDescriptor) HashMap(java.util.HashMap) AddConditionWindow(com.haulmont.cuba.gui.components.filter.addcondition.AddConditionWindow) ConditionDescriptorsTreeBuilderAPI(com.haulmont.cuba.gui.components.filter.addcondition.ConditionDescriptorsTreeBuilderAPI) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Aggregations

AbstractConditionDescriptor (com.haulmont.cuba.gui.components.filter.descriptor.AbstractConditionDescriptor)3 AddConditionWindow (com.haulmont.cuba.gui.components.filter.addcondition.AddConditionWindow)2 ConditionDescriptorsTreeBuilderAPI (com.haulmont.cuba.gui.components.filter.addcondition.ConditionDescriptorsTreeBuilderAPI)2 WindowInfo (com.haulmont.cuba.gui.config.WindowInfo)2 HashMap (java.util.HashMap)2 Tree (com.haulmont.bali.datastruct.Tree)1 ClientConfig (com.haulmont.cuba.client.ClientConfig)1 Entity (com.haulmont.cuba.core.entity.Entity)1 AppBeans (com.haulmont.cuba.core.global.AppBeans)1 Configuration (com.haulmont.cuba.core.global.Configuration)1 WindowManager (com.haulmont.cuba.gui.WindowManager)1 OpenType (com.haulmont.cuba.gui.WindowManager.OpenType)1 WindowManagerProvider (com.haulmont.cuba.gui.WindowManagerProvider)1 Filter (com.haulmont.cuba.gui.components.Filter)1 Window (com.haulmont.cuba.gui.components.Window)1 AbstractCondition (com.haulmont.cuba.gui.components.filter.condition.AbstractCondition)1 CustomConditionCreator (com.haulmont.cuba.gui.components.filter.descriptor.CustomConditionCreator)1 DynamicAttributesConditionCreator (com.haulmont.cuba.gui.components.filter.descriptor.DynamicAttributesConditionCreator)1 HeaderConditionDescriptor (com.haulmont.cuba.gui.components.filter.descriptor.HeaderConditionDescriptor)1 CustomConditionEditor (com.haulmont.cuba.gui.components.filter.edit.CustomConditionEditor)1