Search in sources :

Example 1 with ExpressionMethodParameter

use of org.drools.workbench.models.datamodel.rule.ExpressionMethodParameter in project drools by kiegroup.

the class CopyExpressionVisitor method visit.

@Override
public void visit(ExpressionMethodParameter part) {
    add(new ExpressionMethodParameter(part.getName(), part.getClassType(), part.getGenericType()));
    moveNext(part);
}
Also used : ExpressionMethodParameter(org.drools.workbench.models.datamodel.rule.ExpressionMethodParameter)

Example 2 with ExpressionMethodParameter

use of org.drools.workbench.models.datamodel.rule.ExpressionMethodParameter in project drools-wb by kiegroup.

the class ExpressionBuilder method createWidgetForExpression.

// Render Widgets for the Expression. ExpressionMethodParameter and ExpressionText parts
// are represented by a TextBox to allow the User to edit the values, Updates are
// reflected in the model.
private Widget createWidgetForExpression() {
    final HorizontalPanel container = new HorizontalPanel();
    container.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    container.setStylePrimaryName(GuidedRuleEditorResources.INSTANCE.css().container());
    for (ExpressionPart expressionPart : expression.getParts()) {
        if (expressionPart instanceof ExpressionUnboundFact) {
            continue;
        } else if (this.readOnly) {
            container.add(new Label(expressionPart.getName()));
        } else if (expressionPart instanceof ExpressionMethod) {
            container.add(new Label(expressionPart.getName()));
            container.add(new Label("("));
            final ExpressionMethod em = (ExpressionMethod) expressionPart;
            final List<ExpressionFormLine> emParams = em.getOrderedParams();
            for (int index = 0; index < emParams.size(); index++) {
                final ExpressionFormLine paramValueHolder = emParams.get(index);
                final String paramDataType = em.getParameterDataType(paramValueHolder);
                final ExpressionMethodParameter paramValue = ((ExpressionMethodParameter) paramValueHolder.getRootExpression());
                final TextBox paramValueEditor = TextBoxFactory.getTextBox(paramDataType);
                paramValueEditor.addValueChangeHandler(new ValueChangeHandler<String>() {

                    @Override
                    public void onValueChange(ValueChangeEvent<String> event) {
                        paramValue.setText(event.getValue());
                    }
                });
                paramValueEditor.setText(paramValue.getName());
                container.add(paramValueEditor);
                if (index < emParams.size() - 1) {
                    container.add(new Label(", "));
                }
            }
            container.add(new Label(")"));
        } else if (!(expressionPart instanceof ExpressionText)) {
            container.add(new Label(expressionPart.getName()));
        } else {
            final TextBox tb = new TextBox();
            final ExpressionText expressionTextPart = (ExpressionText) expressionPart;
            tb.setText(expressionTextPart.getName());
            tb.addChangeHandler(new ChangeHandler() {

                @Override
                public void onChange(final ChangeEvent changeEvent) {
                    expressionTextPart.setText(tb.getText());
                }
            });
            container.add(tb);
        }
        container.add(new Label("."));
    }
    return container;
}
Also used : ExpressionMethodParameter(org.drools.workbench.models.datamodel.rule.ExpressionMethodParameter) ExpressionPart(org.drools.workbench.models.datamodel.rule.ExpressionPart) Label(com.google.gwt.user.client.ui.Label) ClickableLabel(org.uberfire.ext.widgets.common.client.common.ClickableLabel) SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) ExpressionText(org.drools.workbench.models.datamodel.rule.ExpressionText) TextBox(org.gwtbootstrap3.client.ui.TextBox) ExpressionUnboundFact(org.drools.workbench.models.datamodel.rule.ExpressionUnboundFact) ExpressionMethod(org.drools.workbench.models.datamodel.rule.ExpressionMethod) ExpressionFormLine(org.drools.workbench.models.datamodel.rule.ExpressionFormLine) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) ExpressionTypeChangeEvent(org.drools.workbench.screens.guided.rule.client.editor.ExpressionTypeChangeEvent) ExpressionChangeEvent(org.drools.workbench.screens.guided.rule.client.editor.ExpressionChangeEvent) ExpressionChangeHandler(org.drools.workbench.screens.guided.rule.client.editor.ExpressionChangeHandler) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) ExpressionTypeChangeHandler(org.drools.workbench.screens.guided.rule.client.editor.ExpressionTypeChangeHandler) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel)

Example 3 with ExpressionMethodParameter

use of org.drools.workbench.models.datamodel.rule.ExpressionMethodParameter in project drools by kiegroup.

the class CopyExpressionVisitorTest method testExpressionFormLineCopy.

@Test
public void testExpressionFormLineCopy() {
    ExpressionFormLine efl = new ExpressionFormLine();
    efl.appendPart(new ExpressionCollection("collection", "CT", "GT", "PT"));
    efl.appendPart(new ExpressionCollectionIndex("collectionIndex", "CT", "GT"));
    efl.appendPart(new ExpressionField("field", "CT", "FT", "PT"));
    efl.appendPart(new ExpressionFieldVariable("fieldVariable", "Type"));
    efl.appendPart(new ExpressionGlobalVariable("globalVariable", "CT", "GT", "PT"));
    efl.appendPart(new ExpressionMethod("method", "CT", "GT"));
    efl.appendPart(new ExpressionMethodParameter("methodParam", "CT", "GT"));
    efl.appendPart(new ExpressionText("text"));
    efl.appendPart(new ExpressionUnboundFact("FactType"));
    efl.appendPart(new ExpressionVariable("binding", "FactType"));
    // verify that the new instance created with copy constructor is equal to original
    assertEquals(efl, new ExpressionFormLine(efl));
}
Also used : ExpressionFormLine(org.drools.workbench.models.datamodel.rule.ExpressionFormLine) ExpressionFieldVariable(org.drools.workbench.models.datamodel.rule.ExpressionFieldVariable) ExpressionMethod(org.drools.workbench.models.datamodel.rule.ExpressionMethod) ExpressionCollectionIndex(org.drools.workbench.models.datamodel.rule.ExpressionCollectionIndex) ExpressionMethodParameter(org.drools.workbench.models.datamodel.rule.ExpressionMethodParameter) ExpressionCollection(org.drools.workbench.models.datamodel.rule.ExpressionCollection) ExpressionText(org.drools.workbench.models.datamodel.rule.ExpressionText) ExpressionVariable(org.drools.workbench.models.datamodel.rule.ExpressionVariable) ExpressionField(org.drools.workbench.models.datamodel.rule.ExpressionField) ExpressionUnboundFact(org.drools.workbench.models.datamodel.rule.ExpressionUnboundFact) ExpressionGlobalVariable(org.drools.workbench.models.datamodel.rule.ExpressionGlobalVariable) Test(org.junit.Test)

Aggregations

ExpressionMethodParameter (org.drools.workbench.models.datamodel.rule.ExpressionMethodParameter)3 ExpressionFormLine (org.drools.workbench.models.datamodel.rule.ExpressionFormLine)2 ExpressionMethod (org.drools.workbench.models.datamodel.rule.ExpressionMethod)2 ExpressionText (org.drools.workbench.models.datamodel.rule.ExpressionText)2 ExpressionUnboundFact (org.drools.workbench.models.datamodel.rule.ExpressionUnboundFact)2 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)1 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)1 ValueChangeEvent (com.google.gwt.event.logical.shared.ValueChangeEvent)1 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)1 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)1 Label (com.google.gwt.user.client.ui.Label)1 ExpressionCollection (org.drools.workbench.models.datamodel.rule.ExpressionCollection)1 ExpressionCollectionIndex (org.drools.workbench.models.datamodel.rule.ExpressionCollectionIndex)1 ExpressionField (org.drools.workbench.models.datamodel.rule.ExpressionField)1 ExpressionFieldVariable (org.drools.workbench.models.datamodel.rule.ExpressionFieldVariable)1 ExpressionGlobalVariable (org.drools.workbench.models.datamodel.rule.ExpressionGlobalVariable)1 ExpressionPart (org.drools.workbench.models.datamodel.rule.ExpressionPart)1 ExpressionVariable (org.drools.workbench.models.datamodel.rule.ExpressionVariable)1 ExpressionChangeEvent (org.drools.workbench.screens.guided.rule.client.editor.ExpressionChangeEvent)1 ExpressionChangeHandler (org.drools.workbench.screens.guided.rule.client.editor.ExpressionChangeHandler)1