use of org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle in project drools-wb by kiegroup.
the class CompositeFactPatternWidget method showFactTypeSelector.
/**
* Pops up the fact selector.
*/
protected void showFactTypeSelector(final Widget w) {
final ListBox box = new ListBox();
AsyncPackageDataModelOracle oracle = this.getModeller().getDataModelOracle();
String[] facts = oracle.getFactTypes();
box.addItem(GuidedRuleEditorResources.CONSTANTS.Choose());
for (int i = 0; i < facts.length; i++) {
box.addItem(facts[i]);
}
box.setSelectedIndex(0);
final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorResources.CONSTANTS.NewFactPattern());
popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.chooseFactType(), box);
box.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
pattern.addFactPattern(new FactPattern(box.getItemText(box.getSelectedIndex())));
setModified(true);
getModeller().refreshWidget();
popup.hide();
}
});
final Button fromBtn = new Button(HumanReadableConstants.INSTANCE.From());
final Button fromAccumulateBtn = new Button(HumanReadableConstants.INSTANCE.FromAccumulate());
final Button fromCollectBtn = new Button(HumanReadableConstants.INSTANCE.FromCollect());
ClickHandler btnsClickHandler = new ClickHandler() {
public void onClick(ClickEvent event) {
Widget sender = (Widget) event.getSource();
if (sender == fromBtn) {
pattern.addFactPattern(new FromCompositeFactPattern());
} else if (sender == fromAccumulateBtn) {
pattern.addFactPattern(new FromAccumulateCompositeFactPattern());
} else if (sender == fromCollectBtn) {
pattern.addFactPattern(new FromCollectCompositeFactPattern());
} else {
throw new IllegalArgumentException("Unknown sender: " + sender);
}
setModified(true);
getModeller().refreshWidget();
popup.hide();
}
};
fromBtn.addClickHandler(btnsClickHandler);
fromAccumulateBtn.addClickHandler(btnsClickHandler);
fromCollectBtn.addClickHandler(btnsClickHandler);
popup.addAttribute("", fromBtn);
popup.addAttribute("", fromAccumulateBtn);
popup.addAttribute("", fromCollectBtn);
popup.show();
}
use of org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle 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.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle in project drools-wb by kiegroup.
the class FromCollectCompositeFactPatternWidget method showRightPatternSelector.
/**
* Pops up the fact selector.
*/
protected void showRightPatternSelector(final Widget w) {
final ListBox box = new ListBox();
AsyncPackageDataModelOracle oracle = this.getModeller().getDataModelOracle();
String[] facts = oracle.getFactTypes();
box.addItem(GuidedRuleEditorResources.CONSTANTS.Choose());
for (int i = 0; i < facts.length; i++) {
box.addItem(facts[i]);
}
box.setSelectedIndex(0);
final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorResources.CONSTANTS.NewFactPattern());
popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.chooseFactType(), box);
box.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
getFromCollectPattern().setRightPattern(new FactPattern(box.getItemText(box.getSelectedIndex())));
setModified(true);
getModeller().refreshWidget();
popup.hide();
}
});
final Button freeFormDRLBtn = new Button(GuidedRuleEditorResources.CONSTANTS.FreeFormDrl());
final Button fromBtn = new Button(HumanReadableConstants.INSTANCE.From());
final Button fromAccumulateBtn = new Button(HumanReadableConstants.INSTANCE.FromAccumulate());
final Button fromCollectBtn = new Button(HumanReadableConstants.INSTANCE.FromCollect());
final Button fromEntryPointBtn = new Button(HumanReadableConstants.INSTANCE.FromEntryPoint());
ClickHandler btnsClickHandler = new ClickHandler() {
public void onClick(ClickEvent event) {
Widget sender = (Widget) event.getSource();
if (sender == fromBtn) {
getFromCollectPattern().setRightPattern(new FromCompositeFactPattern());
} else if (sender == fromAccumulateBtn) {
getFromCollectPattern().setRightPattern(new FromAccumulateCompositeFactPattern());
} else if (sender == fromCollectBtn) {
getFromCollectPattern().setRightPattern(new FromCollectCompositeFactPattern());
} else if (sender == freeFormDRLBtn) {
getFromCollectPattern().setRightPattern(new FreeFormLine());
} else if (sender == fromEntryPointBtn) {
getFromCollectPattern().setRightPattern(new FromEntryPointFactPattern());
} else {
throw new IllegalArgumentException("Unknown sender: " + sender);
}
setModified(true);
getModeller().refreshWidget();
popup.hide();
}
};
freeFormDRLBtn.addClickHandler(btnsClickHandler);
fromBtn.addClickHandler(btnsClickHandler);
fromAccumulateBtn.addClickHandler(btnsClickHandler);
fromCollectBtn.addClickHandler(btnsClickHandler);
fromEntryPointBtn.addClickHandler(btnsClickHandler);
popup.addAttribute("", freeFormDRLBtn);
popup.addAttribute("", fromBtn);
popup.addAttribute("", fromAccumulateBtn);
popup.addAttribute("", fromCollectBtn);
popup.addAttribute("", fromEntryPointBtn);
popup.show();
}
use of org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle in project drools-wb by kiegroup.
the class ActionWorkItemExecuteColumnSynchronizerTest method getOracle.
@Override
protected AsyncPackageDataModelOracle getOracle() {
final AsyncPackageDataModelOracle oracle = super.getOracle();
oracle.addModelFields(Collections.singletonMap("Applicant", new ModelField[] { modelField("this", "Applicant"), modelField("age", DataType.TYPE_NUMERIC_INTEGER) }));
return oracle;
}
use of org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle in project drools-wb by kiegroup.
the class ActionInsertFactColumnSynchronizerTest method getOracle.
@Override
protected AsyncPackageDataModelOracle getOracle() {
final AsyncPackageDataModelOracle oracle = super.getOracle();
oracle.addModelFields(Collections.singletonMap("Applicant", new ModelField[] { modelField("this", "Applicant"), modelField("age", DataType.TYPE_NUMERIC_INTEGER), modelField("name", DataType.TYPE_STRING), modelField("approved", DataType.TYPE_BOOLEAN) }));
return oracle;
}
Aggregations