Search in sources :

Example 31 with HorizontalPanel

use of com.google.gwt.user.client.ui.HorizontalPanel 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 32 with HorizontalPanel

use of com.google.gwt.user.client.ui.HorizontalPanel in project drools-wb by kiegroup.

the class RuleModellerActionSelectorPopup method getContent.

@Override
public Widget getContent() {
    if (position == null) {
        positionCbo.addItem(GuidedRuleEditorResources.CONSTANTS.Bottom(), String.valueOf(this.model.rhs.length));
        positionCbo.addItem(GuidedRuleEditorResources.CONSTANTS.Top(), "0");
        for (int i = 1; i < model.rhs.length; i++) {
            positionCbo.addItem(GuidedRuleEditorResources.CONSTANTS.Line0(i), String.valueOf(i));
        }
    } else {
        // if position is fixed, we just add one element to the drop down.
        positionCbo.addItem(String.valueOf(position));
        positionCbo.setSelectedIndex(0);
    }
    if (oracle.getDSLConditions().size() == 0 && oracle.getFactTypes().length == 0) {
        layoutPanel.addRow(new HTML("<div class='highlight'>" + GuidedRuleEditorResources.CONSTANTS.NoModelTip() + "</div>"));
    }
    // only show the drop down if we are not using fixed position.
    if (position == null) {
        HorizontalPanel hp0 = new HorizontalPanel();
        hp0.add(new HTML(GuidedRuleEditorResources.CONSTANTS.PositionColon()));
        hp0.add(positionCbo);
        hp0.add(new InfoPopup(GuidedRuleEditorResources.CONSTANTS.PositionColon(), GuidedRuleEditorResources.CONSTANTS.ActionPositionExplanation()));
        layoutPanel.addRow(hp0);
        layoutPanel.addRow(new HTML("<hr/>"));
    }
    choices = makeChoicesListBox();
    choicesPanel.add(choices);
    layoutPanel.addRow(choicesPanel);
    // DSL might be prohibited (e.g. editing a DRL file. Only DSLR files can contain DSL)
    if (ruleModeller.isDSLEnabled()) {
        CheckBox chkOnlyDisplayDSLConditions = new CheckBox();
        chkOnlyDisplayDSLConditions.setText(GuidedRuleEditorResources.CONSTANTS.OnlyDisplayDSLActions());
        chkOnlyDisplayDSLConditions.setValue(onlyShowDSLStatements);
        chkOnlyDisplayDSLConditions.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

            public void onValueChange(ValueChangeEvent<Boolean> event) {
                onlyShowDSLStatements = event.getValue();
                choicesPanel.setWidget(makeChoicesListBox());
            }
        });
        layoutPanel.addRow(chkOnlyDisplayDSLConditions);
    }
    return layoutPanel;
}
Also used : CheckBox(org.gwtbootstrap3.client.ui.CheckBox) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) HTML(com.google.gwt.user.client.ui.HTML) InfoPopup(org.uberfire.ext.widgets.common.client.common.InfoPopup)

Example 33 with HorizontalPanel

use of com.google.gwt.user.client.ui.HorizontalPanel 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 34 with HorizontalPanel

use of com.google.gwt.user.client.ui.HorizontalPanel in project drools-wb by kiegroup.

the class ActionSetFieldWidget method doLayout.

private void doLayout() {
    layout.clear();
    for (int i = 0; i < model.getFieldValues().length; i++) {
        ActionFieldValue val = model.getFieldValues()[i];
        layout.setWidget(i, 0, getSetterLabel());
        layout.setWidget(i, 1, fieldSelector(val));
        layout.setWidget(i, 2, valueEditor(val));
        final int idx = i;
        Image remove = GuidedRuleEditorImages508.INSTANCE.DeleteItemSmall();
        remove.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                if (Window.confirm(GuidedRuleEditorResources.CONSTANTS.RemoveThisItem())) {
                    model.removeField(idx);
                    setModified(true);
                    getModeller().refreshWidget();
                    // Signal possible change in Template variables
                    TemplateVariablesChangedEvent tvce = new TemplateVariablesChangedEvent(getModeller().getModel());
                    getEventBus().fireEventFromSource(tvce, getModeller().getModel());
                }
            }
        });
        if (!this.readOnly) {
            layout.setWidget(i, 3, remove);
        }
    }
    if (model.getFieldValues().length == 0) {
        HorizontalPanel h = new HorizontalPanel();
        h.add(getSetterLabel());
        if (!this.readOnly) {
            Image image = GuidedRuleEditorImages508.INSTANCE.Edit();
            image.setAltText(GuidedRuleEditorResources.CONSTANTS.AddFirstNewField());
            image.setTitle(GuidedRuleEditorResources.CONSTANTS.AddFirstNewField());
            image.addClickHandler(new ClickHandler() {

                public void onClick(ClickEvent sender) {
                    showAddFieldPopup(sender);
                }
            });
            h.add(image);
        }
        layout.setWidget(0, 0, h);
    }
// layout.setWidget( 0, 1, inner );
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ActionFieldValue(org.drools.workbench.models.datamodel.rule.ActionFieldValue) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) Image(com.google.gwt.user.client.ui.Image) TemplateVariablesChangedEvent(org.drools.workbench.screens.guided.rule.client.editor.events.TemplateVariablesChangedEvent)

Example 35 with HorizontalPanel

use of com.google.gwt.user.client.ui.HorizontalPanel in project drools-wb by kiegroup.

the class DSLSentenceWidget method addWidget.

private void addWidget(Widget currentBox) {
    if (currentBox instanceof NewLine) {
        currentRow = new HorizontalPanel();
        layout.add(currentRow);
        layout.setCellWidth(currentRow, "100%");
    } else {
        currentRow.add(currentBox);
    }
    widgets.add(currentBox);
}
Also used : HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel)

Aggregations

HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)75 Label (com.google.gwt.user.client.ui.Label)25 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)24 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)21 Image (com.google.gwt.user.client.ui.Image)15 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)14 SmallLabel (org.uberfire.ext.widgets.common.client.common.SmallLabel)11 HTML (com.google.gwt.user.client.ui.HTML)8 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)7 Widget (com.google.gwt.user.client.ui.Widget)7 NpTextBox (com.google.gwtexpui.globalkey.client.NpTextBox)7 Button (org.gwtbootstrap3.client.ui.Button)7 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)6 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)6 TextBox (com.google.gwt.user.client.ui.TextBox)6 KeyUpEvent (com.google.gwt.event.dom.client.KeyUpEvent)5 KeyUpHandler (com.google.gwt.event.dom.client.KeyUpHandler)5 TextBox (org.gwtbootstrap3.client.ui.TextBox)5 InfoPopup (org.uberfire.ext.widgets.common.client.common.InfoPopup)5 KeyPressEvent (com.google.gwt.event.dom.client.KeyPressEvent)4