Search in sources :

Example 16 with Button

use of org.gwtbootstrap3.client.ui.Button 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)

Example 17 with Button

use of org.gwtbootstrap3.client.ui.Button 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 18 with Button

use of org.gwtbootstrap3.client.ui.Button in project drools-wb by kiegroup.

the class ActionInsertFactWidget method showAddFieldPopup.

protected void showAddFieldPopup(Widget w) {
    final AsyncPackageDataModelOracle oracle = this.getModeller().getDataModelOracle();
    final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorImages508.INSTANCE.Wizard(), GuidedRuleEditorResources.CONSTANTS.AddAField());
    final ListBox box = new ListBox();
    box.addItem("...");
    final ModelField[] availableFieldCompletions = ModelFieldUtil.getAvailableFieldCompletions(fieldCompletions, model);
    final boolean isEnabled = !isReadOnly() && availableFieldCompletions.length > 0;
    if (availableFieldCompletions.length > 0) {
        for (int i = 0; i < availableFieldCompletions.length; i++) {
            box.addItem(availableFieldCompletions[i].getName());
        }
    }
    box.setSelectedIndex(0);
    popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.AddField(), box);
    box.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            String fieldName = box.getItemText(box.getSelectedIndex());
            String fieldType = oracle.getFieldType(model.getFactType(), fieldName);
            model.addFieldValue(new ActionFieldValue(fieldName, "", fieldType));
            setModified(true);
            getModeller().refreshWidget();
            popup.hide();
        }
    });
    /*
         * Propose a textBox to the user to make him set a variable name
         */
    final HorizontalPanel vn = new HorizontalPanel();
    final TextBox varName = new TextBox();
    if (this.model.getBoundName() != null) {
        varName.setText(this.model.getBoundName());
    }
    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 (getModeller().isVariableNameUsed(var) && ((model.getBoundName() != null && model.getBoundName().equals(var) == false) || model.getBoundName() == null)) {
                Window.alert(GuidedRuleEditorResources.CONSTANTS.TheVariableName0IsAlreadyTaken(var));
                return;
            }
            model.setBoundName(var);
            setModified(true);
            getModeller().refreshWidget();
            popup.hide();
        }
    });
    popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.BoundVariable(), vn);
    box.setEnabled(isEnabled);
    varName.setEnabled(isEnabled);
    ok.setEnabled(isEnabled);
    popup.show();
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) TextBox(org.gwtbootstrap3.client.ui.TextBox) 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) ActionFieldValue(org.drools.workbench.models.datamodel.rule.ActionFieldValue) Button(org.gwtbootstrap3.client.ui.Button) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) FormStylePopup(org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup) ListBox(org.gwtbootstrap3.client.ui.ListBox)

Example 19 with Button

use of org.gwtbootstrap3.client.ui.Button in project drools-wb by kiegroup.

the class ExpressionBuilder method showBindingPopUp.

private void showBindingPopUp() {
    final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorResources.CONSTANTS.ExpressionEditor());
    final TextBox varName = new TextBox();
    if (expression.isBound()) {
        varName.setText(expression.getBinding());
    }
    popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.BindTheExpressionToAVariable(), new InputGroup() {

        {
            add(varName);
            add(new InputGroupButton() {

                {
                    add(new Button(HumanReadableConstants.INSTANCE.Set()) {

                        {
                            addClickHandler(new ClickHandler() {

                                public void onClick(ClickEvent event) {
                                    String var = varName.getText();
                                    if (getModeller().isVariableNameUsed(var)) {
                                        Window.alert(GuidedRuleEditorResources.CONSTANTS.TheVariableName0IsAlreadyTaken(var));
                                        return;
                                    }
                                    expression.setBinding(var);
                                    getModeller().refreshWidget();
                                    popup.hide();
                                }
                            });
                        }
                    });
                }
            });
        }
    });
    popup.show();
}
Also used : InputGroup(org.gwtbootstrap3.client.ui.InputGroup) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) InputGroupButton(org.gwtbootstrap3.client.ui.InputGroupButton) Button(org.gwtbootstrap3.client.ui.Button) InputGroupButton(org.gwtbootstrap3.client.ui.InputGroupButton) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FormStylePopup(org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup) TextBox(org.gwtbootstrap3.client.ui.TextBox)

Example 20 with Button

use of org.gwtbootstrap3.client.ui.Button in project drools-wb by kiegroup.

the class GuidedScoreCardEditor method getCharacteristics.

private Widget getCharacteristics() {
    characteristicsPanel = new VerticalPanel();
    characteristicsTables = new ArrayList<FlexTable>();
    final HorizontalPanel toolbar = new HorizontalPanel();
    btnAddCharacteristic = new Button(GuidedScoreCardConstants.INSTANCE.addCharacteristic(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            addCharacteristic(null);
        }
    });
    toolbar.add(btnAddCharacteristic);
    toolbar.setHeight("24");
    characteristicsPanel.add(toolbar);
    final SimplePanel gapPanel = new SimplePanel();
    gapPanel.add(new HTML("<br/>"));
    characteristicsPanel.add(gapPanel);
    return characteristicsPanel;
}
Also used : VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) Button(org.gwtbootstrap3.client.ui.Button) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FlexTable(com.google.gwt.user.client.ui.FlexTable) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) SimplePanel(com.google.gwt.user.client.ui.SimplePanel) HTML(com.google.gwt.user.client.ui.HTML)

Aggregations

Button (org.gwtbootstrap3.client.ui.Button)71 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)33 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)33 FormStylePopup (org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup)14 SmallLabel (org.uberfire.ext.widgets.common.client.common.SmallLabel)12 HTML (com.google.gwt.user.client.ui.HTML)10 ListBox (org.gwtbootstrap3.client.ui.ListBox)10 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)9 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)9 InfoPopup (org.uberfire.ext.widgets.common.client.common.InfoPopup)9 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)7 TextBox (org.gwtbootstrap3.client.ui.TextBox)6 MenuItem (org.uberfire.workbench.model.menu.MenuItem)6 IsWidget (com.google.gwt.user.client.ui.IsWidget)5 Widget (com.google.gwt.user.client.ui.Widget)5 AnchorListItem (org.gwtbootstrap3.client.ui.AnchorListItem)5 ButtonGroup (org.gwtbootstrap3.client.ui.ButtonGroup)5 FlexTable (com.google.gwt.user.client.ui.FlexTable)4 ApplicationScoped (javax.enterprise.context.ApplicationScoped)4 Inject (javax.inject.Inject)4