Search in sources :

Example 1 with PopupCreator

use of org.drools.workbench.screens.guided.rule.client.editor.factPattern.PopupCreator in project drools-wb by kiegroup.

the class FactPatternWidget method fieldLabel.

/**
 * get the field widget. This may be a simple label, or it may be bound (and
 * show the var name) or a icon to create a binding. It will only show the
 * binding option of showBinding is true.
 */
private Widget fieldLabel(final SingleFieldConstraint con, final HasConstraints hasConstraints, final boolean showBinding, final int padding) {
    HorizontalPanel ab = new HorizontalPanel();
    ab.setStyleName("modeller-field-Label");
    StringBuilder bindingLabel = new StringBuilder();
    if (con.isBound()) {
        bindingLabel.append("<b>[");
        bindingLabel.append(con.getFieldBinding());
        bindingLabel.append("]</b>&nbsp;");
    }
    String fieldName = con.getFieldName();
    bindingLabel.append(fieldName);
    if (bindable && showBinding && !this.readOnly) {
        ClickHandler click = event -> {
            // If field name is "this" use parent FactPattern type otherwise we can use the Constraint's field type
            if (DataType.TYPE_THIS.equals(fieldName)) {
                getConnectives().getDataModelOracle().getFieldCompletions(pattern.getFactType(), fields -> popupCreator.showBindFieldPopup(pattern, con, fields, popupCreator));
            } else {
                getConnectives().getDataModelOracle().getFieldCompletions(con.getFieldType(), fields -> popupCreator.showBindFieldPopup(pattern, con, fields, popupCreator));
            }
        };
        ClickableLabel cl = new ClickableLabel(bindingLabel.toString(), click, !this.readOnly);
        DOM.setStyleAttribute(cl.getElement(), "marginLeft", "" + padding + "pt");
        ab.add(cl);
    } else {
        ab.add(new SmallLabel(bindingLabel.toString()));
    }
    return ab;
}
Also used : CompositeFieldConstraint(org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint) DataType(org.kie.soup.project.datamodel.oracle.DataType) FlexTable(com.google.gwt.user.client.ui.FlexTable) Image(com.google.gwt.user.client.ui.Image) SingleFieldConstraintOperatorSelector(org.drools.workbench.screens.guided.rule.client.widget.operator.SingleFieldConstraintOperatorSelector) HumanReadable(org.kie.workbench.common.widgets.client.resources.HumanReadable) HTML(com.google.gwt.user.client.ui.HTML) Label(com.google.gwt.user.client.ui.Label) Map(java.util.Map) RuleModeller(org.drools.workbench.screens.guided.rule.client.editor.RuleModeller) ToStringExpressionVisitor(org.drools.workbench.models.datamodel.rule.visitors.ToStringExpressionVisitor) EventBus(com.google.gwt.event.shared.EventBus) DOM(com.google.gwt.user.client.DOM) ConstraintValueEditor(org.drools.workbench.screens.guided.rule.client.editor.ConstraintValueEditor) TextBox(org.gwtbootstrap3.client.ui.TextBox) FieldConstraint(org.drools.workbench.models.datamodel.rule.FieldConstraint) MoveUpButton(org.drools.workbench.screens.guided.rule.client.editor.MoveUpButton) ClickableLabel(org.uberfire.ext.widgets.common.client.common.ClickableLabel) List(java.util.List) Widget(com.google.gwt.user.client.ui.Widget) GuidedRuleEditorImages508(org.drools.workbench.screens.guided.rule.client.resources.images.GuidedRuleEditorImages508) DRLConstraintValueBuilder(org.drools.workbench.models.datamodel.rule.builder.DRLConstraintValueBuilder) HumanReadableConstants(org.kie.workbench.common.widgets.client.resources.i18n.HumanReadableConstants) CEPWindowOperatorsDropdown(org.drools.workbench.screens.guided.rule.client.editor.CEPWindowOperatorsDropdown) OperatorSelection(org.drools.workbench.screens.guided.rule.client.editor.OperatorSelection) RefreshUtil(org.drools.workbench.screens.guided.rule.client.util.RefreshUtil) SingleFieldConstraintEBLeftSide(org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide) HasCEPWindow(org.drools.workbench.models.datamodel.rule.HasCEPWindow) MoveDownButton(org.drools.workbench.screens.guided.rule.client.editor.MoveDownButton) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) GuidedRuleEditorResources(org.drools.workbench.screens.guided.rule.client.resources.GuidedRuleEditorResources) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) HashMap(java.util.HashMap) GWT(com.google.gwt.core.client.GWT) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ArrayList(java.util.ArrayList) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) Window(com.google.gwt.user.client.Window) RuleAttribute(org.drools.workbench.models.datamodel.rule.RuleAttribute) IPattern(org.drools.workbench.models.datamodel.rule.IPattern) SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) Connectives(org.drools.workbench.screens.guided.rule.client.editor.factPattern.Connectives) HasHorizontalAlignment(com.google.gwt.user.client.ui.HasHorizontalAlignment) HasConstraints(org.drools.workbench.models.datamodel.rule.HasConstraints) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter) HasVerticalAlignment(com.google.gwt.user.client.ui.HasVerticalAlignment) PopupCreator(org.drools.workbench.screens.guided.rule.client.editor.factPattern.PopupCreator) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) ClickableLabel(org.uberfire.ext.widgets.common.client.common.ClickableLabel)

Aggregations

GWT (com.google.gwt.core.client.GWT)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 EventBus (com.google.gwt.event.shared.EventBus)1 DOM (com.google.gwt.user.client.DOM)1 Window (com.google.gwt.user.client.Window)1 FlexTable (com.google.gwt.user.client.ui.FlexTable)1 FlexCellFormatter (com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter)1 HTML (com.google.gwt.user.client.ui.HTML)1 HasHorizontalAlignment (com.google.gwt.user.client.ui.HasHorizontalAlignment)1 HasVerticalAlignment (com.google.gwt.user.client.ui.HasVerticalAlignment)1 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)1 Image (com.google.gwt.user.client.ui.Image)1 Label (com.google.gwt.user.client.ui.Label)1 Widget (com.google.gwt.user.client.ui.Widget)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)1 CompositeFieldConstraint (org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint)1