Search in sources :

Example 1 with RuleModeller

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

the class GuidedRuleTemplateEditorViewImpl method setContent.

@Override
public void setContent(final TemplateModel model, final AsyncPackageDataModelOracle oracle, final Caller<RuleNamesService> ruleNamesService, final EventBus eventBus, final boolean isReadOnly) {
    this.modeller = new RuleModeller(model, oracle, new TemplateModellerWidgetFactory(), eventBus, isReadOnly);
    panel.setWidget(modeller);
    ruleNamesService.call(new RemoteCallback<Collection<String>>() {

        @Override
        public void callback(Collection<String> ruleNames) {
            modeller.setRuleNamesForPackage(ruleNames);
        }
    }).getRuleNames(oracle.getResourcePath(), model.getPackageName());
}
Also used : RuleModeller(org.drools.workbench.screens.guided.rule.client.editor.RuleModeller) Collection(java.util.Collection) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Example 2 with RuleModeller

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

the class RuleModellerPage method newRuleModeller.

private RuleModeller newRuleModeller() {
    final RuleModeller ruleModeller = new RuleModeller(ruleModel(), actionPlugins(), oracle(), widgetFactory(), configuration(), eventBus(), isReadOnly());
    presenter.getPackageParentRuleNames(ruleModeller::setRuleNamesForPackage);
    return ruleModeller;
}
Also used : RuleModeller(org.drools.workbench.screens.guided.rule.client.editor.RuleModeller)

Example 3 with RuleModeller

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

the class PopupCreatorTest method testOnExpressionEditorButtonClick.

@Test
public void testOnExpressionEditorButtonClick() {
    final String factType = "factType";
    final FactPattern factPattern = mock(FactPattern.class);
    final HasConstraints hasConstraints = mock(HasConstraints.class);
    final FormStylePopup popup = mock(FormStylePopup.class);
    final SingleFieldConstraintEBLeftSide constraint = mock(SingleFieldConstraintEBLeftSide.class);
    final RuleModeller ruleModeller = mock(RuleModeller.class);
    final ClickEvent clickEvent = mock(ClickEvent.class);
    doReturn(factType).when(factPattern).getFactType();
    doReturn(constraint).when(popupCreator).makeSingleFieldConstraintEBLeftSide(factType);
    doReturn(ruleModeller).when(popupCreator).getModeller();
    doReturn(factPattern).when(popupCreator).getPattern();
    final ClickHandler clickHandler = popupCreator.onExpressionEditorButtonClick(hasConstraints, popup);
    clickHandler.onClick(clickEvent);
    verify(hasConstraints).addConstraint(constraint);
    verify(ruleModeller).refreshWidget();
    verify(popup).hide();
}
Also used : SingleFieldConstraintEBLeftSide(org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide) RuleModeller(org.drools.workbench.screens.guided.rule.client.editor.RuleModeller) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) HasConstraints(org.drools.workbench.models.datamodel.rule.HasConstraints) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) FormStylePopup(org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup) Test(org.junit.Test)

Example 4 with RuleModeller

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

the class DSLDropDownTest method testGetDropDown.

@Test
public void testGetDropDown() throws Exception {
    final String fact = "Fact";
    final String field = "field";
    final AsyncPackageDataModelOracle oracle = mock(AsyncPackageDataModelOracle.class);
    final RuleModeller ruleModeller = mock(RuleModeller.class);
    doReturn(oracle).when(ruleModeller).getDataModelOracle();
    final String variableDefinition = "varName:type:" + fact + "." + field;
    final DSLSentence dslSentence = mock(DSLSentence.class);
    final DSLVariableValue dslVariableValue = mock(DSLVariableValue.class);
    final boolean isMultipleSelect = false;
    final Callback<DSLDropDown> updateEnumsCallback = mock(Callback.class);
    testedDropDown = new DSLDropDown(ruleModeller, variableDefinition, dslSentence, dslVariableValue, isMultipleSelect, updateEnumsCallback);
    // reset oracle due to calls in DSLDropDown constructor
    reset(oracle);
    testedDropDown.getDropDownData();
    verify(oracle).getEnums(eq(fact), eq(field), anyMap());
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) RuleModeller(org.drools.workbench.screens.guided.rule.client.editor.RuleModeller) DSLVariableValue(org.drools.workbench.models.datamodel.rule.DSLVariableValue) DSLSentence(org.drools.workbench.models.datamodel.rule.DSLSentence) Test(org.junit.Test)

Example 5 with RuleModeller

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

the class RuleModellerPageTest method testRuleModeller.

@Test
public void testRuleModeller() throws Exception {
    when(brlActionPlugin.getRuleModel()).thenReturn(new RuleModel());
    when(brlActionPlugin.tableFormat()).thenReturn(GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY);
    when(brlActionPlugin.getRuleModellerActionPlugins()).thenReturn(Collections.singletonList(ruleModellerActionPlugin));
    when(brlActionPlugin.getRuleModellerConfiguration()).thenReturn(mock(RuleModellerConfiguration.class));
    when(presenter.getDataModelOracle()).thenReturn(mock(AsyncPackageDataModelOracle.class));
    final RuleModeller ruleModeller = brlActionPage.ruleModeller();
    assertNotNull(ruleModeller);
    assertEquals(brlActionPlugin.getRuleModel(), ruleModeller.getModel());
    assertEquals(Collections.singletonList(ruleModellerActionPlugin), ruleModeller.getActionPlugins());
    assertEquals(presenter.getDataModelOracle(), ruleModeller.getDataModelOracle());
    assertTrue(ruleModeller.getWidgetFactory() instanceof TemplateModellerWidgetFactory);
    assertFalse(ruleModeller.isReadOnly());
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) RuleModeller(org.drools.workbench.screens.guided.rule.client.editor.RuleModeller) TemplateModellerWidgetFactory(org.drools.workbench.screens.guided.template.client.editor.TemplateModellerWidgetFactory) RuleModellerConfiguration(org.drools.workbench.screens.guided.rule.client.editor.RuleModellerConfiguration) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) Test(org.junit.Test)

Aggregations

RuleModeller (org.drools.workbench.screens.guided.rule.client.editor.RuleModeller)5 Test (org.junit.Test)3 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)2 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 Collection (java.util.Collection)1 DSLSentence (org.drools.workbench.models.datamodel.rule.DSLSentence)1 DSLVariableValue (org.drools.workbench.models.datamodel.rule.DSLVariableValue)1 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)1 HasConstraints (org.drools.workbench.models.datamodel.rule.HasConstraints)1 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)1 SingleFieldConstraintEBLeftSide (org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide)1 RuleModellerConfiguration (org.drools.workbench.screens.guided.rule.client.editor.RuleModellerConfiguration)1 TemplateModellerWidgetFactory (org.drools.workbench.screens.guided.template.client.editor.TemplateModellerWidgetFactory)1 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)1 FormStylePopup (org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup)1