Search in sources :

Example 1 with InfoPopup

use of org.uberfire.ext.widgets.common.client.common.InfoPopup in project drools-wb by kiegroup.

the class MethodParameterCallValueEditor method showTypeChoice.

protected void showTypeChoice(final Widget w) {
    final FormStylePopup form = new FormStylePopup(TestScenarioAltedImages.INSTANCE.Wizard(), TestScenarioConstants.INSTANCE.FieldValue());
    Button lit = new Button(TestScenarioConstants.INSTANCE.LiteralValue());
    lit.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            methodParameter.nature = FieldData.TYPE_LITERAL;
            methodParameter.value = " ";
            refresh();
            form.hide();
        }
    });
    form.addAttribute(TestScenarioConstants.INSTANCE.LiteralValue() + ":", widgets(lit, new InfoPopup(TestScenarioConstants.INSTANCE.Literal(), TestScenarioConstants.INSTANCE.LiteralValTip())));
    form.addRow(new HTML("<hr/>"));
    form.addRow(new SmallLabel(TestScenarioConstants.INSTANCE.AdvancedSection()));
    /*
         * If there is a bound variable that is the same type of the current
         * variable type, then show a button
         */
    List<String> vars = model.getFactNamesInScope(ex, true);
    for (String v : vars) {
        boolean createButton = false;
        Button variable = new Button(TestScenarioConstants.INSTANCE.BoundVariable());
        FactData factData = (FactData) model.getFactTypes().get(v);
        if (factData.getType().equals(this.parameterType)) {
            createButton = true;
        }
        if (createButton == true) {
            form.addAttribute(TestScenarioConstants.INSTANCE.BoundVariable() + ":", variable);
            variable.addClickHandler(new ClickHandler() {

                public void onClick(ClickEvent event) {
                    methodParameter.nature = FieldData.TYPE_VARIABLE;
                    methodParameter.value = "=";
                    refresh();
                    form.hide();
                }
            });
            break;
        }
    }
    form.show();
}
Also used : SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) Button(org.gwtbootstrap3.client.ui.Button) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FactData(org.drools.workbench.models.testscenarios.shared.FactData) FormStylePopup(org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup) HTML(com.google.gwt.user.client.ui.HTML) InfoPopup(org.uberfire.ext.widgets.common.client.common.InfoPopup)

Example 2 with InfoPopup

use of org.uberfire.ext.widgets.common.client.common.InfoPopup in project drools-wb by kiegroup.

the class TypeChoiceFormPopup method addBoundVariableSelection.

private void addBoundVariableSelection() {
    Button variable = new Button(GuidedRuleEditorResources.CONSTANTS.BoundVariable());
    variable.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent w) {
            fireSelection(FieldData.TYPE_VARIABLE);
        }
    });
    addAttribute(GuidedRuleEditorResources.CONSTANTS.AVariable(), widgets(variable, new InfoPopup(GuidedRuleEditorResources.CONSTANTS.ABoundVariable(), GuidedRuleEditorResources.CONSTANTS.BoundVariableTip())));
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) Button(org.gwtbootstrap3.client.ui.Button) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) InfoPopup(org.uberfire.ext.widgets.common.client.common.InfoPopup)

Example 3 with InfoPopup

use of org.uberfire.ext.widgets.common.client.common.InfoPopup in project drools-wb by kiegroup.

the class MethodParameterValueEditor method showTypeChoice.

protected void showTypeChoice() {
    final FormStylePopup form = new FormStylePopup(GuidedRuleEditorImages508.INSTANCE.Wizard(), GuidedRuleEditorResources.CONSTANTS.FieldValue());
    // Literal values
    Button lit = new Button(GuidedRuleEditorResources.CONSTANTS.LiteralValue());
    lit.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            methodParameter.setNature(FieldNatureType.TYPE_LITERAL);
            methodParameter.setValue("");
            refresh();
            form.hide();
        }
    });
    form.addAttribute(GuidedRuleEditorResources.CONSTANTS.LiteralValue() + ":", widgets(lit, new InfoPopup(GuidedRuleEditorResources.CONSTANTS.Literal(), GuidedRuleEditorResources.CONSTANTS.LiteralValTip())));
    canTheVariableButtonBeShown(new Callback<Boolean>() {

        @Override
        public void callback(Boolean result) {
            if (result) {
                addBoundVariableButton(form);
                form.addRow(new HTML("<hr/>"));
                form.addRow(new SmallLabel(GuidedRuleEditorResources.CONSTANTS.AdvancedSection()));
            }
            // Formulas
            Button formula = new Button(GuidedRuleEditorResources.CONSTANTS.NewFormula());
            formula.addClickHandler(new ClickHandler() {

                public void onClick(ClickEvent event) {
                    methodParameter.setNature(FieldNatureType.TYPE_FORMULA);
                    refresh();
                    form.hide();
                }
            });
            form.addAttribute(GuidedRuleEditorResources.CONSTANTS.AFormula() + ":", widgets(formula, new InfoPopup(GuidedRuleEditorResources.CONSTANTS.AFormula(), GuidedRuleEditorResources.CONSTANTS.FormulaExpressionTip())));
            form.show();
        }
    });
}
Also used : SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) Button(org.gwtbootstrap3.client.ui.Button) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FormStylePopup(org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup) HTML(com.google.gwt.user.client.ui.HTML) InfoPopup(org.uberfire.ext.widgets.common.client.common.InfoPopup)

Example 4 with InfoPopup

use of org.uberfire.ext.widgets.common.client.common.InfoPopup in project drools-wb by kiegroup.

the class PopupCreator method showPatternPopup.

/**
 * This shows a popup allowing you to add field constraints to a pattern
 * (its a popup).
 */
public void showPatternPopup(final FactPattern fp, final SingleFieldConstraint con, final boolean isNested) {
    final String factType = getFactType(fp, con);
    String title = (con == null) ? GuidedRuleEditorResources.CONSTANTS.ModifyConstraintsFor0(fp.getFactType()) : GuidedRuleEditorResources.CONSTANTS.AddSubFieldConstraint();
    final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorImages508.INSTANCE.Wizard(), title);
    final ListBox box = new ListBox();
    box.addItem("...");
    this.oracle.getFieldCompletions(factType, FieldAccessorsAndMutators.ACCESSOR, new Callback<ModelField[]>() {

        @Override
        public void callback(final ModelField[] fields) {
            for (int i = 0; i < fields.length; i++) {
                // You can't use "this" in a nested accessor
                final String fieldName = fields[i].getName();
                if (!isNested || !fieldName.equals(DataType.TYPE_THIS)) {
                    box.addItem(fieldName);
                }
            }
        }
    });
    box.setSelectedIndex(0);
    box.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            String fieldName = box.getItemText(box.getSelectedIndex());
            if ("...".equals(fieldName)) {
                return;
            }
            String fieldType = oracle.getFieldType(factType, fieldName);
            fp.addConstraint(new SingleFieldConstraint(factType, fieldName, fieldType, con));
            modeller.refreshWidget();
            popup.hide();
        }
    });
    popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.AddARestrictionOnAField(), box);
    final ListBox composites = new ListBox();
    composites.addItem("...");
    composites.addItem(GuidedRuleEditorResources.CONSTANTS.AllOfAnd(), CompositeFieldConstraint.COMPOSITE_TYPE_AND);
    composites.addItem(GuidedRuleEditorResources.CONSTANTS.AnyOfOr(), CompositeFieldConstraint.COMPOSITE_TYPE_OR);
    composites.setSelectedIndex(0);
    composites.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            CompositeFieldConstraint comp = new CompositeFieldConstraint();
            comp.setCompositeJunctionType(composites.getValue(composites.getSelectedIndex()));
            fp.addConstraint(comp);
            modeller.refreshWidget();
            popup.hide();
        }
    });
    InfoPopup infoComp = new InfoPopup(GuidedRuleEditorResources.CONSTANTS.MultipleFieldConstraints(), GuidedRuleEditorResources.CONSTANTS.MultipleConstraintsTip1());
    HorizontalPanel horiz = new HorizontalPanel();
    horiz.add(composites);
    horiz.add(infoComp);
    if (con == null) {
        popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.MultipleFieldConstraint(), horiz);
    }
    if (con == null) {
        // NON-NLS
        popup.addRow(new SmallLabel("<i>" + GuidedRuleEditorResources.CONSTANTS.AdvancedOptionsColon() + "</i>"));
        Button predicate = new Button(GuidedRuleEditorResources.CONSTANTS.NewFormula());
        predicate.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                SingleFieldConstraint con = new SingleFieldConstraint();
                con.setConstraintValueType(SingleFieldConstraint.TYPE_PREDICATE);
                fp.addConstraint(con);
                modeller.refreshWidget();
                popup.hide();
            }
        });
        popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.AddANewFormulaStyleExpression(), predicate);
        final Button expressionEditorButton = makeExpressionEditorButton(fp, popup);
        popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.ExpressionEditor(), expressionEditorButton);
        doBindingEditor(popup);
    }
    popup.show();
}
Also used : SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) CompositeFieldConstraint(org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ModelField(org.kie.soup.project.datamodel.oracle.ModelField) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) Button(org.gwtbootstrap3.client.ui.Button) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) FormStylePopup(org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup) InfoPopup(org.uberfire.ext.widgets.common.client.common.InfoPopup) ListBox(org.gwtbootstrap3.client.ui.ListBox)

Example 5 with InfoPopup

use of org.uberfire.ext.widgets.common.client.common.InfoPopup in project drools-wb by kiegroup.

the class PopupCreator method showPatternPopupForComposite.

/**
 * This shows a popup for adding fields to a composite
 */
public void showPatternPopupForComposite(final HasConstraints hasConstraints) {
    final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorImages508.INSTANCE.Wizard(), GuidedRuleEditorResources.CONSTANTS.AddFieldsToThisConstraint());
    final ListBox box = new ListBox();
    box.addItem("...");
    this.oracle.getFieldCompletions(this.pattern.getFactType(), new Callback<ModelField[]>() {

        @Override
        public void callback(final ModelField[] fields) {
            for (int i = 0; i < fields.length; i++) {
                final String fieldName = fields[i].getName();
                box.addItem(fieldName);
            }
        }
    });
    box.setSelectedIndex(0);
    box.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            String factType = pattern.getFactType();
            String fieldName = box.getItemText(box.getSelectedIndex());
            String fieldType = getDataModelOracle().getFieldType(factType, fieldName);
            hasConstraints.addConstraint(new SingleFieldConstraint(factType, fieldName, fieldType, null));
            modeller.refreshWidget();
            popup.hide();
        }
    });
    popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.AddARestrictionOnAField(), box);
    final ListBox composites = new ListBox();
    // NON-NLS
    composites.addItem("...");
    composites.addItem(GuidedRuleEditorResources.CONSTANTS.AllOfAnd(), CompositeFieldConstraint.COMPOSITE_TYPE_AND);
    composites.addItem(GuidedRuleEditorResources.CONSTANTS.AnyOfOr(), CompositeFieldConstraint.COMPOSITE_TYPE_OR);
    composites.setSelectedIndex(0);
    composites.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            CompositeFieldConstraint comp = new CompositeFieldConstraint();
            comp.setCompositeJunctionType(composites.getValue(composites.getSelectedIndex()));
            hasConstraints.addConstraint(comp);
            modeller.refreshWidget();
            popup.hide();
        }
    });
    InfoPopup infoComp = new InfoPopup(GuidedRuleEditorResources.CONSTANTS.MultipleFieldConstraints(), GuidedRuleEditorResources.CONSTANTS.MultipleConstraintsTip());
    HorizontalPanel horiz = new HorizontalPanel();
    horiz.add(composites);
    horiz.add(infoComp);
    popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.MultipleFieldConstraint(), horiz);
    // Include Expression Editor
    popup.addRow(new SmallLabel("<i>" + GuidedRuleEditorResources.CONSTANTS.AdvancedOptionsColon() + "</i>"));
    Button predicate = new Button(GuidedRuleEditorResources.CONSTANTS.NewFormula());
    predicate.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            SingleFieldConstraint con = new SingleFieldConstraint();
            con.setConstraintValueType(SingleFieldConstraint.TYPE_PREDICATE);
            hasConstraints.addConstraint(con);
            modeller.refreshWidget();
            popup.hide();
        }
    });
    popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.AddANewFormulaStyleExpression(), predicate);
    final Button expressionEditorButton = makeExpressionEditorButton(hasConstraints, popup);
    popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.ExpressionEditor(), expressionEditorButton);
    popup.show();
}
Also used : SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) CompositeFieldConstraint(org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ModelField(org.kie.soup.project.datamodel.oracle.ModelField) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) Button(org.gwtbootstrap3.client.ui.Button) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) FormStylePopup(org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup) InfoPopup(org.uberfire.ext.widgets.common.client.common.InfoPopup) ListBox(org.gwtbootstrap3.client.ui.ListBox)

Aggregations

InfoPopup (org.uberfire.ext.widgets.common.client.common.InfoPopup)13 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)9 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)9 Button (org.gwtbootstrap3.client.ui.Button)9 HTML (com.google.gwt.user.client.ui.HTML)5 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)5 SmallLabel (org.uberfire.ext.widgets.common.client.common.SmallLabel)5 FormStylePopup (org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup)5 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)2 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)2 CompositeFieldConstraint (org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint)2 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)2 CheckBox (org.gwtbootstrap3.client.ui.CheckBox)2 ListBox (org.gwtbootstrap3.client.ui.ListBox)2 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)2 IsWidget (com.google.gwt.user.client.ui.IsWidget)1 FactData (org.drools.workbench.models.testscenarios.shared.FactData)1 DirtyableHorizontalPane (org.uberfire.ext.widgets.common.client.common.DirtyableHorizontalPane)1