Search in sources :

Example 1 with HtmlCommandButton

use of javax.faces.component.html.HtmlCommandButton in project gdmatrix by gdmatrix.

the class QueryInstanceBean method addPredicateComponents.

private void addPredicateComponents(Predicate predicate, HtmlPanelGroup exprPanelGroup) {
    FacesContext context = FacesContext.getCurrentInstance();
    Application application = context.getApplication();
    exprPanelGroup.setStyleClass("expression predicate");
    addLabelComponents(predicate.getLabel(), "expressions['" + predicate.getId() + "'].parameterValuesMap", predicate.getParameters(), exprPanelGroup);
    id++;
    HtmlCommandButton button = new HtmlCommandButton();
    button.setId("button_" + id);
    MethodBinding method = application.createMethodBinding("#{queryInstanceBean.expressionWrappers['" + predicate.getId() + "'].removeExpression}", new Class[0]);
    button.setAction(method);
    button.setImage("/common/misc/images/remove_expr.png");
    button.setStyleClass("expr_button remove");
    exprPanelGroup.getChildren().add(button);
}
Also used : FacesContext(javax.faces.context.FacesContext) MethodBinding(javax.faces.el.MethodBinding) HtmlCommandButton(javax.faces.component.html.HtmlCommandButton) Application(javax.faces.application.Application)

Example 2 with HtmlCommandButton

use of javax.faces.component.html.HtmlCommandButton in project gdmatrix by gdmatrix.

the class QueryInstanceBean method addOperatorComponents.

private void addOperatorComponents(Operator operator, HtmlPanelGroup exprPanelGroup) {
    FacesContext context = FacesContext.getCurrentInstance();
    Application application = context.getApplication();
    ValueBinding valueBinding = context.getApplication().createValueBinding("expression #{queryInstanceBean.expressions['" + operator.getId() + "'].type}");
    exprPanelGroup.setValueBinding("styleClass", valueBinding);
    if (operator.getType().equals(Operator.ROOT)) {
        addLabelComponents(selectedInstance.getQuery().getLabel(), "selectedInstance.globalParameterValuesMap", selectedInstance.getQuery().getGlobalParameters(), exprPanelGroup);
    } else // other operators: and, or, nor
    {
        // add operator select box
        id++;
        HtmlSelectOneMenu selectMenu = new HtmlSelectOneMenu();
        selectMenu.setId(operator.getType() + "_" + id);
        selectMenu.setStyleClass("operator");
        selectMenu.setOnchange("submit();");
        String valueExpr = "#{queryInstanceBean.expressions['" + operator.getId() + "'].type}";
        valueBinding = context.getApplication().createValueBinding(valueExpr);
        selectMenu.setValueBinding("value", valueBinding);
        ArrayList list = new ArrayList();
        SelectItem item1 = new SelectItem();
        item1.setDescription(Operator.AND);
        item1.setValue(Operator.AND);
        item1.setLabel(getQueryLabel(Operator.AND));
        list.add(item1);
        SelectItem item2 = new SelectItem();
        item2.setDescription(Operator.OR);
        item2.setValue(Operator.OR);
        item2.setLabel(getQueryLabel(Operator.OR));
        list.add(item2);
        SelectItem item3 = new SelectItem();
        item3.setDescription(Operator.NOR);
        item3.setValue(Operator.NOR);
        item3.setLabel(getQueryLabel(Operator.NOR));
        list.add(item3);
        id++;
        UISelectItems selectItems = new UISelectItems();
        selectItems.setId("si_" + id);
        selectItems.setValue(list);
        selectMenu.getChildren().add(selectItems);
        exprPanelGroup.getChildren().add(selectMenu);
        id++;
        HtmlCommandButton button = new HtmlCommandButton();
        button.setId("button_" + id);
        MethodBinding method = application.createMethodBinding("#{queryInstanceBean.expressionWrappers['" + operator.getId() + "'].removeExpression}", new Class[0]);
        button.setAction(method);
        button.setImage("/common/misc/images/remove_expr.png");
        button.setStyleClass("expr_button remove");
        exprPanelGroup.getChildren().add(button);
    }
    id++;
    HtmlPanelGroup subPanelGroup = new HtmlPanelGroup();
    subPanelGroup.setId("comp_" + id);
    subPanelGroup.setStyleClass("op_children");
    exprPanelGroup.getChildren().add(subPanelGroup);
    for (Expression expr : operator.getArguments()) {
        addExpressionComponents(expr, subPanelGroup);
        if (!operator.getType().equals(Operator.ROOT)) {
            id++;
            HtmlOutputText linkText = new HtmlOutputText();
            linkText.setId("link_" + id);
            valueBinding = application.createValueBinding("#{queryInstanceBean.expressionWrappers['" + operator.getId() + "'].linkLabel}");
            linkText.setValueBinding("value", valueBinding);
            linkText.setStyleClass("operator_link");
            subPanelGroup.getChildren().add(linkText);
        }
    }
    if (operator.equals(selectedExpression)) {
        addExpressionList(context, subPanelGroup);
    } else {
        id++;
        HtmlCommandButton button = new HtmlCommandButton();
        button.setId("button_" + id);
        MethodBinding method = application.createMethodBinding("#{queryInstanceBean.expressionWrappers['" + operator.getId() + "'].selectExpression}", new Class[0]);
        button.setAction(method);
        button.setImage("/common/misc/images/add_expr.png");
        button.setStyleClass("expr_button add");
        ValueBinding value = application.createValueBinding("#{queryInstanceBean.expressionWrappers['" + operator.getId() + "'].addButtonRendered}");
        button.setValueBinding("rendered", value);
        subPanelGroup.getChildren().add(button);
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) UISelectItems(javax.faces.component.UISelectItems) ValueBinding(javax.faces.el.ValueBinding) ArrayList(java.util.ArrayList) HtmlSelectOneMenu(javax.faces.component.html.HtmlSelectOneMenu) HtmlCommandButton(javax.faces.component.html.HtmlCommandButton) Expression(org.santfeliu.misc.query.QueryInstance.Expression) SelectItem(javax.faces.model.SelectItem) MethodBinding(javax.faces.el.MethodBinding) HtmlPanelGroup(org.apache.myfaces.component.html.ext.HtmlPanelGroup) HtmlOutputText(javax.faces.component.html.HtmlOutputText) Application(javax.faces.application.Application)

Example 3 with HtmlCommandButton

use of javax.faces.component.html.HtmlCommandButton in project gdmatrix by gdmatrix.

the class QueryInstanceBean method addExpressionList.

private void addExpressionList(FacesContext context, HtmlPanelGroup subPanelGroup) {
    id++;
    HtmlDataList dataList = new HtmlDataList();
    dataList.setId("data_list_" + id);
    dataList.setVar("expression");
    dataList.setLayout("unorderedList");
    dataList.setStyleClass("data_list");
    ArrayList list = new ArrayList();
    list.add(OPERATOR_PREFIX + Operator.AND);
    list.add(OPERATOR_PREFIX + Operator.OR);
    list.add(OPERATOR_PREFIX + Operator.NOR);
    List<Query.Predicate> predicates = getQuery().getPredicates();
    for (Query.Predicate predicate : predicates) {
        list.add(predicate.getName());
    }
    dataList.setValue(list);
    subPanelGroup.getChildren().add(dataList);
    id++;
    HtmlCommandLink link = new HtmlCommandLink();
    link.setId("expr_link_" + id);
    Application application = context.getApplication();
    MethodBinding method = application.createMethodBinding("#{queryInstanceBean.addExpression}", new Class[0]);
    link.setAction(method);
    ValueBinding valueBinding = application.createValueBinding("#{queryInstanceBean.expressionLabel}");
    link.setValueBinding("value", valueBinding);
    link.setStyleClass("expr_option");
    dataList.getChildren().add(link);
    id++;
    HtmlCommandButton cancelButton = new HtmlCommandButton();
    cancelButton.setId("cancel_link_" + id);
    method = context.getApplication().createMethodBinding("#{queryInstanceBean.cancel}", new Class[0]);
    cancelButton.setAction(method);
    valueBinding = application.createValueBinding("#{objectBundle.cancel}");
    cancelButton.setValueBinding("value", valueBinding);
    cancelButton.setStyleClass("big_button");
    subPanelGroup.getChildren().add(cancelButton);
}
Also used : Query(org.santfeliu.misc.query.Query) HtmlDataList(org.apache.myfaces.custom.datalist.HtmlDataList) HtmlCommandLink(javax.faces.component.html.HtmlCommandLink) ValueBinding(javax.faces.el.ValueBinding) ArrayList(java.util.ArrayList) MethodBinding(javax.faces.el.MethodBinding) HtmlCommandButton(javax.faces.component.html.HtmlCommandButton) Application(javax.faces.application.Application) Predicate(org.santfeliu.misc.query.QueryInstance.Predicate)

Aggregations

Application (javax.faces.application.Application)3 HtmlCommandButton (javax.faces.component.html.HtmlCommandButton)3 MethodBinding (javax.faces.el.MethodBinding)3 ArrayList (java.util.ArrayList)2 FacesContext (javax.faces.context.FacesContext)2 ValueBinding (javax.faces.el.ValueBinding)2 UISelectItems (javax.faces.component.UISelectItems)1 HtmlCommandLink (javax.faces.component.html.HtmlCommandLink)1 HtmlOutputText (javax.faces.component.html.HtmlOutputText)1 HtmlSelectOneMenu (javax.faces.component.html.HtmlSelectOneMenu)1 SelectItem (javax.faces.model.SelectItem)1 HtmlPanelGroup (org.apache.myfaces.component.html.ext.HtmlPanelGroup)1 HtmlDataList (org.apache.myfaces.custom.datalist.HtmlDataList)1 Query (org.santfeliu.misc.query.Query)1 Expression (org.santfeliu.misc.query.QueryInstance.Expression)1 Predicate (org.santfeliu.misc.query.QueryInstance.Predicate)1