Search in sources :

Example 1 with DirtyableVerticalPane

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

the class RuleModeller method renderRhs.

/**
 * Do all the widgets for the RHS.
 */
private void renderRhs(final RuleModel model) {
    for (int i = 0; i < model.rhs.length; i++) {
        DirtyableVerticalPane widget = new DirtyableVerticalPane();
        widget.setWidth("100%");
        IAction action = model.rhs[i];
        // if lockRHS() set the widget RO, otherwise let them decide.
        Boolean readOnly = this.lockRHS() ? true : null;
        RuleModellerWidget w = getWidgetFactory().getWidget(this, eventBus, action, readOnly);
        w.addOnModifiedCommand(this.onWidgetModifiedCommand);
        widget.add(wrapRHSWidget(model, i, w));
        widget.add(spacerWidget());
        layout.setWidget(currentLayoutRow, 0, new DirtyableHorizontalPane());
        layout.setWidget(currentLayoutRow, 1, new DirtyableHorizontalPane());
        layout.setWidget(currentLayoutRow, 2, this.wrapLineNumber(i + 1, false));
        layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 2, HasHorizontalAlignment.ALIGN_CENTER);
        layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 2, HasVerticalAlignment.ALIGN_MIDDLE);
        layout.setWidget(currentLayoutRow, 3, widget);
        layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 3, HasHorizontalAlignment.ALIGN_LEFT);
        layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 3, HasVerticalAlignment.ALIGN_TOP);
        layout.getFlexCellFormatter().setWidth(currentLayoutRow, 3, "100%");
        layout.getRowFormatter().addStyleName(currentLayoutRow, (i % 2 == 0 ? GuidedRuleEditorResources.INSTANCE.css().evenRow() : GuidedRuleEditorResources.INSTANCE.css().oddRow()));
        if (!w.isFactTypeKnown()) {
            addInvalidPatternIcon();
            addFactTypeKnownValueChangeHandler(w, currentLayoutRow);
        }
        final int index = i;
        if (!(this.lockRHS() || w.isReadOnly())) {
            this.addActionsButtonsToLayout(GuidedRuleEditorResources.CONSTANTS.AddAnActionBelow(), new ClickHandler() {

                public void onClick(ClickEvent event) {
                    showActionSelector(index + 1);
                }
            }, new ClickHandler() {

                public void onClick(ClickEvent event) {
                    model.moveRhsItemDown(index);
                    refreshWidget();
                }
            }, new ClickHandler() {

                public void onClick(ClickEvent event) {
                    model.moveRhsItemUp(index);
                    refreshWidget();
                }
            });
        }
        this.rhsWidgets.add(w);
        currentLayoutRow++;
    }
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) IAction(org.drools.workbench.models.datamodel.rule.IAction) DirtyableVerticalPane(org.uberfire.ext.widgets.common.client.common.DirtyableVerticalPane) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) DirtyableHorizontalPane(org.uberfire.ext.widgets.common.client.common.DirtyableHorizontalPane) RuleModellerWidget(org.drools.workbench.screens.guided.rule.client.widget.RuleModellerWidget)

Example 2 with DirtyableVerticalPane

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

the class CompositeFactPatternWidget method doLayout.

protected void doLayout() {
    this.layout.setWidget(0, 0, getCompositeLabel());
    this.layout.getFlexCellFormatter().setColSpan(0, 0, 2);
    // this.layout.getFlexCellFormatter().setWidth(0, 0, "15%");
    this.layout.setWidget(1, 0, new HTML("&nbsp;&nbsp;&nbsp;&nbsp;"));
    if (this.pattern.getPatterns() != null) {
        DirtyableVerticalPane vert = new DirtyableVerticalPane();
        IFactPattern[] facts = pattern.getPatterns();
        for (int i = 0; i < facts.length; i++) {
            RuleModellerWidget widget = this.getModeller().getWidgetFactory().getWidget(this.getModeller(), this.getEventBus(), facts[i], this.readOnly);
            widget.addOnModifiedCommand(new Command() {

                public void execute() {
                    setModified(true);
                }
            });
            // Wrap widget so the Fact pattern can be deleted
            vert.add(wrapLHSWidget(pattern, i, widget));
            vert.add(spacerWidget());
        }
        this.layout.setWidget(1, 1, vert);
    }
}
Also used : Command(com.google.gwt.user.client.Command) DirtyableVerticalPane(org.uberfire.ext.widgets.common.client.common.DirtyableVerticalPane) HTML(com.google.gwt.user.client.ui.HTML) IFactPattern(org.drools.workbench.models.datamodel.rule.IFactPattern)

Example 3 with DirtyableVerticalPane

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

the class RuleModeller method renderLhs.

/**
 * Builds all the condition widgets.
 */
private void renderLhs(final RuleModel model) {
    for (int i = 0; i < model.lhs.length; i++) {
        DirtyableVerticalPane vert = new DirtyableVerticalPane();
        vert.setWidth("100%");
        // if lockLHS() set the widget RO, otherwise let them decide.
        Boolean readOnly = this.lockLHS() ? true : null;
        IPattern pattern = model.lhs[i];
        final RuleModellerWidget widget = getWidgetFactory().getWidget(this, eventBus, pattern, readOnly);
        widget.addOnModifiedCommand(this.onWidgetModifiedCommand);
        vert.add(wrapLHSWidget(model, i, widget));
        vert.add(spacerWidget());
        layout.setWidget(currentLayoutRow, 0, new DirtyableHorizontalPane());
        layout.setWidget(currentLayoutRow, 1, new DirtyableHorizontalPane());
        layout.setWidget(currentLayoutRow, 2, this.wrapLineNumber(i + 1, true));
        layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 2, HasHorizontalAlignment.ALIGN_CENTER);
        layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 2, HasVerticalAlignment.ALIGN_MIDDLE);
        layout.setWidget(currentLayoutRow, 3, vert);
        layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 3, HasHorizontalAlignment.ALIGN_LEFT);
        layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 3, HasVerticalAlignment.ALIGN_TOP);
        layout.getFlexCellFormatter().setWidth(currentLayoutRow, 3, "100%");
        layout.getRowFormatter().addStyleName(currentLayoutRow, (i % 2 == 0 ? GuidedRuleEditorResources.INSTANCE.css().evenRow() : GuidedRuleEditorResources.INSTANCE.css().oddRow()));
        if (!widget.isFactTypeKnown()) {
            addInvalidPatternIcon();
            addFactTypeKnownValueChangeHandler(widget, currentLayoutRow);
        }
        final int index = i;
        if (!(this.lockLHS() || widget.isReadOnly())) {
            this.addActionsButtonsToLayout(GuidedRuleEditorResources.CONSTANTS.AddAConditionBelow(), new ClickHandler() {

                public void onClick(ClickEvent event) {
                    showConditionSelector(index + 1);
                }
            }, new ClickHandler() {

                public void onClick(ClickEvent event) {
                    model.moveLhsItemDown(index);
                    refreshWidget();
                }
            }, new ClickHandler() {

                public void onClick(ClickEvent event) {
                    model.moveLhsItemUp(index);
                    refreshWidget();
                }
            });
        }
        this.lhsWidgets.add(widget);
        currentLayoutRow++;
    }
}
Also used : IPattern(org.drools.workbench.models.datamodel.rule.IPattern) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) DirtyableVerticalPane(org.uberfire.ext.widgets.common.client.common.DirtyableVerticalPane) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) DirtyableHorizontalPane(org.uberfire.ext.widgets.common.client.common.DirtyableHorizontalPane) RuleModellerWidget(org.drools.workbench.screens.guided.rule.client.widget.RuleModellerWidget)

Aggregations

DirtyableVerticalPane (org.uberfire.ext.widgets.common.client.common.DirtyableVerticalPane)3 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)2 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)2 RuleModellerWidget (org.drools.workbench.screens.guided.rule.client.widget.RuleModellerWidget)2 DirtyableHorizontalPane (org.uberfire.ext.widgets.common.client.common.DirtyableHorizontalPane)2 Command (com.google.gwt.user.client.Command)1 HTML (com.google.gwt.user.client.ui.HTML)1 IAction (org.drools.workbench.models.datamodel.rule.IAction)1 IFactPattern (org.drools.workbench.models.datamodel.rule.IFactPattern)1 IPattern (org.drools.workbench.models.datamodel.rule.IPattern)1