use of org.drools.workbench.screens.guided.rule.client.editor.ActionValueEditor in project drools-wb by kiegroup.
the class ActionInsertFactWidget method valueEditor.
ActionValueEditor valueEditor(final ActionFieldValue actionFieldValue) {
final ActionValueEditor actionValueEditor = actionValueEditor(factType, actionFieldValue, model.getFieldValues(), readOnly);
actionValueEditor.setOnChangeCommand(new Command() {
public void execute() {
RefreshUtil.refreshActionValueEditorsDropDownData(actionValueEditors, actionFieldValue);
setModified(true);
}
});
// Keep a reference to the value editors so they can be refreshed for dependent enums
actionValueEditors.put(actionFieldValue, actionValueEditor);
return actionValueEditor;
}
use of org.drools.workbench.screens.guided.rule.client.editor.ActionValueEditor in project drools-wb by kiegroup.
the class RefreshUtilTest method testActionValueEditorRefreshPredicateNotRefreshed.
@Test
public void testActionValueEditorRefreshPredicateNotRefreshed() throws Exception {
final ActionFieldValue valueOne = mock(ActionFieldValue.class);
final ActionFieldValue valueTwo = mock(ActionFieldValue.class);
final ActionValueEditor editorOne = mock(ActionValueEditor.class);
final ActionValueEditor editorTwo = mock(ActionValueEditor.class);
final Map<ActionFieldValue, ActionValueEditor> editors = new HashMap<>();
editors.put(valueOne, editorOne);
editors.put(valueTwo, editorTwo);
doReturn(FieldNatureType.TYPE_LITERAL).when(valueOne).getNature();
doReturn(FieldNatureType.TYPE_PREDICATE).when(valueTwo).getNature();
RefreshUtil.refreshActionValueEditorsDropDownData(editors, mock(ActionFieldValue.class));
verify(editorOne).refresh();
verify(editorTwo, never()).refresh();
}
use of org.drools.workbench.screens.guided.rule.client.editor.ActionValueEditor in project drools-wb by kiegroup.
the class ActionSetFieldWidgetTest method testOnChangeCallbackRegisteredForActionValueEditor.
@Test
public void testOnChangeCallbackRegisteredForActionValueEditor() throws Exception {
final ActionFieldValue value = new ActionFieldValue();
value.setNature(FieldNatureType.TYPE_LITERAL);
value.setField("a");
final ActionValueEditor editor = mock(ActionValueEditor.class);
doReturn(editor).when(testedWidget).actionValueEditor(any(), eq(value), any(), anyBoolean());
final ActionFieldValue valueTwo = new ActionFieldValue();
valueTwo.setNature(FieldNatureType.TYPE_LITERAL);
valueTwo.setField("b");
final ActionValueEditor editorTwo = mock(ActionValueEditor.class);
doReturn(editorTwo).when(testedWidget).actionValueEditor(any(), eq(valueTwo), any(), anyBoolean());
testedWidget.valueEditor(value);
testedWidget.valueEditor(valueTwo);
verify(editor).setOnChangeCommand(commandCaptor.capture());
commandCaptor.getValue().execute();
verify(testedWidget).setModified(true);
verify(editorTwo).refresh();
}
use of org.drools.workbench.screens.guided.rule.client.editor.ActionValueEditor in project drools-wb by kiegroup.
the class ActionSetFieldWidget method valueEditor.
ActionValueEditor valueEditor(final ActionFieldValue actionFieldValue) {
AsyncPackageDataModelOracle oracle = this.getModeller().getDataModelOracle();
String type = "";
if (oracle.isGlobalVariable(this.model.getVariable())) {
type = oracle.getGlobalVariable(this.model.getVariable());
} else {
type = this.getModeller().getModel().getLHSBindingType(this.model.getVariable());
/*
* to take in account if the using a rhs bound variable
*/
if (type == null && !this.readOnly) {
type = this.getModeller().getModel().getRHSBoundFact(this.model.getVariable()).getFactType();
}
}
ActionValueEditor actionValueEditor = actionValueEditor(type, actionFieldValue, model.getFieldValues(), readOnly);
actionValueEditor.setOnChangeCommand(new Command() {
public void execute() {
RefreshUtil.refreshActionValueEditorsDropDownData(actionValueEditors, actionFieldValue);
setModified(true);
}
});
// Keep a reference to the value editors so they can be refreshed for dependent enums
actionValueEditors.put(actionFieldValue, actionValueEditor);
return actionValueEditor;
}
use of org.drools.workbench.screens.guided.rule.client.editor.ActionValueEditor in project drools-wb by kiegroup.
the class RefreshUtilTest method testActionValueEditorRefreshMultipleEditors.
@Test
public void testActionValueEditorRefreshMultipleEditors() throws Exception {
final ActionFieldValue valueOne = mock(ActionFieldValue.class);
final ActionFieldValue valueTwo = mock(ActionFieldValue.class);
final ActionValueEditor editorOne = mock(ActionValueEditor.class);
final ActionValueEditor editorTwo = mock(ActionValueEditor.class);
final Map<ActionFieldValue, ActionValueEditor> editors = new HashMap<>();
editors.put(valueOne, editorOne);
editors.put(valueTwo, editorTwo);
doReturn(FieldNatureType.TYPE_LITERAL).when(valueOne).getNature();
doReturn(FieldNatureType.TYPE_LITERAL).when(valueTwo).getNature();
RefreshUtil.refreshActionValueEditorsDropDownData(editors, mock(ActionFieldValue.class));
verify(editorOne).refresh();
verify(editorTwo).refresh();
}
Aggregations