use of org.kie.soup.project.datamodel.oracle.DropDownData in project kie-wb-common by kiegroup.
the class AbstractProxyPopupDropDownEditCell method startEditing.
// Start editing the cell
@Override
protected void startEditing(final Context context, final Element parent, final C value) {
// We need to get the list of potential values for the enumeration. Since the content
// of the list may be different for each cell (dependent enumerations) the list
// has to be populated "on demand".
DropDownData dd = dmo.getEnums(this.factType, this.factField, this.dropDownManager.getCurrentValueMap(context));
if (dd == null) {
// If no enumeration exists show a TextBox
delegate = singleValueEditor;
delegate.setValue(value);
vPanel.clear();
vPanel.add(delegate.asWidget());
} else {
// Otherwise show a drop-down list box
delegate = multipleValueEditor;
delegate.setDropDownData(dd);
vPanel.clear();
vPanel.add(delegate.asWidget());
}
delegate.startEditing(context, parent, value);
panel.setPopupPositionAndShow(new PositionCallback() {
public void setPosition(int offsetWidth, int offsetHeight) {
panel.setPopupPosition(parent.getAbsoluteLeft() + offsetX, parent.getAbsoluteTop() + offsetY);
// Focus the first enabled control
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
public void execute() {
delegate.setFocus(true);
}
});
}
});
}
use of org.kie.soup.project.datamodel.oracle.DropDownData in project kie-wb-common by kiegroup.
the class AbstractProxyPopupDropDownEditCell method render.
@Override
public void render(final Context context, final C value, final SafeHtmlBuilder sb) {
// We need to get the list of potential values to lookup the "Display" value from the "Stored" value.
// Since the content of the list may be different for each cell (dependent enumerations) the list
// has to be populated "on demand".
DropDownData dd = dmo.getEnums(this.factType, this.factField, this.dropDownManager.getCurrentValueMap(context));
if (dd == null) {
// If no enumeration exists show a TextBox
delegate = singleValueEditor;
delegate.setValue(value);
vPanel.clear();
vPanel.add(delegate.asWidget());
} else {
// Otherwise show a drop-down list box
delegate = multipleValueEditor;
delegate.setDropDownData(dd);
vPanel.clear();
vPanel.add(delegate.asWidget());
}
delegate.render(context, value, sb, renderer);
}
use of org.kie.soup.project.datamodel.oracle.DropDownData in project kie-wb-common by kiegroup.
the class PopupDropDownEditCell method render.
@Override
public void render(Context context, String value, SafeHtmlBuilder sb) {
// We need to get the list of potential values to lookup the "Display" value from the "Stored" value.
// Since the content of the list may be different for each cell (dependent enumerations) the list
// has to be populated "on demand".
DropDownData dd = dmo.getEnums(this.factType, this.factField, this.dropDownManager.getCurrentValueMap(context));
if (dd == null) {
return;
}
utilities.setDropDownData(value, dd, isMultipleSelect, dmo.getResourcePath(), listBox);
// Render value
if (value != null) {
String label = getLabel(value);
sb.append(renderer.render(label));
}
}
use of org.kie.soup.project.datamodel.oracle.DropDownData in project drools-wb by kiegroup.
the class GuidedRuleTemplateEditorServiceImplCDITest method testLoadContent.
@Test
public void testLoadContent() throws Exception {
final Path testedPath = getPath(CARS);
final GuidedTemplateEditorContent testedContent = testedService.loadContent(testedPath);
oracleFactory.makeAsyncPackageDataModelOracle(testedPath, testedContent.getModel(), testedContent.getDataModel());
final String declaredFactInEnum = "Car";
final String declaredFieldInEnum = "price";
final Map<String, String> actualFieldValues = new HashMap<String, String>() {
{
put("color", "red");
}
};
final DropDownData dropDownData = asyncOracle.getEnums(declaredFactInEnum, declaredFieldInEnum, actualFieldValues);
Assertions.assertThat(dropDownData.getQueryExpression()).isEqualTo("(new org.kiegroup.PriceHelper()).getPrices(\"@{color}\")");
Assertions.assertThat(dropDownData.getValuePairs()).hasSize(1);
Assertions.assertThat(dropDownData.getValuePairs()[0]).isEqualTo("color=red");
}
use of org.kie.soup.project.datamodel.oracle.DropDownData in project drools-wb by kiegroup.
the class VerifyFieldConstraintEditor method refreshEditor.
private void refreshEditor() {
String flType = oracle.getFieldType(factType, field.getFieldName());
panel.clear();
if (flType != null && flType.equals(DataType.TYPE_BOOLEAN)) {
String[] c = new String[] { "true", "false" };
panel.add(new EnumDropDown(field.getExpected(), new DropDownValueChanged() {
public void valueChanged(String newText, String newValue) {
callback.valueChanged(newValue);
}
}, DropDownData.create(c), oracle.getResourcePath()));
} else if (flType != null && flType.equals(DataType.TYPE_DATE)) {
FieldDatePicker fieldDatePicker = new FieldDatePicker(new FieldDatePickerViewImpl());
fieldDatePicker.setValue(field.getExpected());
fieldDatePicker.addValueChangeHandler(new ValueChangeHandler<String>() {
@Override
public void onValueChange(ValueChangeEvent<String> event) {
field.setExpected(event.getValue());
}
});
panel.add(fieldDatePicker);
} else {
Map<String, String> currentValueMap = new HashMap<String, String>();
// TODO fill currentValueMap with values of other VerifyFields (if any)
DropDownData dropDownData = oracle.getEnums(factType, field.getFieldName(), currentValueMap);
if (dropDownData != null) {
// GUVNOR-1324: Java enums are of type TYPE_COMPARABLE whereas Guvnor enums are not.
// The distinction here controls whether the EXPECTED value is handled as a true
// Java enum or a literal with a selection list (i.e. Guvnor enum)
String dataType = oracle.getFieldType(factType, field.getFieldName());
if (dataType.equals(DataType.TYPE_COMPARABLE)) {
field.setNature(FieldData.TYPE_ENUM);
} else {
field.setNature(FieldData.TYPE_LITERAL);
}
panel.add(new EnumDropDown(field.getExpected(), new DropDownValueChanged() {
public void valueChanged(String newText, String newValue) {
callback.valueChanged(newValue);
}
}, dropDownData, oracle.getResourcePath()));
} else {
if (field.getExpected() != null && field.getExpected().length() > 0 && field.getNature() == FieldData.TYPE_UNDEFINED) {
if (field.getExpected().charAt(0) == '=') {
field.setNature(FieldData.TYPE_VARIABLE);
} else {
field.setNature(FieldData.TYPE_LITERAL);
}
}
if (field.getNature() == FieldData.TYPE_UNDEFINED && isThereABoundVariableToSet() == true) {
Image clickme = CommonAltedImages.INSTANCE.Edit();
clickme.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
showTypeChoice((Widget) event.getSource(), field);
}
});
panel.add(clickme);
} else if (field.getNature() == FieldData.TYPE_VARIABLE) {
panel.add(variableEditor());
} else {
panel.add(editableTextBox(callback, flType, field.getFieldName(), field.getExpected()));
}
}
}
}
Aggregations