Search in sources :

Example 1 with BindingTextBox

use of org.kie.workbench.common.widgets.client.widget.BindingTextBox in project drools-wb by kiegroup.

the class PopupCreator method doBindingEditor.

/**
 * This adds in (optionally) the editor for changing the bound variable
 * name. If its a bindable pattern, it will show the editor, if it is
 * already bound, and the name is used, it should not be editable.
 */
private void doBindingEditor(final FormStylePopup popup) {
    if (bindable || !(modeller.getModel().isBoundFactUsed(pattern.getBoundName()))) {
        HorizontalPanel varName = new HorizontalPanel();
        final TextBox varTxt = new BindingTextBox();
        if (pattern.getBoundName() == null) {
            varTxt.setText("");
        } else {
            varTxt.setText(pattern.getBoundName());
        }
        ((InputElement) varTxt.getElement().cast()).setSize(6);
        varName.add(varTxt);
        Button bindVar = new Button(HumanReadableConstants.INSTANCE.Set());
        bindVar.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                String var = varTxt.getText();
                if (modeller.isVariableNameUsed(var)) {
                    Window.alert(GuidedRuleEditorResources.CONSTANTS.TheVariableName0IsAlreadyTaken(var));
                    return;
                }
                pattern.setBoundName(varTxt.getText());
                modeller.refreshWidget();
                popup.hide();
            }
        });
        varName.add(bindVar);
        popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.VariableName(), varName);
    }
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) BindingTextBox(org.kie.workbench.common.widgets.client.widget.BindingTextBox) Button(org.gwtbootstrap3.client.ui.Button) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) BindingTextBox(org.kie.workbench.common.widgets.client.widget.BindingTextBox) TextBox(org.gwtbootstrap3.client.ui.TextBox) InputElement(com.google.gwt.dom.client.InputElement)

Example 2 with BindingTextBox

use of org.kie.workbench.common.widgets.client.widget.BindingTextBox in project drools-wb by kiegroup.

the class FieldPage method newBindingTextBox.

TextBox newBindingTextBox() {
    final BindingTextBox bindingTextBox = GWT.create(BindingTextBox.class);
    bindingTextBox.setText(plugin().getBinding());
    bindingTextBox.addKeyUpHandler(event -> {
        plugin().setBinding(bindingTextBox.getText());
    });
    return bindingTextBox;
}
Also used : BindingTextBox(org.kie.workbench.common.widgets.client.widget.BindingTextBox)

Example 3 with BindingTextBox

use of org.kie.workbench.common.widgets.client.widget.BindingTextBox in project drools-wb by kiegroup.

the class PopupCreator method showBindFieldPopup.

/**
 * Display a little editor for field bindings.
 */
public void showBindFieldPopup(final FactPattern fp, final SingleFieldConstraint con, final ModelField[] fields, final PopupCreator popupCreator) {
    final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorResources.CONSTANTS.AddAField());
    // popup.setWidth( 500 + "px" );
    // popup.setHeight( 100 + "px" );
    final HorizontalPanel vn = new HorizontalPanel();
    final TextBox varName = new BindingTextBox();
    if (con.getFieldBinding() != null) {
        varName.setText(con.getFieldBinding());
    }
    final Button ok = new Button(HumanReadableConstants.INSTANCE.Set());
    vn.add(varName);
    vn.add(ok);
    ok.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            String var = varName.getText();
            if (modeller.isVariableNameUsed(var)) {
                Window.alert(GuidedRuleEditorResources.CONSTANTS.TheVariableName0IsAlreadyTaken(var));
                return;
            }
            con.setFieldBinding(var);
            modeller.refreshWidget();
            popup.hide();
        }
    });
    popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.BindTheFieldCalled0ToAVariable(con.getFieldName()), vn);
    // Show the sub-field selector is there are applicable sub-fields
    if (hasApplicableFields(fields)) {
        Button sub = new Button(GuidedRuleEditorResources.CONSTANTS.ShowSubFields());
        popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.ApplyAConstraintToASubFieldOf0(con.getFieldName()), sub);
        sub.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                popup.hide();
                popupCreator.showPatternPopup(fp, con, true);
            }
        });
    }
    popup.show();
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) BindingTextBox(org.kie.workbench.common.widgets.client.widget.BindingTextBox) Button(org.gwtbootstrap3.client.ui.Button) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) FormStylePopup(org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup) BindingTextBox(org.kie.workbench.common.widgets.client.widget.BindingTextBox) TextBox(org.gwtbootstrap3.client.ui.TextBox)

Aggregations

BindingTextBox (org.kie.workbench.common.widgets.client.widget.BindingTextBox)3 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)2 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)2 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)2 Button (org.gwtbootstrap3.client.ui.Button)2 TextBox (org.gwtbootstrap3.client.ui.TextBox)2 InputElement (com.google.gwt.dom.client.InputElement)1 FormStylePopup (org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup)1